Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.



Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.


How to show a module only on a particular article

How to show a module only on a particular article

Hi there,
I tried


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

Beginner Modder
1 Posts
Administrator has disabled public posting

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.



if ($option == "com_content" and $view == "article" and (int)$id == 48 ) return 51;

Hope that helps,

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

3314 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
Total Topics:
Total Polls:
Total Posts:
Total Posts Today:
User Info:
Total Users:
Newest User:
toko solo
Members Online:
Guests Online:

There are no members online

Forum Legend:

 New Sticky