PieX

From MODx Wiki

Jump to: navigation, search

 MODx Snippet 

PieX v0.6.1
Author 
ZeRo
MODx Versions 
>= 0.9.5
Last Updated 
11/3/2007

Contents


pieX is snippets which take in RSS news in your site.

You can use 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).

Downloads

Download the pieX Ver0.6.1

Reference

Installation

Get "simplepie.inc"

pieX needs "simplepie.inc" of Simplepie addition to pieX.

You can get "simplepie.inc" from simplepie:Download

Upload

  1. First, unzip "piex-v061.zip". Then you will see the following files.
    • piex-v061
      • [simplepie]
        • class.html2text.inc
        • simplepie_hatena.inc
        • piex.snippet.php(snippet code)
  2. Upload files, [simplepie] folder and all under the "assets/snippets". please look at "directory hierarchy".
  3. Unzip "simplepie_1.0.1.zip". Some files appear, but pieX needs only "simplepie.inc" in them.
  4. Upload "simplepie.inc" under the "assets/snippets/simplepie".

Directory hierarchy on the server

  • [assets]
    • [snippets]
      • [simplepie]
        • class.html2text.inc
        • simplepie.inc
        • simplepie_hatena.inc

Create snippets

Create snippets in the manager.

  1. resource > resource control > snippets > Create snippet
  2. Enter a snippets name. It is "pieX".
  3. Copy the content of "piex.snippet.php", then paste it into "snippets code(php)".
  4. Click "property" tab, then paste the following code into "default property".
    • &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;

Basic call

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

Case:URL has "?" or "=" or "&"

You rewrite each as follows.

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

Sample:

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

The above is like the following:

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

About snippets property

Property has the following meaning. The inside of a parenthesis is a parameter name in case it is called by snippets.

cache enable(cache_enable)

Determine whether to use cache. [true | false]. Default is "true".

cache life time(cache_time)

Determine the time to save in cache. A unit is "minute" "second". Default is 60 "minute" "second".

extend item class name(extclass)

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

noitem template chunk name(noitem)

Set the template(chunk), when pieX can not get data or there is no data.

Default is the following.

<p>no item</p>

Sample of chunk:

<p>There is no items. Or can not get items in order to be some trouble. </p>
 [+feed_url+]

date format(dateformat)

Set the format of date. Format follows strftime function of PHP. Default is "%Y/%m/%d %H:%M".

max items(max)

Determine the maximum number of item which want to display. Default is "10".

pattern rows(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 property Chunk Name(embed)

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

Parameter (required)

It is the required parameter which you can call in snippets.

&url

Set URI of RSS feed.

Parameter (Option)

It is the option parameter which you can call in snippets.

header

Set the chunk for header template. Default is the following.

<h2><a href="[+permalink+]" title="[+title+]">[+image_url+]</a></h2><ul>

footer

Set the chunk for footer template. Default is the following.

</ul>

item

Set the chunk for row template. Default is the following.

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

Others

You can set property of snippets as parameter. The following.

  • cache enable
  • cache_time
  • extclass
  • noitem
  • dateformat
  • max
  • rows
  • embed

Please refer to "About property" about meaning of each parameter.

Placeholder

header / footer

  • [+title+] ... feed titel
  • [+permalink+] ... feed URL
  • [+description(type,length)+] ... feed summary. You can omit "Type" and "length". Refer to "About [+description+]".
  • image_title ... logo image title
  • [+image_url(width,height)+] ... logo image URL. You can omit "width" and "height".
  • [+subscribe_xxxx+] ... You can use "subscribe function" of Simplepie. Refer to "About [+subscribe_xxx+]".

About [+description+]

You can set the following as type .

  • text ... Plain text. All HTML tag will be removed.
  • html ... Except for <a> and <img> will be removed.

Set to "length" which you display. In case 0 or blank, It will be displayed all.

Sample
[+description(text,300)+]

[+subscribe_xxx+] function

It inserts for URL of each service.

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

Please look at "simplepie API document" about other subscribe function.

item

  • [+title+] ... item title
  • [+permalink+] ... item URL
  • [+description+] ... item summary
  • [+date+] ... date
  • [+category+] ... category
  • [+author+] ... author
  • [+enclosure+] ...Display Podcast/videocast. (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.

Sample
<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.

sample:

alt=Download this enclosure!
audio=assets/image/place_audio.png
video=assets/image/place_video.png
mediaplayer=assets/flash/mediaplayer.swf
widescreen=true

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).

Little tips

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

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

Writer : MEGU

Personal tools