A content module managing youtube version 2 feeds

Source file

A TIP_Content implementation that sets a default data engine capable to directly parse youtube feeds (version 2).

To be able to use this module, it suffices to configure a youtube2 module in your configuration options and feed it with a YouTube 2 video RSS file:

 $cfg = array(
     'movie'    => array(
         'type' => array('module', 'content', 'youtube2'),
         'data' => 'http://gdata.youtube.com/feeds/...?v=2'

The TIP_Youtube2 access to the feed is read-only, so there is no need for user authentication. To determine the URI to put in the 'data' option, please refer to the YouTube documentation:


Also, keep in mind this module expects a version 2 feed, so remember to always append "?v=2" at the end of the URI if you are using the standard feeds provided by YouTube.

After configuring it, you can use your newly "movie" module in the same way a common TIP_Content module is used.

To be able to access the feed, TIP_Youtube2 considers any <entry> in the feed as any SQL engine treats a row in a table. The field of this virtual row are mapped to a usable field id using the "fields_xpath" property of the TIP_XML engine. Here it is a (probably outdated) list of these virtual fields (together with the XPath used to map their value):

Adding new field mapping is trivial: up to now it was added what I actually need.

The above fields can be used in you templates just as every other field provided by the more usual TIP_Mysql engine. For instance, to get a list of the first 5 items, you can do something like this:

 <ul class="movie">{movie.forSelect(LIMIT 5)}
   <li><a href="{actionUri(view,{id})}">
     <img src="{thumbnail120x90}" width="120" height="90" />

Because TIP_Youtube2 accesses the underlying feed using the TIP_XML data engine there are some known restriction: for instance, you can't do a complex SQL query using the ORDER BY or GROUP BY clauses. For common usage, I think it was not worth the effort for a full-fledged SQL parser. Check the TIP_XML documentation to exactly know which queries can be executed.


checkOptions (&$options)

106 - 139

__construct ($options)


Properties values
148 - 151

Initializes a TIP_Youtube2 instance.

TIP_Youtube2 was last modified by TiP on Mon 25 May 2009 06:22:25 PM CEST
Hosted by BerliOS Developer Logo