ExpressionEngine utility plugin to call php string processing function from template

The says it all. Sometime I need to process string from template using php functions, So I thought – it would be great if We’ve a plugin which will allow to call any php string processing functions from template. Thus I’ve created this simple plugin which does the job. I’m going to share this addon with you guys if you need it too. For example, you can call any available php function using following tag

{exp:util:func function="strip_tags" params="'<p><a>'"}<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>{/exp:util:func}

You can even pass argument, if argument is a string, wrap this with a single/double quote, if argument is a constant, dont wrap with quote. Provide multiple params with pipe separator.

Here are the codes – https://github.com/appskitchen/util


Sort order issue in expressionengine 1.x

You might noticed the issue for sorting stuff in expressionengine cms to show entries if you’ve worked with this, that is if you’ve a custom field which stores number value and later you want sort the entries by that field – the entries sorted in wrong order! If you didn’t noticed that yet, explaining…

Let you have a custom field named “display_order”. This field stores integer value. Later you’ve tag like bellow to show entries in specific display order by this field –

{exp:weblog:entries  channel="channel_name"  orderby="display_order" sort="asc"  limit="15"}

Above code pulls data in wrong order. Because Expressionengine creates varchar type field in table for every custom field. So if an entry has value 2 for display_order and 10, the entry with value 10 will comes first as mysql query treats them as string.

For this, you can do a quick trick. First find which field is created for the custom field you created, as per above example find out the field created for custom field “display_order”. Lets say table field for this custom field is field_id_20. Alter this field as integer type. So prepare a query like below and execute –

ALTER TABLE exp_weblog_data CHANGE `field_id_20` `field_id_20` INT(11) DEFAULT NULL

So, now see – issue is fixed ;)