From MODx Wiki
Jump to: navigation, search

 MODx Snippet 

PieX v0.6.1
MODx Versions 
>= 0.9.5
Last Updated 

pieX is a snippet which can parse RSS feeds for your MODx websites. You can use the original template (chunk). This snippets runs on "allow_url_fopne = off". (Of course, also on "allow_url_fopne = on"). Also this snippets works using Simplepie.

Other features (by Simplepie):

  • Generate URL for Subscribe (support Podcast / Videocast).
  • Generate URL for bookmark (Add_to).


Download pieX Ver0.6.1



Getting the necessary files

pieX requires the file "simplepie.inc" from the original SimplePie script. This is not included in the download but you can get it of the Simplepie website.

  1. Download the SimplePie package here.
  2. Download the pieX package from the link above
  3. Unzip both the packages.


The pieX package comes with the following files (and hierarchy):

  • piex.snippet.php
  • piex-v061
    • [simplepie]
      • class.html2text.inc
      • simplepie_hatena.inc

You'll need to upload the 'class.html2text.inc' and 'simplepie_hatena.inc' files into the assets/snippets/simplepie folder on your server.

You'll only need the 'simplepie.inc' file from the SimplePie package - upload that file into the assets/snippets/simplepie folder also.

If you did this correct, you now have three files in your assets/snippets/simplepie folder: - 'class.html2text.inc' - 'simplepie_hatena.inc' - 'simplepie.inc'

Making it work

Before you can use pieX you need to create a new snippet.

In your MODx content manager, go to Resources (MODx 1.0: Elements) -> Resource Control (MODx 1.0: Manage Elements) -> Snippets -> Create Snippet.

For the Snippet name use pieX. The content of the snippet can be found in the piex.snippet.php file, found in the root of the pieX package. Copy/paste the contents of that file into the snippets content.

(The next step is, in my opinion, either optional or redundant. But as the snippet creator added it, I wont remove it for the sole reason of me not using it. You can use pieX without this step.)

Go into the Property tab, and paste the following code in the 'Default property' box:

&cache_enable=cache enable;text;true &cache_time=cache life time;text;60 &extclass=extend item class;text; &noitem=no item template chunk name;text; &dateformat=date format;text;%Y/%m/%d %H:%M &max=max items;text;30 &rows=pattern rows;text;0 &embed=embed property Chunk Name;text;

How to use

The basic call is:

[!pieX? &url=`feedURL`!]

feedURL can either be the link to a website (eg www.interestingblog.com) or the link to the rss blog page itself (eg www.interestingblog.com/blog/handylinks/rss.xml). pieX will automaticly try to find the rss feed.


If the RSS Feed you are trying to read with pieX has a question mark (?), an equal sign (=) or & in the link, you will need to rewrite it in order for pieX to work.

You rewrite them as follows.

  • "?" => |xq|
  • "=" => |xe|
  • "&" => |xa|


[!pieX? &url=`http://yoursite.com/index.php?act=rss&id=1`!]

The above needs to be rewritten to the following:

[!pieX? &url=`http://yoursite.com/index.php|xq|act|xe|rss|xa|id|xe|1`!]


The following parameters can be used to modify the snippet to your taste.

  • &url (link)

Defines the url of the RSS feed to view.

  • &header (chunk name)

Sets a chunk for the header template. The default is:

<h2><a href="[+permalink+]" title="[+title+]">[+image_url+]</a></h2><ul>
  • &footer (chunk name)

Sets a chunk for the footer template. The default is:

  • &item (chunk name)

Sets a chunk for the item template. This chunk will be called for each item retrieved from the feed. The default is:

<li><a href="[+permalink+]" title="[+description+]">[+title+]</a>([+date+])[+category+]</li>
  • &max (number)

Defines the maximum number of items the feed shows. Defaults to 10.

  • &len (number)

Defines the maximum number of symbols the item shows. Defaults to 128.

  • &cache_enable (true|false)

Determine if you want to use the caching feature. Defaults to 'true'.

  • &cache_time (number)

The time the cache will be kept. Specify a number in seconds. Defaults to 60.

  • &extclass (class name)

If you want to use "extend item class of Simplepie", set the class name. Default is blank.

  • &noitem (chunk name)

Set a chunk to use when pieX could not retrieve any data. Defaults to the following string: <p>no item</p>

  • &dateformat (strftime dateformat)

Change the timestamp/dateformat used. Check out the strftime function of PHP for the available options. Defaults to "%Y/%m/%d %H:%M".

  • &rows

Determine the maximum number of "[+no+]". Thereby, a value of "[+no+]" is repeated between 1-maximum until number of item. For example, if it assumes that 2 was set to it, the value of "[+no+]" will repeat 1 and 2. When 0 is specified, [+no+] will show sequential number until number of item. Default "0".

  • &embed

Set a chunk name which wrote the parameter of embed. Default is blank.


When creating your own templates for pieX you can use the following placeholders:

&header / &footer

  • [+title+] - title of the feed
  • [+permalink+] - link to the feed
  • [+description+] - summary of the current feed.
  • [+description(text)+] - summary of the current feed with all HTML tags removed
  • [+description(html)+] - summary of the current feed with all HTML tags except <a> and <img> removed.
  • [+description(type,number)+] - only show the first number characters of the feed's summary. Example:
  • [+image_title+] - logo image title
  • [+image_url(width,height)+] - logo image URL. You can omit "width" and "height".
  • [+subscribe_xxxx+] - the "subscribe function" of Simplepie. Refer to "About [+subscribe_xxx+]".

You can use this to insert links for certain services.

<a href="[+subscribe_google+]" title="Subscribe google">Subscribe google</a>

Check out the "simplepie API document" for more subscribe features.


  • [+title+] - item title
  • [+permalink+] - item URL
  • [+description+] - item summary
  • [+date+] - date
  • [+category+] - category
  • [+author+] - author
  • [+enclosure+] - Display embedded content (Refer to embed parameter).
  • [+add_to_xxxx+] - You can use "add_to" function of Simplepie. Refer to [+add_to_xxx+] function.
  • [+no+] - Sequential number of item. The value set by "pattern rows" or "rows" will appear.

You can use get method of Simplepie. For more information, refer to "Simplepie:Extending the SimplePie class".

[+add_to_xxx+] function

It inserts for URL of each Bookmarklet.

<a href="[+add_to_delciou+]" title="Register del.ci.ou">Register del.ci.ou</a>

For more information, refer to "simplepie:API document".

Embed parameter (For "Podcast/Videocast").

Determine the format of display of [+enclosure+]. The format of display depends on Simplepie. Create the chunk for. Value of chunk name turns into the value specified by "embed property Chunk Name" or "embed". Write option of "embed" into chunk code.


alt=Download this enclosure!

For more information, refer to "simplepie:native_embed".

Extending the SimplePie class

You can create the original extending the Simplepie class by yourself.

  1. Create the file of extending class, then save it in the form of the following.
    • simplepie_classname.inc
  2. Upload file under the "assets/snippets/simplepie".
  3. Set the parameter as follows.
    • [!pieX? &url=`feed url` &extclass=`classname`!]
    • You can set also with parameter of snippet(extend item class).

Tips & Hints

You can change the cache location. Change the following in the snippets code.

define("SIMPLEPIE_CACHE_LOCATION",$modx->config['base_path'] . "assets/cache/");

Writer : MEGU

Rewritten by --Mark 10:59, 12 July 2009 (PDT)

Personal tools