How to remove mootools.js and caption.js from Joomla1.5

linux
Written by Joe   
Thursday, 19 June 2008 02:34

For most Joomla 1.5 template, they don't use mootools.js and caption.js at all. These two javasript libiaries are mainly used in the adiminstrator control panal. Their size are about 75K, and decrease the response speed of Joomla site. Here I introduce a method to remove the two javascript libs.

To make sure your Joomla site have the two scripts in the front site, you can look you site's html source code and will find the following code:

  <script type="text/javascript" src="/media/system/js/mootools.js"></script>
  <script type="text/javascript" src="/media/system/js/caption.js"></script>

To remove the above javascript's import, you just need to add the following code at the top of your template's index.php file.

		<?php 
		//remove mootools.js and caption.js
		$headerstuff=$this->getHeadData();
		reset($headerstuff['scripts']);
		foreach($headerstuff['scripts'] as $key=>$value){
		  unset($headerstuff['scripts'][$key]);
		}		
		$this->setHeadData($headerstuff);
		?>
   

Clear cache and go back to you front site's source code, you will find the mootools.js and caption.js gone.

 
linux
Get active menu linked Content's section Id and category Id in Joomla1.5.x
Written by Joe   
Wednesday, 18 June 2008 09:34

In joomla1.5.X, If the active menu links to com_content, we can use the following code to get the active menu linked content's section id and category Id.

	 $menus = &JSite::getMenu();

	 $currentMenu  = $menus->getActive();   
    $menuOption=$currentMenu->query['option'];

	if($menuOption=='com_content'){
	   $menuView=$currentMenu->query['view'];
	   if($menuView=='section'){
	     $secid=$currentMenu->query['id'];	    
	   }elseif($menuView=='category'){
	     $catid=$currentMenu->query['id'];	        
	   }else if($menuView=='article'){
	   	$articleId=$currentMenu->query['id']; 
			$sql = "SELECT c.sectionid,c.catid"
				. "\n FROM #__content AS c"
				. "\n WHERE c.id = ".$articleId;
			$database->setQuery( $sql );
			$sectionCat = $database->loadObjectList();
			if(count($sectionCat)){
			  $secid=$sectionCat[0]->sectionid;
			  $catid=$sectionCat[0]->catid;
			}
	   }
	}

The following Joomla1.5.x categoryOrSection series extensions are all using the above code. Joomla categoryOrSection series extensions

 
Get active menu linked Content's section Id and category Id in Joomla1.0.x
Written by Joe   
Wednesday, 18 June 2008 09:25

In joomla1.0.x, If the active menu links to com_content, we can use the following code to get the active menu linked content's section id and category Id.

global  $Itemid;
$activeMenuItemId=$Itemid;
$params=array();
$sql = "SELECT m.*"
	. "\n FROM #__menu AS m"
	. "\n WHERE id = ".$activeMenuItemId
	. "\n AND published = 1";
$database->setQuery( $sql );
$menuRows = $database->loadObjectList();
if(count($menuRows)){
	$linkParts=explode('?',$menuRows[0]->link);	   
	$parts=explode('&',$linkParts[1]);	       
	foreach($parts as $p){
	    $nv=explode('=',$p);    
	    $params[$nv[0]] = $nv[1];
	}  

$isContentMenu=0;	
if($params['option']=='com_content'){
   $isContentMenu=1;
	if($params['task']=='section'){//section
	    $secid=$params['id'];
	    unset($catid);
	}else if($params['task']=='category'){//category
	   $secid=$params['sectionid']; 
	   $catid=$params['id']; 
	}else{//article
		$articleId=$params['id']; 
		$sql = "SELECT c.sectionid,c.catid"
			. "\n FROM #__content AS c"
			. "\n WHERE c.id = ".$articleId;
		$database->setQuery( $sql );
		$sectionCat = $database->loadObjectList();
		if(count($sectionCat)){
		  $secid=$sectionCat[0]->sectionid;
		  $catid=$sectionCat[0]->catid;
		}
	}//end task

}//end option
}//end menu

The following Joomla1.0.x extensions are all using the above code. Mod_latestnewsByCategoryOrSection mod_mostreadCategoryOrSection

 
How to dispay previous and next content with title in Joomla 1.5?
Written by Joe   
Wednesday, 18 June 2008 07:01

Joomla 1.5's page navigation display the previous and next content without content title.
This article will help you display the previous and next content with title in an easy way.

Open file $Joomla_base/plugins/content/pagenavigation.php.

  1. Change line 109 from
  2. $query = 'SELECT a.id,'
    to
    $query = 'SELECT a.id,a.title,'  
  3. Line 153 from

     $row->prev = JRoute::_('index.php?option=com_content&view=article&catid='.$row->prev->catslug.'&id='.$row->prev->slug); 
    to
      $row->prevTitle=$row->prev->title;
    $row->prev = JRoute::_('index.php?option=com_content&view=article&catid='.$row->prev->catslug.'&id='.$row->prev->slug);
  4. Line 159 from

    $row->next = JRoute::_('index.php?option=com_content&view=article&catid='.$row->next->catslug.'&id='.$row->next->slug); 
    to
    $row->nextTitle=$row->next->title;
    $row->next = JRoute::_('index.php?option=com_content&view=article&catid='.$row->next->catslug.'&id='.$row->next->slug);
  5. Line 177 from

     . JText::_( '<' ) . $pnSpace . JText::_( 'Prev' ) . '</a> 
    to
     .$row->prevTitle. JText::_( '<' ) . $pnSpace . JText::_( 'Prev' ) . '</a> 
  6. Line 196 from
    . JText::_( 'Next' ) . $pnSpace . JText::_( '>' ) .'</a> 
    to
    . JText::_( 'Next' ) . $pnSpace . JText::_( '>' ).$row->nextTitle .'</a>

Or you can just download the PageNav plugin from attachment.

To make the plugin work you should

1. Disable the default PageNavigation and enable PageNav.

2. Content-->Article Manager-->Parameters-->Show Navigation. Please select 'Show'.

 

Attachments:
 pageNav1.0.3.zip2 Kb
 
<< Start < Prev 1 2 3 4 5 6 7 8 9 Next > End >>

Page 9 of 9