Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » How to show a module only on a...
How to show a module only on a particular article
How to show a module only on a particular article
Hi there,
I tried
Code:
if ($id == 48)
return 51;
where 48, is my com_content item id, and 51 my module id, but it doesn't work.
In the doc it is said :
$id - the id of the item in the main component on the page (e.g. "24:content-layouts")
I don't understand "24:content-layouts" what it is ?
I use a french version of joomla, so maybe things have different names
Thanks a lot
Re: How to show a module only on a particular article
Hi Mouloud,
$id can be structured in different ways depending on the component that you are using.
In most cases in com_content, when you are viewing an article then $id will be structured like "24:content-layouts", with the ID number of the article first followed by ":" and the title of the article.
If you want to just get the ID number from the beginning of the string, you can do it like this:
if ( (int)$id == 48 ) return 51;
However, if you are viewing a "category" page, then $id can represent different values depending on whether you are looking at the blog/list view, or if you have clicked on one of the articles to view just that article.
When you are on the category page, $view will equal "category", and $id will equal the category ID. When you click on one of the articles in the category, $view will equal "article" and $id will be the article id and title (e.g. "24:content-layouts").
So it pays to check more than just the id, because you sometimes won't know what $id is referring to.
e.g.
Code:
if ($option == "com_content" and $view == "article" and (int)$id == 48 ) return 51;
Hope that helps,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » How to show a module only on a...
Board Info
- Board Stats:
- Total Topics:
- 1699
- Total Polls:
- 6
- Total Posts:
- 5965
- Posts this week:
- 3
- User Info:
- Total Users:
- 8012
- Newest User:
- grant1ab
- Members Online:
- 0
- Guests Online:
- 167
- 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