Posts Tagged ‘WordPress’

WordPress Xslt Processor plugin – follow up

Saturday, April 18th, 2009

So, a user of the plugin asked me on how to make the plugin also have parameters for the xsl file. And I ended up coding it because it seemed simpler that way.

This this post servers as much as a test bed as a presentation of the different kind of options one can use:

So lets start with the most basic way to use this plugin:

Use:

[XmlProcessor wp-content/plugins/CPT_XslProcessor/example]

Result

[XmlProcessor wp-content/plugins/CPT_XslProcessor/example]

or:

[XmlProcessor xml=”wp-content/plugins/CPT_XslProcessor/example.xml” xslt=”wp-content/plugins/CPT_XslProcessor/example.xsl”]

Result:

[XmlProcessor xml="wp-content/plugins/CPT_XslProcessor/example.xml" xslt="wp-content/plugins/CPT_XslProcessor/example.xsl"]

Now, lets say you want to add options to the xsl file:

Use:

[XmlProcessor wp-content/plugins/CPT_XslProcessor/example params=”default_param=this is the replaced default parameter”]

Result:

[XmlProcessor wp-content/plugins/CPT_XslProcessor/example params="default_param=this is the replaced default parameter"]

or:

[XmlProcessor xml=”xml_filepath” xslt=”xslt_filepath” params=”default_param=this is the replaced default parameter”]

Result:

[XmlProcessor xml="wp-content/plugins/CPT_XslProcessor/example.xml" xslt="wp-content/plugins/CPT_XslProcessor/example.xsl" params="default_param=this is the replaced default parameter"]

And that should actually be working now :)

WordPress Xslt Processor plugin development

Sunday, April 5th, 2009

Need

If any of you actually read my about me page, you know that this blog ended up being more than foreseen. Thus I required to have more liberty in some of the things i wanted to do.

Typically you may have a resume in a pdf or document format. How do I include such a document inside the theme of WordPress ? How do I include content from a webservice / an xml document in WordPress?

To answer part of this need, I made a request on the wordpress forum to no avail and I ended up coding it. Fortunately the WordPress API is very well made though the documentation is a bit lacking in some places. In WordPress you can have:

First I tried using filters but due to the encoding and escaping done by wordpress my regular expressions would not work. I loaded my prefered IRC client and connected to the #wordpress channel on freenode. Lots of help and advice there and information too. Taking their advice into account I used Shortcode which actually remove all the requirements for parsing the code yourself. WordPress provides the Shortcode API for that.

What about the Plugin ?

The plugin that I am now using takes an XML and XSLT files, process it and output to the window. For an example of how to use it see my “resume” pages.

If you want to use this plugin, you can find the latest version on WordPress: XslProcessor

(At the time of this note, the code is not yet uploaded. Approval from WordPress has not yet been received)

Hope you find it as usefull as I do.