Posts Tagged ‘PHP’

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.

PHP PDO & Apache mod_rewrite configuration…

Friday, March 13th, 2009

This is just a small post since it only concerns a few stupid thing I did.

For a while I had been trying to get PDO (it is an extension that provides some nice functionalites to connect to databases) to work with mysql. In the php documentation they inform that you need the php_pdo_mysql.dll library to be available and loaded. I went in the library folder and found a php_mysql.dll file… Thinking that maybe since the time the documentation had been written, the file had been renamed and i vainly tried to get PDO working… lost like an hour or so… Well the thing is you really have 2 mysql files, one that is used by PDO and one that is used by the standard mysql commands!

As for the apache story, to enable the pretty prints for the urls on this blog I had to configure mod_rewrite. Not being an expert or anything a while back I had setup some virtual hosts and some directories. So to allow mod_rewrite, i go in my virtual host and modify it accordingly… forgetting that I had a directory section in the file that was superseeding the directives I was giving in the virtual host directory section… So when you try to install mod_rewrite on Apache and you are running virtual hosts, don’t forget to also check your directory directives!

And since I tend to forget this kind of things since I am not an everyday user it is blogged!