Skip to main content

Posts

Showing posts from February, 2012

Joomla ARTIO SEF set default Itemid for new posts

A small hack to set the default Itemid for new posts added into the admin panel can be done at 2 places in the file:  components/com_sef/joomsef.php Line: 1462                     if (isset($Itemid) && ($Itemid != '')) {                         $col = ', `Itemid`';                         $val = ", '171'";                      // Itemid of the menu item, which is included for almost all modules in our site                     } Line: 1567     if (isset($Itemid) && ($Itemid != '')) {                                 $col = ', `Itemid`';                                 $val = ", '171'";                             } Whenever a new article is added in the admin panel, and its link is visited in the front end, a record is inserted into the jos_sefurls table, with the Itemid column value as 1. This can be hacked with the above code modification, to include a custom Itemid for the new url, s

Joomla jquery conflicts

Sometimes, we face certain jquery conflicts in Joomla. These can be avoided by using jQuery instead of $ in your code. For example, instead of: $(function() {         $( "#tabs" ).tabs();     }); Use this: jQuery(function() {         jQuery( "#tabs" ).tabs();     }); And in your template index (or head includes script file), add a js file (noconflict.js) with just this content: jQuery.noConflict(); For example: $this->addScript($this->baseurl."/templates/".$this->template."/js/jquery-1.7.1.js"); $this->addScript($this->baseurl."/templates/".$this->template."/js/noconflict.js");

Joomla redirection

Example of URL Redirection in joomla: Suppose the user visits our component view page without logging in. Then we want to force the user to login page (if he is not already logged in) and then redirect back to our page after logging in, and show a custom logout button. This is a sample code in our component view: <?php $user =& JFactory::getUser(); global $mainframe; if($user->id == 0) { $return_url = 'index.php?option=com_comments'; $return_url = urlencode(base64_encode($return_url)); $redirect_url = '&return='.$return_url; $login_url = 'index.php?option=com_user&view=login'; $finalUrl = $login_url . $redirect_url; $mainframe->redirect( $finalUrl, 'Please login or register before you post comment' ); } else {  ?> <table width="800"> <tr><td><?php echo 'Welcome <b>'.$user->name; ?></b></td> <td align="right"> <form id="l