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”

Continue reading

āĻ¸āĻŽā§āĻ­āĻžāĻŦāĻ¨āĻžāĻŽāĻ¯āĻŧ āĻ¨āĻ¤ā§āĻ¨ āĻ¤āĻŋāĻ¨āĻŸāĻŋ āĻ¸ā§‹āĻ¸ā§āĻ¯āĻžāĻ˛ āĻ¨ā§‡āĻŸāĻ“āĻ¯āĻŧāĻžāĻ°ā§āĻ•

āĻĢā§‡āĻ¸āĻŦā§āĻ• āĻ•āĻŋāĻ‚āĻŦāĻž āĻŸā§āĻ‡āĻŸāĻžāĻ° āĻĻā§€āĻ°ā§āĻ˜āĻĻāĻŋāĻ¨ āĻ§āĻ°ā§‡ āĻ°āĻžāĻœāĻ¤ā§āĻŦ āĻ•āĻ°ā§‡ āĻ¯āĻžāĻšā§āĻ›ā§‡ āĻ†āĻ° āĻ¸ā§‡āĻ‡ āĻ¸āĻžāĻĨā§‡ āĻ—ā§āĻ—āĻ˛ āĻĒā§āĻ˛āĻžāĻ¸ āĻāĻ¸ā§‡ āĻ¨āĻŋāĻœā§‡āĻ° āĻŦā§āĻ¯āĻ°ā§āĻĨ āĻ…āĻŦāĻ¸ā§āĻĨāĻžāĻ¨ āĻ¤ā§ˆāĻ°āĻŋāĻ° āĻšā§‡āĻ¸ā§āĻŸāĻž āĻ•āĻ°ā§‡ āĻ¯āĻžāĻšā§āĻ›ā§‡āĨ¤ āĻāĻ¤ā§‹āĻĻāĻŋāĻ¨ āĻ†āĻŽāĻ°āĻž āĻāĻ•āĻŸāĻž āĻ¸ā§‹āĻ¸ā§āĻ¯āĻžāĻ˛ āĻ¨ā§‡āĻŸāĻ“āĻ¯āĻŧāĻžāĻ°ā§āĻ•ā§‡āĻ‡ āĻ•ā§āĻˇā§āĻĻā§āĻ°/āĻŦāĻĄāĻŧ āĻŦāĻžāĻ°ā§āĻ¤āĻž āĻļā§‡āĻ¯āĻŧāĻžāĻ°(āĻ¸ā§āĻŸā§āĻ¯āĻžāĻŸāĻžāĻ¸ āĻ†āĻĒāĻĄā§‡āĻŸ), āĻ›āĻŦāĻŋ āĻļā§‡āĻ¯āĻŧāĻžāĻ°, āĻ­āĻŋāĻĄāĻŋāĻ“ āĻļā§‡āĻ¯āĻŧāĻžāĻ° āĻ‡āĻ¤ā§āĻ¯āĻžāĻĻāĻŋ āĻ•āĻ°āĻ¤āĻžāĻŽ… āĻ¯ā§‡āĻŽāĻ¨ āĻĢā§‡āĻ¸āĻŦā§āĻ•ā§‡ āĻāĻ•āĻ‡ āĻ¸āĻžāĻĨā§‡ āĻ¸ā§āĻŸā§āĻ¯āĻžāĻŸāĻžāĻ¸ āĻ†āĻĒāĻĄā§‡āĻŸ, āĻ›āĻŦāĻŋ, āĻ“āĻĄāĻŋāĻ“, āĻ­āĻŋāĻĄāĻŋāĻ“, āĻ¨ā§‹āĻŸ āĻ˛ā§‡āĻ–āĻž, āĻ—ā§‡āĻŽ āĻ–ā§‡āĻ˛āĻžāĻ¸āĻš āĻ…āĻ¨ā§‡āĻ•āĻ•āĻŋāĻ›ā§ āĻ•āĻ°āĻž āĻ¯āĻžāĻšā§āĻ›ā§‡āĨ¤ āĻ•āĻŋāĻ¨ā§āĻ¤ā§ āĻ†āĻŽāĻžāĻ° āĻŽāĻ¨ā§‡ āĻšāĻšā§āĻ›ā§‡ āĻ†āĻ—āĻžāĻŽā§€āĻ¤ā§‡ āĻāĻ‡ āĻ§āĻžāĻ°āĻž āĻ…āĻšāĻŋāĻ°ā§‡āĻ‡ āĻāĻ˛ā§‹āĻŽā§‡āĻ˛ā§‹ āĻšāĻ¯āĻŧā§‡ āĻ¯āĻžāĻŦā§‡… āĻļā§āĻ°ā§ āĻšāĻŦā§‡ āĻ›āĻŦāĻŋ āĻļā§‡āĻ¯āĻŧāĻžāĻ° āĻ¨ā§‡āĻŸāĻ“āĻ¯āĻŧāĻžāĻ°ā§āĻ•, āĻ­āĻŋāĻĄāĻŋāĻ“ āĻļā§‡āĻ¯āĻŧāĻžāĻ°āĻŋāĻ‚ āĻ¨ā§‡āĻŸāĻ“āĻ¯āĻŧāĻžāĻ°ā§āĻ• … āĻāĻ•āĻŸāĻž āĻŦā§āĻ¯āĻžāĻĒāĻžāĻ° āĻšāĻšā§āĻ›ā§‡ āĻāĻ‡ āĻ§āĻ°āĻ¨ā§‡āĻ° āĻ¸āĻžāĻ‡āĻŸ āĻ•āĻŋāĻ¨ā§āĻ¤ā§ āĻ†āĻ›ā§‡ āĻ¯ā§‡āĻŽāĻ¨ āĻĢā§āĻ˛āĻŋāĻ•āĻžāĻ° āĻ•āĻŋāĻ‚āĻŦāĻž āĻ‡āĻ‰āĻŸāĻŋāĻ‰āĻŦ āĻ¤āĻŦā§‡ āĻāĻ–āĻžāĻ¨ā§‡ āĻ¯āĻ¤āĻ¨āĻž āĻŦā§‡āĻļāĻŋ āĻļā§‡āĻ¯āĻŧāĻžāĻ° āĻšāĻ¯āĻŧ āĻ¤āĻžāĻ° āĻĨā§‡āĻ•ā§‡ āĻ¨ā§‡āĻŸāĻ“āĻ¯āĻŧāĻžāĻ°ā§āĻ•āĻŋāĻ‚ āĻŦāĻž āĻĢāĻ˛ā§‹āĻ¯āĻŧāĻŋāĻ‚-āĻĢāĻ˛ā§‹āĻ¯āĻŧāĻžāĻ° āĻ¸āĻŽā§āĻĒāĻ°ā§āĻ• āĻāĻ° āĻŸāĻžāĻ¨āĻžāĻĒā§‹āĻĄāĻŧā§‡āĻ¨ āĻ¨āĻŋāĻ¤āĻžāĻ¨ā§āĻ¤āĻ‡ āĻ•āĻŽāĻ‡ āĻšāĻ¯āĻŧāĨ¤ āĻ†āĻ° āĻ¤āĻžāĻ‡ āĻ–ā§āĻŦ āĻ•āĻŽ āĻ¸āĻŽāĻ¯āĻŧā§‡ āĻ¤āĻŋāĻ¨āĻŸāĻŋ āĻ¸ā§‹āĻ¸ā§āĻ¯āĻžāĻ˛ āĻ¨ā§‡āĻŸāĻ“āĻ¯āĻŧāĻžāĻ°ā§āĻ• āĻ¨āĻ¤ā§āĻ¨ āĻ•āĻ°ā§‡ āĻœāĻžāĻ¯āĻŧāĻ—āĻž āĻ•āĻ°ā§‡ āĻ¨āĻŋāĻšā§āĻ›ā§‡ āĻ¯āĻžāĻ°āĻž āĻ¯āĻĨāĻžāĻ•ā§āĻ°āĻŽā§‡ āĻ›āĻŦāĻŋ, āĻ­āĻŋāĻĄāĻŋāĻ“ āĻāĻŦāĻ‚ āĻ“āĻĄāĻŋāĻ“ āĻļā§‡āĻ¯āĻŧāĻžāĻ°āĻŋāĻ‚ āĻ¸ā§‹āĻ¸ā§āĻ¯āĻžāĻ˛ āĻ¨ā§‡āĻŸāĻ“āĻ¯āĻŧāĻžāĻ°ā§āĻ• …

āĻĒāĻŋāĻ¨ā§āĻŸāĻžāĻ°ā§‡āĻ¸ā§āĻŸ(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.

See how a long url go outside of a div box

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

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