Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » MetaMod and Search Engine Friendly URLS
MetaMod and Search Engine Friendly URLS
MetaMod and Search Engine Friendly URLS
Hello everybody,
I have following problem: I want to show a module just for all articles of a category, except in the category blog layout.
I'm using this code: if ($option == "com_content" and $view == "article") return 89;
It works pretty good BUT if I activate search engine friendly urls and mod_rewrite, it doenst'n work anymore.
I hope I find help here!
Ando
Re: MetaMod and Search Engine Friendly URLS
Hmm, that's strange. The miracle of Joomla SEF URLs is that this code is supposed to still work!
Can you turn on Advanced Debug mode in your MetaMod, then view an article page, then paste the output from the Advanced Debug mode into a forum post? Then we can see exactly what variables are being used, if the ones above are no longer correct.
Thanks,
Stephen
Re: MetaMod and Search Engine Friendly URLS
Hi, I'm having exact same issue as the person who started this thread. metamod shows the correct module only if I turn off SEF urls in Joomla. I'm using Joomla 1.5.20 with default Joomla sef.
SITUATION: I have a category list link on main menu. When I click any of the category list links, I want to add a left col module to the category article. Since Joomla is not capable of displaying a module on a category list article page, I am using metamod to do that. It works perfectly unless I turn on Joomla SEF URLs. Then it doesn't work and the module does not display.
Here is metabod debug info for page:
Page Identification
The PHP code below may be used to help MetaMod to identify the exact page that you are viewing. For help using this feature, please click here.
if (
$option == 'com_content'
and $view == 'article'
and $id == '60:nashville-sales-career-fair-wednesday-august-18th'
and $Itemid == '56'
) return XXX; /* replace XXX with the module ID or position to display */
MetaMod debug info:
$option: com_content
$view: article
$id: 60:nashville-sales-career-fair-wednesday-august-18th
$Itemid: 56
$timezone: default
$language: en-us
$language_code: en
$language_region: us
Including modules: 90
Here is module php code:
$category_id = null;
if ( $option == "com_content" ) {
if ( $view == "category" ) {
/* category list pages (blog or list style) */
$category_id = (int)$id;
} else if (array_key_exists("catid",$_REQUEST)) {
/* if the category id is in the URL */
$category_id = (int)JRequest::getInt("catid",0);
}
if ( $category_id === null && $view == "article" ) {
/* if it's an article page without the catid mentioned in the url */
$nullDate = $db->Quote( $db->getNullDate() );
$my_id = $db->Quote( $db->getEscaped( (int)$id ) );
$jnow =& JFactory::getDate();
$now = $db->Quote( $db->getEscaped( $jnow->toMySQL() ) );
$query = "SELECT title, id, catid "
. " FROM #__content WHERE id = $my_id AND state = 1"
. " AND ( publish_up = $nullDate "
. " OR publish_up <= $now )"
. " AND ( publish_down = $nullDate "
. " OR publish_down >= $now )";
$db->setQuery( $query, 0, 1 );
$row = $db->loadObject();
$category_id = $row->catid;
}
}
/* Now customise any of the following rules for your use.
* $category_id will correspond to the category id of the
* article being displayed (if one is being displayed!)
*/
if ($option == "com_content" and $view == "article" and $category_id == 37) return 90;/* on category 1, return module 55 */
Below is debug info.
Profile Information
Application afterLoad: 0.000 seconds, 0.39 MB
Application afterInitialise: 0.053 seconds, 4.47 MB
Application afterRoute: 0.077 seconds, 6.35 MB
Application afterDispatch: 0.130 seconds, 10.15 MB
Application afterRender: 0.165 seconds, 11.72 MB
Memory Usage
12408720
15 queries logged
1.
SELECT *
FROM jos_session
WHERE session_id = '2qb00oakmcj13946ghtbgb09u1'
2.
DELETE
FROM jos_session
WHERE ( time < '1280338890' )
3.
SELECT *
FROM jos_session
WHERE session_id = '2qb00oakmcj13946ghtbgb09u1'
4.
UPDATE `jos_session`
SET `time`='1280346090',`userid`='0',`usertype`='',`username`='',`gid`='0',`guest`='1',`client_id`='0',`data`='__default|a:7:{s:15:\"session.counter\";i:10;s:19:\"session.timer.start\";i:1280344382;s:18:\"session.timer.last\";i:1280344504;s:17:\"session.timer.now\";i:1280344507;s:22:\"session.client.browser\";s:95:\"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8\";s:8:\"registry\";O:9:\"JRegistry\":3:{s:17:\"_defaultNameSpace\";s:7:\"session\";s:9:\"_registry\";a:1:{s:7:\"session\";a:1:{s:4:\"data\";O:8:\"stdClass\":0:{}}}s:7:\"_errors\";a:0:{}}s:4:\"user\";O:5:\"JUser\":19:{s:2:\"id\";i:0;s:4:\"name\";N;s:8:\"username\";N;s:5:\"email\";N;s:8:\"password\";N;s:14:\"password_clear\";s:0:\"\";s:8:\"usertype\";N;s:5:\"block\";N;s:9:\"sendEmail\";i:0;s:3:\"gid\";i:0;s:12:\"registerDate\";N;s:13:\"lastvisitDate\";N;s:10:\"activation\";N;s:6:\"params\";N;s:3:\"aid\";i:0;s:5:\"guest\";i:1;s:7:\"_params\";O:10:\"JParameter\":7:{s:4:\"_raw\";s:0:\"\";s:4:\"_xml\";N;s:9:\"_elements\";a:0:{}s:12:\"_elementPath\";a:1:{i:0;s:66:\"/home1/vmgtcom/public_html/libraries/joomla/html/parameter/element\";}s:17:\"_defaultNameSpace\";s:8:\"_default\";s:9:\"_registry\";a:1:{s:8:\"_default\";a:1:{s:4:\"data\";O:8:\"stdClass\":0:{}}}s:7:\"_errors\";a:0:{}}s:9:\"_errorMsg\";N;s:7:\"_errors\";a:0:{}}}'
WHERE session_id='2qb00oakmcj13946ghtbgb09u1'
5.
SELECT *
FROM jos_components
WHERE parent = 0
6.
SELECT folder AS type, element AS name, params
FROM jos_plugins
WHERE published >= 1
AND access <= 0
ORDER BY ordering
7.
SELECT name,player_id,ripper_id,postreplace
FROM jos_avr_tags
8.
SELECT name,player_id,ripper_id,postreplace
FROM jos_avr_tags
9.
SELECT m.*, c.`option` AS component
FROM jos_menu AS m
LEFT JOIN jos_components AS c
ON m.componentid = c.id
WHERE m.published = 1
ORDER BY m.sublevel, m.parent, m.ordering
10.
SELECT template
FROM jos_templates_menu
WHERE client_id = 0
AND (menuid = 0 OR menuid = 56)
ORDER BY menuid DESC
LIMIT 0, 1
11.
SELECT a.*, u.name AS author, u.usertype, cc.title AS category, s.title AS section, CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END AS slug, CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END AS catslug, g.name AS groups, s.published AS sec_pub, cc.published AS cat_pub, s.access AS sec_access, cc.access AS cat_access
FROM jos_content AS a
LEFT JOIN jos_categories AS cc
ON cc.id = a.catid
LEFT JOIN jos_sections AS s
ON s.id = cc.section
AND s.scope = "content"
LEFT JOIN jos_users AS u
ON u.id = a.created_by
LEFT JOIN jos_groups AS g
ON a.access = g.id
WHERE a.id = 70
AND ( ( a.created_by = 0 ) OR ( a.state = 1
AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '2010-07-28 19:41:30' )
AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '2010-07-28 19:41:30' ) ) OR ( a.state = -1 ) )
12.
UPDATE jos_content
SET hits = ( hits + 1 )
WHERE id='70'
13.
SELECT id, title, module, position, content, showtitle, control, params
FROM jos_modules AS m
LEFT JOIN jos_modules_menu AS mm
ON mm.moduleid = m.id
WHERE m.published = 1
AND m.access <= 0
AND m.client_id = 0
AND ( mm.menuid = 56 OR mm.menuid = 0 )
ORDER BY position, ordering
14.
SELECT m.*
FROM jos_menu AS m
WHERE menutype='mainmenu'
AND published = 1
AND access <= 0
ORDER BY ordering
15.
SELECT catid
FROM jos_content
WHERE id = 70
Language Files Loaded
* /home1/vmgtcom/public_html/language/en-GB/en-GB.ini 1
* /home1/vmgtcom/public_html/administrator/language/en-GB/en-GB.plg_content_avreloaded.ini 1
* /home1/vmgtcom/public_html/language/en-GB/en-GB.plg_system_debug.ini 1
* /home1/vmgtcom/public_html/language/en-GB/en-GB.com_content.ini 1
* /home1/vmgtcom/public_html/language/en-GB/en-GB.plg_content_pagebreak.ini 1
* /home1/vmgtcom/public_html/language/en-GB/en-GB.tpl_beez2.ini
* /home1/vmgtcom/public_html/language/en-GB/en-GB.mod_mj_markupchooser.ini
* /home1/vmgtcom/public_html/language/en-GB/en-GB.mod_exmenu-j15.ini
Untranslated Strings Diagnostic
None
Untranslated Strings Designer
None
Re: MetaMod and Search Engine Friendly URLS
Hi pxforti,
unfortunately I can't seem to replicate the problem. I'm using a freshly upgraded test site (1.5.15->1.5.20) with almost nothing extra installed on it. I used this recipe to print out the option, view and category_id:
$category_id = null;
if ( $option == "com_content" ) {
if ( $view == "category" ) {
/* category list pages (blog or list style) */
$category_id = (int)$id;
} else if (array_key_exists("catid",$_REQUEST)) {
/* if the category id is in the URL */
$category_id = (int)JRequest::getInt("catid",0);
}
if ( $category_id === null && $view == "article" ) {
/* if it's an article page without the catid mentioned in the url */
$nullDate = $db->Quote( $db->getNullDate() );
$my_id = $db->Quote( $db->getEscaped( (int)$id ) );
$jnow =& JFactory::getDate();
$now = $db->Quote( $db->getEscaped( $jnow->toMySQL() ) );
$query = "SELECT title, id, catid "
. " FROM #__content WHERE id = $my_id AND state = 1"
. " AND ( publish_up = $nullDate "
. " OR publish_up <= $now )"
. " AND ( publish_down = $nullDate "
. " OR publish_down >= $now )";
$db->setQuery( $query, 0, 1 );
$row = $db->loadObject();
$category_id = $row->catid;
}
}
echo "option: $option, view $view, category_id $category_id ";
With both SEF URLs of and then on, I went to the front page of the site, then clicked on the link to "What languages are supported by Joomla! 1.5?".
I get the debug info:
When SEF URLs are on:
URL: http://localhost/category-table/30-what-languages-are-supported-by-joomla-15
if (
$option == 'com_content'
and $view == 'article'
and $id == '30:what-languages-are-supported-by-joomla-15'
and $Itemid == '47'
) return XXX;
option: com_content, view article, category_id 32
When SEF URLs are off:
URL: http://localhost/index.php?option=com_content&view=article&id=30:what-languages-are-supported-by-joomla-15&catid=32:languages&Itemid=47
if (
$option == 'com_content'
and $view == 'article'
and $id == '30:what-languages-are-supported-by-joomla-15'
and JRequest::getVar('catid') == '32:languages'
and $Itemid == '47'
) return XXX;
option: com_content, view article, category_id 32
So in both cases the Advanced Debug info is a little different, but the end result is the same.
Note: I'm also using the "Use Apache mod_rewrite" option. The results are the same whether or not I use it.
Could you try putting the "echo" line instead of the "if" line at the end of your recipe, and take a look at the output when you have SEF URLs turned on? Which info is it missing?
Cheers,
Stephen
Re: MetaMod and Search Engine Friendly URLS
Mmm, could be caching. Do you have the system cache plugin enabled? That can sometimes play havoc with MetaMod.
Anyway, glad it's working now.
Cheers,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » MetaMod and Search Engine Friendly URLS
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Posts this week:
- 2
- User Info:
- Total Users:
- 7627
- Newest User:
- rudys68879
- Members Online:
- 0
- Guests Online:
- 182
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked