Sort order issue in expressionengine 1.x
February 11th, 2011 § Leave a Comment
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"}
content
{/exp:weblog:entries}
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
ExpressionEngine Addon to track visit for specific pages
June 15th, 2010 § 4 Comments
A few days back someone told me that he wants to track page visits of few selected for his ExpressionEngine site. To do that i built an extension and a module. You have to add the pages that is needed to track from module. I used sessions hooks to fire extension method that track/store visits info so later you can see the time to time visits info from module.
« Read the rest of this entry »
Sessions hook issue in ExpressionEngine Extension
June 14th, 2010 § 1 Comment
I was creating a custom extension of expressionengine 1.6.x version where i tried to use sessions_start and sessions_end hooks but i was facing problem with $SESS global var, it was not loaded to extension method. The method was something like -
function do_something(){
global $SESS;
print_r($SESS);
}
I wasted about 1/2 hours with this but no clue why this happened. Later i saw that, this hook is called with instantiated object(session) $this as parameter, so later i defined that function as -
function do_something($sess){
print_r($sess);
}
It solved and shows session data. Its very easy but sometime time wasting issue. Hope this will help EE community.
Email address verification/validation php class
June 1st, 2010 § 17 Comments
Let you want to validate an email address using php, address is abc@yahoo.com, if you use regular expression, it will pass validation properly but we know – this is not a real email address. So we need to check if an email address is exists or not – it can be done. I’ve created a php class that verify email address. Let me show you how to use this class – « Read the rest of this entry »