OPML Renderer

This page and the OPML Renderer are deprecated. In a few seconds, you will be automatically redirected to the page for Optimal, which now can be installed as a WordPress plugin.

OPML Renderer renders valid OPML from any source as an expandable/collapsible list.

XSL stylesheets are used to transform the OPML from XML to HTML. Two XSL stylesheets are included: one for use in pages or posts and one for use as a sidebar item .

OPML Renderer is invoked through either a new content filter or a new template function.

To access the content filter, use the following in a page or post (without spaces):

!OPMLRender : url,updatetime,page|sidebar

To access the template function, use the following:

<? OPMLRender('url','updatetime','page|sidebar'); ?>

  • 'updatetime' is the number of seconds to cache a file before requesting an update
  • 'page' or 'sidebar' indicates which XSL transform to use

Click here to download the latest version.

This is beta software, so please use with caution and report any problems.

Images are included as of version 0.5.

Thanks to iconophobia and the inlineRSS plugin for some code and ideas.

And great thanks to Dave Winer for his work on OPML.

Installation

  1. Unzip opmlRenderer.zip into your plugins directory. It should automatically create a new subdirectory.
  2. Activate the plugin.

That's about it!

You may want to edit the XSL stylesheets to use your own icons or change the appearance of the rendered HTML. Links to do so are provided in the plugin's description on the Plugin pane of the Admin panel.

Errata and Gotchas

I'm very sorry. At least I didn't destroy your data, right?

  • [+/-]Version 0.6
    • opmlRenderer.php - Bug in OPMLContent function prevents usage of content filter with remote URLs that have a query string. (fixed in development version)
  • [+/-]Version 0.5
    • opmlRenderer.php - Error in error message handling. (fixed in development version)
    • Should probably find a way to indicate that remote OPML is being fetched. (done in development version)
    • [+/-]Need to rework the XSL stylesheets' determination as to whether or not to use bulleted lists or bullet certain list items. (done in development version)
    • Need to see if plugin works as expected with WordPress 2.0 (done in development version) and PHP 5+ (OPEN)
    • Need to turn off caching of local files. (done in development version)
    • Need to fix XPath expressions, e.g., from @htmlUrl to @htmlUrl!="". (done in development version)
    • [+/-]Long-term goals:
  • [+/-]Version 0.4
    • Currently generating valid XHTML 1.0 Transitional. If you're using a different version, your pages probably won't validate unless you tweak the XSL stylesheets.
  • [+/-]Version 0.3
    • Not generating valid XHTML. My mistake! I'm fixing this for the next release.
    • Using a variable with the same name as a parameter. Will fix.
  • [+/-]Version 0.2
    • If you're using the :before CSS selector to generate "fancy" bullets on list items, you probably will still want to edit your CSS to eliminate those fancy bullets. For example, here's my stylesheet.
  • [+/-]Version 0.1
    • Dies on any failure to grab your OPML file. I will change this behavior so that instead it loads the cache file, if available, and if no cache file is available, it will die more gracefully.
    • Uses CSS classes in the XSL stylesheets, which you probably have not defined. I will change them to use explicit CSS styles.

Changes

  • [+/-]Verions 0.6
    • (There should be stuff here, but I seem to have over written this file with an older version. Basically, I fixed all the errata in version 0.5.)
  • [+/-]Version 0.5
    • New feature - OPML inclusion.
    • All files - Having learned more about creating WP plugins, the javascript was moved to the document head.
    • Images are now included.
  • [+/-]Version 0.4
    • opmlRenderer.php - Deletes cache file upon XSLT processing error, because this error is usually caused by a corrupt cache file (usually, an error page cached when trying and failing to grab a remote OPML file).
    • opmlRenderer.php - Changed the regex to capture and discard paragraph elements that get added by the wpautop filter. Necessary to enable the page to validate.
    • opmlRenderer-page.xsl, opmlRenderer-sidebar.xsl - Corrected some invalid XHTML.
    • opmlRenderer-page.xsl, opmlRenderer-sidebar.xsl - Renamed a variable that had the same name as a parameter.
    • opmlRenderer-page.xsl, opmlRenderer-sidebar.xsl - Added a div wrapper to rendered text to give user more flexability to change the presentation.
  • [+/-]Version 0.3
    • opmlRenderer.php - Added a check to ensure that allow_url_fopen is enabled if a remote OPML file is requested. Will emit an error message upon failure without dying.
    • opmlRenderer-page.xsl, opmlRenderer-sidebar.xsl - Cleanup and more CSS class sanitizing. No classes are used. Lists should render better on Internet Explorer.
    • opmlRenderer-page.xsl, opmlRenderer-sidebar.xsl - Changed the rendering of reading lists. The title always links to the home page (if available), and the feed may be viewed by clicking the XML icon.
  • [+/-]Version 0.2
    • opmlRenderer.php - Changed behavior upon failure to grab the specified OPML file or XSL stylesheet. Now, instead of dying upon failure to grab the OPML file, the cache file is displayed, and if there is no cache file, an error message is displayed and script execution continues. If the XSL stylesheet cannot be read, an error message is displayed and script execution continues.
    • opmlRenderer.php - Added a comment to the end of the rendered HTML if the cache file was used.
    • opmlRenderer-page.xsl, opmlRenderer-sidebar.xsl - Changed to use CSS styles instead of CSS classes, since users (other than the author) would not likely have those CSS classes (nobullet, blogrollbutton, opmlFolder) defined. N.B. - continues to use "nobullet", but only certain users should be affected (see errata).
  • [+/-]Version 0.1
    • Created

WordPress › Plugin: OPML Renderer « WordPress Support

78 comments

  1. My Bloglines feeds won’t validate anymore for some reason (it says “outline” in front of each feed now) but hopefully I can use this down the line if I ever find out how to export my feeds successfully, thx.

  2. Pingback: Library clips
  3. I’m trying to use this[4] from plain PHP, at least for now, but even though after a bunch of fixes my file validates[1] the renderer says it’s invalid[2]. I also installed as a plugin in WP and created a page template[3] but that didn’t work either. Can you see what the problem is?

    Thanks!

    [1] http://www.kbcafe.com/rss/rsv.aspx?xml=http%3A%2F%2Fwww.billsaysthis.com%2Fcontent%2Fmisc%2Fbillsaysthissubs_122405.opml

    [2] http://www.billsaysthis.com/content/misc/viewOPML.php

    [3] http://www.billsaysthis.com/wp/?page_id=98

    [4] http://www.billsaysthis.com/content/misc/billsaysthissubs_122405.opml

  4. Billy: Depending on just how invalid the OPML is, it may render anyway. Did you give it a shot?

    BillSaysthis: I notice that you’re using WordPress 2.0 — that could be the problem. I haven’t loaded WP2.0 yet, so I can’t test it. The OPML, though invalid, does render with my OPML Browser, which uses the same engine as this plugin.

  5. I loaded the plugin right away. I see it says: OPMLRender(‘url’,’updatetime’,’page|sidebar’)

    so if I want it in the sidebar, I would enter: OPMLRender(‘my opml URL [from opml manager]’,’1 min’,’sidebar’) in my opmlRenderer-sidebar.xsl file, is that right? if so, where do I enter it at in the file? TIA

  6. Billy: You don’t need to edit opmlRenderer-sidebar.xsl. In your sidebar.php file, put something like what I’ve got:

    <li><h2>Reading Lists</h2> <?php OPMLRender('{YOUR_URL}', '60', 'sidebar'); ?> </li>

    Note that the update time must be in seconds. Also, reading a remote url every minute could be considered abusive — consider bumping that up to 1 hour, or 3600 seconds.

  7. I thought that was just retrieving my OPML file one time, I didn’t realize it was going out to it during those timeperiods, THX. Also, I was reacting to reading this from the plugin install on my WP Admin panel:

    Renders valid OPML from any source as an expandable/collapsible list. Click here to edit XSL transform used for pages and posts and here to edit the XSL Transform used for the sidebar. Usage in code: OPMLRender(‘url’,’updatetime’,’page|sidebar’); Usage in pages / posts: !OPMLRender : url,updatetime,page|sidebar where ‘updatetime’ is the number of seconds to cache a file before requesting an update, and ‘page’ or ’sidebar’ indicates which XSL transform to use. By Dan MacTough.

    which is why I thought I needed to edit the .xsl file… so glad I went to the source! I see you already updated it since I got it yesterday so I’ll get a new copy now, thx.

  8. I see that you’re running WP 2.0 RC. I haven’t tested WP 2.0 yet, so I cannot say if there is a problem.

    Try dropping this script on your website and running it. Post the results.

  9. Current PHP Version: 4.3.11
    You have CURL installed.
    You have allow_url_fopen enabled.

    took a minute to realize I had to go to the directory on that one lol… guess Y! wasn’t lyin

  10. Well… I’m stumped. You shouldn’t be getting that error message if you have CURL installed (the message should be different). Try editing opmlRenderer.php by commenting out the line error_reporting(0);, which should be on line 40.

  11. this is what is in the sidebar right now:

    php OPMLRender(‘{http://www.opmlmanager.com/opml/BillyG.opml}’, ’60’, ‘sidebar’);

    with the opening/closing php brackets & inside the html list as shown above

  12. Oh. Sorry, Billy, I thought it would be understood that {YOUR_URL} was the bit to replace with your url, i.e., no braces.

  13. well that code does look better… and YES, IT LOOKS MUCH BETTER! Thank you Dan, U da Man!

    (I knew it was something my end lol)

  14. Hi Dan. Just wanted to let you know that I’ve been getting errors in the validator for the the first line of the Renderer script, text/Javascript if I remember correctly, you can see it thru the W3C validator. Of course, I’m getting errors thru the del.icio.us script also and their’s is still being displayed so I guess I’ll turn yours back on. I do remember that IE wasn’t displaying as FF was and that was why I turned off some scripts before. I’ll give it another go. thx again.

  15. Thanks, Billy. I’ll fix that soon. Looks like the script I was using to validate the XHTML was not using the correct URI.

  16. Current PHP Version: 4.4.1
    You have CURL installed.
    You have allow_url_fopen enabled.

    not working on my blog http://blog.franto.com

    after inserting your php script, rendering of HTML PAGE stops and dont continue, i’m using WP2.0

    It’s very nice plugin, and I like it

  17. Has anyone been able to make this work properly on a post (not a page or sidebar)? While I was finally able to make it function (who knew I had to take out the spaces in between the variables!) when I have a post with and opml file, it causes havoc with any theme I use. I am also having problems with IE displaying it properly (missing icons and the first half of the first character of each line chopped off). Any suggestions? If need be, I will put up a test post to show you. I’d rather not leave it up since it destroys the look of my site.

    Thanks,
    Bob

  18. Ok…looks like I was able to fix some of the problems myself. The only problem remaining is that IE seems to chop off the first .5 to 1.5 characters of each line. I even tried indenting the lines a little more to see if that helps. Firefox has no problems with it. Any ideas why this would happen?

    Thanks,
    Bob

    P.S. I’m leaving the test post up now, since it doesn’t mar my whole site.

    P.P.S. Thank you so much for making this tool. I have wanted to do something like this with for my podcast show notes for awhile now!

  19. Bob – Thanks for persevering. Sorry for the thing with the spaces. When I first posted, I was having trouble with the plugin trying to render the example text, and the spaces were my way of stopping it.

    Note that I just posted version 0.4. To the extent any of your issues were the result of poorly formatted HTML, this update may help.

    However, I think your IE issue may be a CSS issue in your template. I noticed you’ve got a 3-column layout with frames, too. FWIW, I have no troubles in IE with any of the templates I’ve got installed.

  20. Dan,

    The new version worked like a charm! Everything works as it should now. Thank you so much for your hard work. You have just cut tons of time from the post production of my podcast. Now I can create a show outline in Dave Winer’s OPML Editor and after I finish recording the show upload the file to my blog and not have to worry about retyping all the show notes! I’ll make sure to talk about this on my next episode as well as discuss this with my fellow members of the New Jersey Podcasters Association, since I know a few other members were looking to do something similar.

    Bob

  21. That’s great, Bob! I’m so relieved it could be cured so easily.

    And thanks for your kind words. I’m just glad that someone else finds this useful or interesting.

  22. error message appears such as “Horrific XSLT error – check logs”

    how do i do?

    anyway it’s a really good.

  23. she – Most of the time, that’s because of a failure to fetch the OPML or because the OPML is not valid. Try editing opmlRenderer.php and comment out the line error_reporting(0);, then rerun your problem page and post the error messages.

  24. she – But were there additional errors? Post a link to the page, and I’ll delete it from your comment once I’ve read it.

  25. hey. in my php is not installed curl. but can use allow_url_fopen via .htaccess.
    so i wrote the allow_url_fopen via .htaccess. but same error message reported.

  26. Hi Dan. Just came back for a visit and saw you doubled the size of your download, that immediately sounded like a good thing! I swear my list opens extremely fast now, and I thought it was great before…

    Two points though: I’m still getting the XHTML validation error as soon as it hits yuor script:

    —————————————————————————————————————-
    required attribute “type” not specified .

    The attribute given above is required for an element that you’ve used, but you have omitted it. For instance, in most HTML and XHTML document types the “type” attribute is required on the “script” element and the “alt” attribute is required for the “img” element.

    Typical values for type are type=”text/css” for and type=”text/javascript” for .
    —————————————————————————————————————-

    which is referencing this:

    ———————————
    # Reading Lists
    #
    #
    ———————————

    And tons from the fact that your img folder resides inside your opmlrender folder (even after ftp upload time) but the img tags in the script are pointing to /wp/wp-images/ as indicated here:

    —————————————————————————————————————-
    a name=”#” onClick=”jsid591740(‘oi-id594641’);” style=”text-decoration: none; border: none;”>Subscriptions
    —————————————————————————————————————-

    I guess I could copy those img’s over to the /wp/wp-images/ folder for now, just wanted to let you know… then again, with my history lately, maybe it’s something on my end lol. G/L and thanks again.

  27. look like it didn’t all come thru but the important part is the start:

    # h2 Reading Lists /h2
    # ul
    # script language equal “JavaScript” * edited out brackets and = so maybe it will stay *

    and reference:

    src=” wp wp-images imgCollapsed.gif” * edited out /’s *

    peace

  28. Billy, I think the problem is on your end. You’ve got a mixture of files from different releases. Please try getting the current download.

  29. Rendering of template stops at call of OPMLRender(...);
    with
    Fatal error: Call to undefined function: domxml_xslt_stylesheet() in /home/…/wp-content/plugins/opmlRenderer/opmlRenderer.php on line 136

    curl-fopen-test.php returns:
    Current PHP Version: 4.3.4
    You have CURL installed.
    You have allow_url_fopen enabled.
    You have DOM_XML support.

    I’m using WP 2.0

  30. Dan, I’m trying to instal the plugin, and after getting a “Horrific XSLT error” 🙂 I ran the script recommended in the comments, and I got this message:

    Current PHP Version: 4.4.2
    You have CURL installed.
    You have allow_url_fopen enabled.
    You DO NOT have XSLT support.

    Is there anything I can do about this? Thank you!

  31. Constantin, there really is nothing you can do other than ask your hosting company to install DOM_XML with libxslt.

    I had the experience with my hosting company when they upgraded to PHP 4.4.x from 4.3.x that none of the PHP extensions were installed! Turns out the RedHat-based distros (which most web hosts use) changed the PHP packages by moving almost all the extensions into separate packages as of PHP 4.4.x. So the upgrade is an effective downgrade (in terms of features) if the administrator isn’t paying careful attention.

    Just tell them you need it, pointing out that its capabilities are so integral that they are built into PHP 5 (no longer an extension).

    Good luck!

Comments are closed.