Just back from the event Joomla user group bangladesh meetup 2012
[slideshare id=14713241&doc=developingjoomlaextensions-jugbangladeshmeetupdhaka-2012-121013111415-phpapp01]
Tips and Tricks
There are 65 posts filed in Tips and Tricks (this is page 3 of 7).
Fixing ‘DS’ error in joomla 3.0 alpha
I was checking the Joomla! 3.0.0_Alpha1 version and got an error after installing one of extension that shows Directory separator constant DS error. So if you get such error for any of your extension try this code
if(!defined('DS')){ define('DS',DIRECTORY_SEPARATOR); }
May be making a system plugin can solve this problem. I developed one đ
[download id=”35″]
BTW, we develop custom joomla extension at codeboxr.com
Quick tips to work with joomla caching in different joomla versions
Here just some quick tips about how to use joomla caching in joomla extensions , here for module and component.
For joomla 1.5 module caching:
[code language=”php”]
//$params, $module are global parameter here , can be used in default.php or have to pass in helper method.
$enable_cache = $params->get(‘cache’,0);
$cachetime = $params->get(‘cache_time’,0);
//for 1.5
if($enable_cache == 1) {
$conf =& JFactory::getConfig();
$cache = &JFactory::getCache($module->module);
$cache->setLifeTime( $params->get( ‘cache_time’, $conf->getValue( ‘config.cachetime’ ) * 60 ) );
$cache->setCaching(true);
$cache->setCacheValidation(true);
$output = $cache->get( array(‘modClassname’, ‘getMethod’), array($params, $module));
} else {
$output = modClassname::getMethod($params,$module);
}
[/code]
For joomla 1.6 we do the same thing in following way
[code language=”php”]
$cacheparams = new stdClass;
$cacheparams->cachemode = ‘safeuri’;
$cacheparams->class = ‘modClassname’;
$cacheparams->method = ‘getMethod’;
$cacheparams->methodparams = array($params,$module);
$cacheparams->modeparams = array(‘id’=>’int’,’Itemid’=>’int’);
$output = JModuleHelper::moduleCache ($module, $params, $cacheparams);
[/code]
For joomla 1.5 and 1.6 compatibility we can code like this which will work for both joomla version
[code language=”php”]
$enable_cache = $params->get(‘cache’,0);
$cachetime = $params->get(‘cache_time’,0);
if(version_compare(JVERSION,’1.6.0′,’ge’)) {
$cacheparams = new stdClass;
$cacheparams->cachemode = ‘safeuri’;
$cacheparams->class = ‘modClassname’;
$cacheparams->method = ‘getMethod’;
$cacheparams->methodparams = array($params,$module);
$cacheparams->modeparams = array(‘id’=>’int’,’Itemid’=>’int’);
$output = JModuleHelper::moduleCache ($module, $params, $cacheparams);
}
else{
//for 1.5
if($enable_cache == 1) {
$conf =& JFactory::getConfig();
$cache = &JFactory::getCache($module->module);
$cache->setLifeTime( $params->get( ‘cache_time’, $conf->getValue( ‘config.cachetime’ ) * 60 ) );
$cache->setCaching(true);
$cache->setCacheValidation(true);
$output = $cache->get( array(‘modClassname’, ‘getMethod’), array($params, $module));
} else {
$output = modClassname::getMethod($params,$module);
}
}
[/code]
Note: here I assumed the modClassname is the class name of the helper and modMethod is the method used to handle the caching part. In next post I will write something about the component caching and in 3rd one post about how to caching when we are not doing any function call or how about handle caching in plugin. Let me have time for the next post.
āĻāĻĒāĻžāĻ˛ ! āĻ˛ā§āĻāĻāĻ¨ āĻā§āĻŽāĻ¨ā§ āĻŦā§āĻāĻ˛ āĻāĻŽāĻŋ āĻŦāĻĄāĻŧ āĻŽāĻ¨āĻŋāĻĻā§āĻ° āĻāĻŋāĻĄāĻŋāĻ āĻĻā§āĻāĻāĻŋ āĻ āĻŽā§āĻ āĻ¸āĻžāĻāĻā§ !!
“āĻāĻĒāĻžāĻ˛ ! āĻ˛ā§āĻāĻāĻ¨ āĻā§āĻŽāĻ¨ā§ āĻŦā§āĻāĻ˛ āĻāĻŽāĻŋ āĻŦāĻĄāĻŧ āĻŽāĻ¨āĻŋāĻĻā§āĻ° āĻāĻŋāĻĄāĻŋāĻ āĻĻā§āĻāĻāĻŋ āĻ āĻŽā§āĻ āĻ¸āĻžāĻāĻā§ !!” Â āĻāĻ āĻ°āĻāĻŽ āĻ āĻ¨ā§āĻā§āĻ¤āĻŋ āĻ¯ā§ āĻāĻžāĻ°ā§ āĻšāĻ¤ā§ āĻĒāĻžāĻ°ā§āĨ¤ āĻ¤āĻŦā§ āĻā§āĻ¨ Â āĻāĻŦāĻ āĻāĻŋāĻāĻžāĻŦā§ āĻ āĻ¨ā§āĻ¯ āĻā§āĻ āĻŦā§āĻā§ āĻĢā§āĻ˛āĻā§ āĻĨāĻ˛ā§āĻ° āĻŦāĻŋāĻĄāĻŧāĻžāĻ˛ đ āĻāĻŽāĻ¨ āĻĒā§āĻ°āĻļā§āĻ¨ āĻŽāĻ¨ā§ āĻāĻ¸āĻ¤ā§āĻ āĻĒāĻžāĻ°ā§āĨ¤
āĻ¯āĻžāĻ āĻšā§āĻ āĻāĻ¤āĻā§āĻˇāĻ¨ āĻŽāĻāĻž āĻāĻ°āĻāĻŋāĻ˛āĻžāĻŽāĨ¤ āĻ¤āĻŦā§ āĻāĻāĻ¨āĻž āĻšāĻā§āĻā§ āĻ āĻ¨ā§āĻā§āĻ āĻ āĻ¨ā§āĻ āĻ¸āĻžāĻāĻā§ āĻāĻāĻāĻž āĻ¨āĻŋāĻāĻ āĻĒāĻĄāĻŧāĻā§ āĻŦāĻž āĻāĻŋāĻĄāĻŋāĻ āĻĻā§āĻāĻā§ āĻŦāĻž āĻŦā§āĻ˛āĻ āĻĒāĻĄāĻŧāĻā§ āĻ¤āĻž āĻāĻŦāĻžāĻ° āĻ āĻ¨ā§āĻ¯ āĻĢā§āĻ¸āĻŦā§āĻ āĻŦāĻ¨ā§āĻ§ā§āĻ°āĻž āĻā§āĻ¨ā§ āĻ¯āĻžāĻā§āĻā§āĨ¤ āĻ¯ā§āĻŽāĻ¨ āĻāĻāĻāĻž āĻāĻĻāĻžāĻšāĻ°āĻŖ āĻĻā§āĻāĻ¯āĻŧāĻž āĻ¯āĻžāĻāĨ¤ āĻšāĻ āĻžā§ āĻāĻĒāĻ¨āĻžāĻ° āĻĢā§āĻ¸āĻŦā§āĻā§āĻ° āĻšā§āĻŽ āĻĒāĻžāĻ¤āĻžāĻ¯āĻŧ āĻĻā§āĻāĻ˛ā§āĻ¨ āĻāĻāĻāĻž āĻĒā§āĻ¸ā§āĻ
“Mr. X watched a video on Dailymotion”
āĻ¸āĻŽā§āĻāĻžāĻŦāĻ¨āĻžāĻŽāĻ¯āĻŧ āĻ¨āĻ¤ā§āĻ¨ āĻ¤āĻŋāĻ¨āĻāĻŋ āĻ¸ā§āĻ¸ā§āĻ¯āĻžāĻ˛ āĻ¨ā§āĻāĻāĻ¯āĻŧāĻžāĻ°ā§āĻ
āĻĢā§āĻ¸āĻŦā§āĻ āĻāĻŋāĻāĻŦāĻž āĻā§āĻāĻāĻžāĻ° āĻĻā§āĻ°ā§āĻāĻĻāĻŋāĻ¨ āĻ§āĻ°ā§ āĻ°āĻžāĻāĻ¤ā§āĻŦ āĻāĻ°ā§ āĻ¯āĻžāĻā§āĻā§ āĻāĻ° āĻ¸ā§āĻ āĻ¸āĻžāĻĨā§ āĻā§āĻāĻ˛ āĻĒā§āĻ˛āĻžāĻ¸ āĻāĻ¸ā§ āĻ¨āĻŋāĻā§āĻ° āĻŦā§āĻ¯āĻ°ā§āĻĨ āĻ āĻŦāĻ¸ā§āĻĨāĻžāĻ¨ āĻ¤ā§āĻ°āĻŋāĻ° āĻā§āĻ¸ā§āĻāĻž āĻāĻ°ā§ āĻ¯āĻžāĻā§āĻā§āĨ¤ āĻāĻ¤ā§āĻĻāĻŋāĻ¨ āĻāĻŽāĻ°āĻž āĻāĻāĻāĻž āĻ¸ā§āĻ¸ā§āĻ¯āĻžāĻ˛ āĻ¨ā§āĻāĻāĻ¯āĻŧāĻžāĻ°ā§āĻā§āĻ āĻā§āĻˇā§āĻĻā§āĻ°/āĻŦāĻĄāĻŧ āĻŦāĻžāĻ°ā§āĻ¤āĻž āĻļā§āĻ¯āĻŧāĻžāĻ°(āĻ¸ā§āĻā§āĻ¯āĻžāĻāĻžāĻ¸ āĻāĻĒāĻĄā§āĻ), āĻāĻŦāĻŋ āĻļā§āĻ¯āĻŧāĻžāĻ°, āĻāĻŋāĻĄāĻŋāĻ āĻļā§āĻ¯āĻŧāĻžāĻ° āĻāĻ¤ā§āĻ¯āĻžāĻĻāĻŋ āĻāĻ°āĻ¤āĻžāĻŽ… āĻ¯ā§āĻŽāĻ¨ āĻĢā§āĻ¸āĻŦā§āĻā§ āĻāĻāĻ āĻ¸āĻžāĻĨā§ āĻ¸ā§āĻā§āĻ¯āĻžāĻāĻžāĻ¸ āĻāĻĒāĻĄā§āĻ, āĻāĻŦāĻŋ, āĻāĻĄāĻŋāĻ, āĻāĻŋāĻĄāĻŋāĻ, āĻ¨ā§āĻ āĻ˛ā§āĻāĻž, āĻā§āĻŽ āĻā§āĻ˛āĻžāĻ¸āĻš āĻ āĻ¨ā§āĻāĻāĻŋāĻā§ āĻāĻ°āĻž āĻ¯āĻžāĻā§āĻā§āĨ¤ āĻāĻŋāĻ¨ā§āĻ¤ā§ āĻāĻŽāĻžāĻ° āĻŽāĻ¨ā§ āĻšāĻā§āĻā§ āĻāĻāĻžāĻŽā§āĻ¤ā§ āĻāĻ āĻ§āĻžāĻ°āĻž āĻ āĻāĻŋāĻ°ā§āĻ āĻāĻ˛ā§āĻŽā§āĻ˛ā§ āĻšāĻ¯āĻŧā§ āĻ¯āĻžāĻŦā§… āĻļā§āĻ°ā§ āĻšāĻŦā§ āĻāĻŦāĻŋ āĻļā§āĻ¯āĻŧāĻžāĻ° āĻ¨ā§āĻāĻāĻ¯āĻŧāĻžāĻ°ā§āĻ, āĻāĻŋāĻĄāĻŋāĻ āĻļā§āĻ¯āĻŧāĻžāĻ°āĻŋāĻ āĻ¨ā§āĻāĻāĻ¯āĻŧāĻžāĻ°ā§āĻ … āĻāĻāĻāĻž āĻŦā§āĻ¯āĻžāĻĒāĻžāĻ° āĻšāĻā§āĻā§ āĻāĻ āĻ§āĻ°āĻ¨ā§āĻ° āĻ¸āĻžāĻāĻ āĻāĻŋāĻ¨ā§āĻ¤ā§ āĻāĻā§ āĻ¯ā§āĻŽāĻ¨ āĻĢā§āĻ˛āĻŋāĻāĻžāĻ° āĻāĻŋāĻāĻŦāĻž āĻāĻāĻāĻŋāĻāĻŦ āĻ¤āĻŦā§ āĻāĻāĻžāĻ¨ā§ āĻ¯āĻ¤āĻ¨āĻž āĻŦā§āĻļāĻŋ āĻļā§āĻ¯āĻŧāĻžāĻ° āĻšāĻ¯āĻŧ āĻ¤āĻžāĻ° āĻĨā§āĻā§ āĻ¨ā§āĻāĻāĻ¯āĻŧāĻžāĻ°ā§āĻāĻŋāĻ āĻŦāĻž āĻĢāĻ˛ā§āĻ¯āĻŧāĻŋāĻ-āĻĢāĻ˛ā§āĻ¯āĻŧāĻžāĻ° āĻ¸āĻŽā§āĻĒāĻ°ā§āĻ āĻāĻ° āĻāĻžāĻ¨āĻžāĻĒā§āĻĄāĻŧā§āĻ¨ āĻ¨āĻŋāĻ¤āĻžāĻ¨ā§āĻ¤āĻ āĻāĻŽāĻ āĻšāĻ¯āĻŧāĨ¤ āĻāĻ° āĻ¤āĻžāĻ āĻā§āĻŦ āĻāĻŽ āĻ¸āĻŽāĻ¯āĻŧā§ āĻ¤āĻŋāĻ¨āĻāĻŋ āĻ¸ā§āĻ¸ā§āĻ¯āĻžāĻ˛ āĻ¨ā§āĻāĻāĻ¯āĻŧāĻžāĻ°ā§āĻ āĻ¨āĻ¤ā§āĻ¨ āĻāĻ°ā§ āĻāĻžāĻ¯āĻŧāĻāĻž āĻāĻ°ā§ āĻ¨āĻŋāĻā§āĻā§ āĻ¯āĻžāĻ°āĻž āĻ¯āĻĨāĻžāĻā§āĻ°āĻŽā§ āĻāĻŦāĻŋ, āĻāĻŋāĻĄāĻŋāĻ āĻāĻŦāĻ āĻāĻĄāĻŋāĻ āĻļā§āĻ¯āĻŧāĻžāĻ°āĻŋāĻ āĻ¸ā§āĻ¸ā§āĻ¯āĻžāĻ˛ āĻ¨ā§āĻāĻāĻ¯āĻŧāĻžāĻ°ā§āĻ …
āĻĒāĻŋāĻ¨ā§āĻāĻžāĻ°ā§āĻ¸ā§āĻ(http://pinterest.com/)
āĻāĻŋāĻ˛(http://chill.com)
āĻĻāĻŋāĻāĻāĻāĻŽāĻžāĻāĻā§āĻ¯āĻžāĻŽ(http://www.thisismyjam.com/)
Break long url or word using css to prevent overflow of div container
First of all I am not design expert, not a designer but I learnt many thing about design I mean css, html while working with website projects. Something gave me pain when I found a long url is getting outside of a box(div) in google chrome. After a google search I found a solution… need to use word break though it doesn’t support all browser.
I found a solution
[code language=”css”]
.box{
white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;
}
[/code]
thanks
Detect User type in joomla 1.6 or later
In Joomla1.5.x we can detect user type easily or check if a user is admin type.
[code language=”php”]
$isadmin = false;
$user =&JFactory::getUser();
if($user->usertype == "Super Administrator" || $user->usertype == "Administrator"){
$isadmin = true;
}
[/code]
But from joomla 1.6 as the user group architecture is changed the above way will not work.
From j1.6 we can do this in this way, here actually I was trying to detect if the user is super user or not like admin user in j1.5
[code language=”php”]
$isadmin = false;
$user =&JFactory::getUser();
$db = JFactory::getDbo();
//var_dump($user->getAuthorisedGroups());
$userid = intval($user->get( ‘id’ ));
if($userid > 0){
$query = $db->getQuery(true);
$query->select(‘g.title AS group_name’)
->from(‘#__usergroups AS g’)
->leftJoin(‘#__user_usergroup_map AS map ON map.group_id = g.id’)
->where(‘map.user_id = ‘.(int) $userid);
$db->setQuery($query);
$ugp = $db->loadObject();
$usertype = $ugp->group_name;
if(is_string($usertype)) $usertype = array($usertype);
if(in_array(‘Super Users’, $usertype)){
$isadmin = true;
}
//var_dump($usertype);
}
[/code]
thanks
My trouble story about ‘onContentPrepare’ hook for joomla
1. I was developing a content plugin for joomla, currently I was working with joomla1.6 or earlier.
2. My target was skip some specific or used defined category for the plugin execution as this is very useful feature.
3. It works in article details page but doesn’t work in other view of com_content component. Why
4. Here is the function that get’s hooked in content plugin for onContentPrepare
Continue reading
Showing custom taxonomy filter in custom post types in wordpress admin post listing
Please note that “this post is for them who knows custom post types and custom taxonomy in wordpress”
Isn’t the title enough to get what my article about ?
Let me paste the code what I did: I think I collected the basic code from somewhere and then edited as I need.
Continue reading
Virtuemart2.0 content plugin support/fix for joomla1.6+
I see virtuemart2 is compatible with joomla 1.6 , hope for 1.7 too. I see there is a issue for content plugin compatibility for vm2 in joomla1.6. Then checked the vm2 code where the plugin event if fired. I see the plugin trigger method is not compatible with 1.6 content plugin structure, the hook name is for old joomla 1.5 series
note: paths are windows style
folder components\com_virtuemart\views\productdetails open file view.html.php line 97
Continue reading