Page title and pathway problem for rsgallery2

I always like to share web related silly problems that I face in my works.
If u are a joomla fan and u like to make a image gallery in joomla then rsgallery2 can be ur better(to me it’s best) choise. But one thing that I faced in joomla1.5(don’t know about the condition in joomla1.x series) about rsgallery2 is it’s title and pathway problem when it’s just connected as component from menu I mean just when u go to rsgallery2 as from menu as a component it doesn’t show any breadcrumb(pathway) and pagetitle

I searched google and joomla forum for this but didn’t get much help actually. BTW, at this time the rsgallery2 site is down for maintenance. So I gave a try to fix this as I always do.

At first let me clear about the problem. When first time u will go to rsgallery2 as component, in this condition no gallery is selected and no items in any gallery ie, no gallery id or current gallery is as no gallery id

Not clear yet, check the code in com_rsgallery2\templates\meta\display.class.php and in function showRSPathWay()…To get it clearly u have to check this function dear

see this
if ( $gallery->id == $currentGallery && empty($item) )

this is true when just go to rsgallery2 because no items and both the gallery id is null and currentgallery id is null and
as it’s true the code is executed as $pathway->addItem($gallery->name );
but as gallery id is null then it’s doesn’t show any gallery name… isn’t it a bug huh ? that means pathway fails to show any thing for this condition and same problem in
function metadata() which shows the pagetitle for rsgallery2 and meta information.

Here is the code that I edited for those two functions


/**     * shows proper Joomla path     */
function showRSPathWay() {
		global $mainframe, $mosConfig_live_site, $Itemid, $option;
		// if rsg2 isn't the component being displayed, don't show pathway
		if( $option != 'com_rsgallery2' )	return;

		$gallery = rsgInstance::getGallery();
		$currentGallery = $gallery->id;
		$item = rsgInstance::getItem();
		$galleries = array();
		$galleries[] = $gallery;
		while ( $gallery->parent != 0) {
			$gallery = $gallery->parent();
			$galleries[] = $gallery;
		}
		$galleries = array_reverse($galleries);
		if( defined( 'J15B_EXEC' ) )
		{
			// J1.0 method
			foreach( $galleries as $gallery )
			{
				if ( $gallery->id == $currentGallery && empty($item) )
				{
					$mainframe->appendPathWay($gallery->name);
				} else {
					$mainframe->appendPathWay('<a href="' . JRoute::_('index.php?option=com_rsgallery2&amp;Itemid='.$Itemid.'&amp;gid=' . $gallery->id) . '">' . $gallery->name . '</a>');
				}
			}
			if (!empty($item)) {
					$mainframe->appendPathWay( $item->title );
			}
		}
		else
		{
			// J1.5 method
			$pathway =&amp; $mainframe->getPathway();

			/*Edit start by manchumahara*/
			$document	=&amp; JFactory::getDocument();
			$params = &amp;$mainframe->getParams();
			$menus	= &amp;JSite::getMenu();
			$menu	= $menus->getActive();
			$pagetitle = '';
			if (is_object( $menu ))
			{
				$menu_params = new JParameter( $menu->params );
				if (!$menu_params->get( 'page_title'))
				{
					$pagetitle = JText::_('MRSGALLERYTITLE');
					//loading it from language file
				}
				else $pagetitle =$menu_params->get( 'page_title');
			}
			else
			{
				$pagetitle = JText::_('MRSGALLERYTITLE');
				//loading it from language file
			}
			//$pagetitle = $mainframe->getPageTitle();
			foreach( $galleries as $gallery )
			{
				if ( $gallery->id == $currentGallery &amp;&amp; empty($item) )
				{
					if($gallery->id== 0){
						//gallery id zero and no items ie, if menu is link to component directly
						$pathway->addItem($pagetitle);
					}
					else
					{
						//gallery id not zero,ie gid id ok but no items in this gallery
						$pathway->addItem($gallery->name );
					}
				} else
				{
					$link = 'index.php?option=com_rsgallery2&amp;gid=' . $gallery->id;
					$pathway->addItem( $gallery->name, $link );
				}
			}
			/*Edit end by manchumahara*/

			/*Edit start by manchumahara*/
			if (!empty($item)) {
				$mainframe->appendPathWay($item->title );
				//$mainframe->appendPathWay( $title );
			}
			else {$mainframe->appendPathWay($pagetitle);}
			/*Edit end by manchumahara*/
		}
	}
	/**	 * insert meta data into head	 */
	function metadata(){
		global $mainframe, $option;
		// if rsg2 isn't the component being displayed, don not append meta data
		if( $option != 'com_rsgallery2' )
			return;		/*Edit by manchumahara*/
		$document	=&amp; JFactory::getDocument();
		$params = &amp;$mainframe->getParams();
		$menus	= &amp;JSite::getMenu();
		$menu	= $menus->getActive();
		$pagetitle = '';
		if (is_object( $menu )) {
			$menu_params = new JParameter( $menu->params );
			if (!$menu_params->get( 'page_title')) {
				$pagetitle = JText::_('MRSGALLERYTITLE');
				//loading it from language file
			}
			else $pagetitle =$menu_params->get( 'page_title');
		}
		else
		{
			$pagetitle = JText::_('MRSGALLERYTITLE');
			//loading it from language file
		}

		/*Edit start by manchumahara*/
		$title = $this->gallery->get('name');
		$description = htmlspecialchars(strip_tags($this->gallery->get('description')), ENT_QUOTES );
		$item = rsgInstance::getItem();
		if ($item != null){
			$title .= ' - ' . $item->title;
			$description .= ' -  ' . htmlspecialchars(strip_tags($item->descr), ENT_QUOTES );
		}

		/*Edit end by manchumahara*/

		if($title == ''){ $title = $pagetitle;}

		/*Edit start by manchumahara*/
		$mainframe->setPageTitle( ' '. $title );
		$mainframe->appendMetaTag( 'description',  $description );
	}

BTW, as if there is nothig set as pagetitle from menu then I showed it from language file and for this I made an entry in language file as like this. Open en-GB.ini file and put this line at the end
MRSGALLERYTITLE = RSGallery2

2 Responses to “Page title and pathway problem for rsgallery2”

  1. I have been interested in your code but unfortunatley it doesn’t display correctly on this page, none of the line breaks or justifications are in place.
    Do you have the code that you could send to me?
    many thanks

Leave a Reply

Your email address will not be published. Required fields are marked *