Working with Phocagallery Menu or Tree Module on SEO Mode

Phoca Gallery modules - modules for Phoca Gallery extension
trespies
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 14 Aug 2009, 00:03
Location: Spain
Contact:

Working with Phocagallery Menu or Tree Module on SEO Mode

Post by trespies »

Hello.

This is an inelegant workaround, but it works, with some limitations.

Before anything, I go on to state the problem:

Recently, when I wanted to use the Phocagallery Menu/Tree Module, I found out that, if the Module wasn't assigned to "All" pages, it disappeared when I clicked on any of its menu items... To solve this problem, without SEO mode in Joomla, only had to replace this line of code (just before "return ($link);"):

Code: Select all

$link = JRoute::_('index.php?option=com_phocagallery&view=category&id='. $catid_slug .'&Itemid='.$itemId);
by the following:

Code: Select all

$link = JRoute::_('index.php?option=com_phocagallery&view=category&id='. $catid_slug .'&Itemid='.$_GET['Itemid']);


in its correspondent file (mod_phocagallery_menu.php or mod_phocagallery_tree.php).

In this way, menu or tree module works properly... without SEO mode.

Well, when I've tried out it activating SEO + mod_rewrite in Joomla (1.5.14, in my case), this problem turns to occur, and the anterior mend doesn't serve... The Phocagallery Menu/Tree module disappears when the user clicks on any of its menu items, if you don't assign this Menu/Tree module to “All”… In my case, that solution (assign the module to "All") was not satisfactory.

So, I've made the following workaround.

IMPORTANT! Note that, for this to work, you can not have any numbers neither in the name of your site, nor in the page name where you place the Menu, because it would conflict with the code entered.

1) To change, in its correspondent file, the code line above mentioned:

Code: Select all

$link = JRoute::_('index.php?option=com_phocagallery&view=category&id='. $catid_slug .'&Itemid='.$itemId);
by the following code lines:

Code: Select all

// URL DETECT
if (preg_match('#([0-9]+)#',$pageURL,$num)) {
	$pageURL = $pageURL;
} else {
	$pageURL = 'http';
	if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
		$pageURL .= "://";
	if ($_SERVER["SERVER_PORT"] != "80") {
		$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
	} else {
		$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] .'/';
	}
}

// URL CLEAN
preg_match('#([0-9]+)#',$pageURL,$num);
$numero = $num[1];
if ($numero != "") {
	$urlSeperate = explode($numero, $pageURL, 2);
	$urlClean = $urlSeperate[1];
	$pageURLclean = str_replace($urlClean,"",$pageURL);
	$pageURL = str_replace($numero,"",$pageURLclean);
}
$pageURL = str_replace("component/phocagallery/category/","YOUR-SEO-PAGE-NAME-WITH-MENU-or-TREE-MODULE",$pageURL);

// LOAD URL PAGE + PHOCA ITEM MENU
$link = JRoute::_($pageURL. $_GET['Itemid'] .'/'. $catid_slug);
IMPORTANT! Note that, where it's written "YOUR-SEO-PAGE-NAME-WITH-MENU-or-TREE-MODULE", you must write the name of the page/menu item where you've placed your Phocagallery Menu/Tree Module.

2) To insert, in the .htaccess in Joomla root, in any place between the line:

Code: Select all

########## End - Rewrite rules to block out some common exploits
and the line:

Code: Select all

########## Begin - Joomla! core SEF Section
the following two RewriteRules:

Code: Select all

RewriteRule ^component/phocagallery/category/(.*)$ index.php?option=com_phocagallery&view=category&id=$1&Itemid=YOUR-ITEMID-PAGE-NUMBER
RewriteRule ^YOUR-SEO-PAGE-NAME-WITH-MENU-or-TREE-MODULE/(.*)/(.*)$ index.php?option=com_phocagallery&view=category&id=$2&Itemid=$1
If you don't know wich is the ItemID number of the page where you've placed the Menu/Tree Module, you can see it in two ways: (a) Looking it on the Admin control panel (faster) or (b) desactivating SEO and looking it in the browser bar url (slower).

It's an inelegant workaround for several reasons:

a) It combines two different SEO nomenclatures, one for the galleries (your-website-name/your-page-name/your-ItemID/your-category), other for galleries containers (your-website-name/component/phocagallery/category/your-ItemID/your-category). It was necessary, because, if not, the Menu/Tree Module turned to disappear when the user clicked on a category thumbnail. I don't know how unify this nomenclatures.
b) It needs a non-variable-name (your-page-name) in php code. Sorry, I haven't achieved to avoid this.
c) It needs to introduce specifics RewriteRules in .htaccess
d) It requires no-number-url-names.

And, on the other hand, it doesn't solve other problem: at the least in my case, the Download Icon of Menu/Tree Module doesn't work properly in SEO Mode. If someone knows how to solve this problem, I would be grateful if inform me how to get it...

Well; in any case, you can see an example of Phocagallery Menu Module working in this way with SEO and mod_rewrite, in vertical disposition on leftcolumn, in http://mundojoomla.org/fotografia. It's a spanish website.

Other example, in this case in horizontal disposition, in http://ignacioiglesias.com/joomla. English.

Regards,
Nacho
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48799
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Working with Phocagallery Menu or Tree Module on SEO Mode

Post by Jan »

Hi,

1 Phocagallery Menu/Tree Module - yes, because Itemid are added by menu links to Joomla! url. All Phoca Extensions use JRoute method, which is a Joomla! core method. This means, all links are created (if SEF enabled) by Joomla! or by some other SEF extensions. There is problem with modules and plugins which don't have any menu link, so they don't have any Itemid and need to get some one, see this for explaining it:

https://www.phoca.cz/documents/50-phoca/ ... -component
https://www.phoca.cz/documents/16-joomla ... -in-joomla
https://www.phoca.cz/documents/2-phoca-g ... ent/24-faq (2)

If you add this:
&Itemid='.$_GET['Itemid'] it means, it will be used the menu link Itemid which is currently loaded, so e.g. if you will see VirtueMart on your site and some Phoca Module, the module will take a VM link in this case, and this can cause SEF problems. If it works for you, it is OK, but I think, this can make problems on some servers, so this solution cannot be made as default :-(

Disapperaing of Module - you can set in Module settings where the module will be displayed (you can set none, all or some menu links). This is standard Joomla! settings and if some menu link is not set in Module settings, then the module will disappear. In fact the displaying or hiding module depends on Itemid and if the Itemid is not selected, then the module will be not displayed.

But thank you for your guide, because in case Itemid, SEF there are a lot of possible solutions and user needs to set the right for him. The base problem is the Itemid which is missed in modules and plugins and it is only in menu links (e.g. to component). But this is very difficult to solve as e.g. if the modules and plugins get Itemid then the links to the same place will be not the same, so in fact you need always to use some kind of hack. In Phoca extensions I use the following hack:

The module or plugin url will try to find some menu link to component and then it will try to find some itemid of it. Then the same link as from menu link will be created. The problem is then, if there are more links to component. As I said, there are a lot of SEF solutions but seems like no one will be 100% ok :(

Jan
If you find Phoca extensions useful, please support the project
trespies
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 14 Aug 2009, 00:03
Location: Spain
Contact:

Re: Working with Phocagallery Menu or Tree Module on SEO Mode

Post by trespies »

Hi, Jan.

Thank you for your reply.

Yes, I know that use "&Itemid='.$_GET['Itemid'])" isn't a good solution, and nor the way that I expose in anterior post...

In any case, I'm going to read the text references that you comment, and to try a better understanding of JRoute & Joomla' core working (I'm a Newbie in Joomla).

Regards,
Nacho
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48799
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Working with Phocagallery Menu or Tree Module on SEO Mode

Post by Jan »

Ok
If you find Phoca extensions useful, please support the project
gritsyuk
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 26 Feb 2011, 14:27

Re: Working with Phocagallery Menu or Tree Module on SEO Mod

Post by gritsyuk »

If to include SEF and use mod_rewrite at phocadownload tree modul do not work references
to the categories and to $linkSections.
Please help me o! great and wise Jan :|
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48799
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Working with Phocagallery Menu or Tree Module on SEO Mod

Post by Jan »

Did you read the articles above?
If you find Phoca extensions useful, please support the project
Post Reply