Publishing certain modules only on article page?

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
A1ex037
Joomla! Apprentice
Joomla! Apprentice
Posts: 29
Joined: Mon Jul 23, 2007 6:22 am

Publishing certain modules only on article page?

Post by A1ex037 » Wed Feb 27, 2008 11:47 pm

I'm definitely a new one when it comes to templates....anyway, I'm playing with this on local machine, trying to get inside all nuts and bolts. My question probably fits here (I couldn't find a better place to put it in).

How can I publish certain module only on article page? Everything is working nicely, except this. I don't want that module to appear anywhere else (front page, section, categories)...is this involves some modification inside templates/html or something else? The trick is that the idea is that frontpage, sections and categories hold some other modules in that position, but the article page should display another module right next to the article. As far as I understood, there may have been a way to do this, and looking through the forum I picked up a few interesting ideas... like "assign module to certain position which will not be published anywhere else, but on the article page" or "the module that holds vertical banners is to be copied to templates/html/... and then something needs to be done there (and I don't know what)"...anyway, the position is on the right side (it's a simple 3-way column, and position is called 'right'). On category and section page, that position holds other modules....

Anyone had some similar issue??? Any leads to the right direction???

Thanks in advance...
Last edited by A1ex037 on Fri Feb 29, 2008 5:40 pm, edited 2 times in total.

User avatar
radiant_tech
Joomla! Guru
Joomla! Guru
Posts: 531
Joined: Sat Dec 15, 2007 3:02 pm
Location: Washington DC Metro

Re: Publishing ads only on article page?

Post by radiant_tech » Fri Feb 29, 2008 4:09 pm

I'd start with creating a position that will only be used by these banner ads (don't forget to add it to your templateDetails.xml file). Then add php logic to the template index.php file that checks whether the page being displayed is an article. Further in the template, use that logic to decide whether to display the new position.

A1ex037
Joomla! Apprentice
Joomla! Apprentice
Posts: 29
Joined: Mon Jul 23, 2007 6:22 am

Re: Publishing ads only on article page?

Post by A1ex037 » Fri Feb 29, 2008 4:17 pm

radiant_tech wrote:I'd start with creating a position that will only be used by these banner ads (don't forget to add it to your templateDetails.xml file).
OK, this one was easy...
radiant_tech wrote: Then add php logic to the template index.php file that checks whether the page being displayed is an article. Further in the template, use that logic to decide whether to display the new position.
...but could you please explain how do I accomplish this?

Thanks.

User avatar
radiant_tech
Joomla! Guru
Joomla! Guru
Posts: 531
Joined: Sat Dec 15, 2007 3:02 pm
Location: Washington DC Metro

Re: Publishing certain modules only on article page?

Post by radiant_tech » Fri Feb 29, 2008 6:12 pm

Here's the logic that checks whether an article is being viewed and displays all modules assigned to that position:

Code: Select all

<?php if( JRequest::getVar( 'view' ) == 'article' ): ?>
    <jdoc:include type="modules" name="your_custom_position" />
<?php endif; ?>
If you want module chrome to be applied you'll want to add the style="attrib_name" attribute (i.e., style="rounded").

A1ex037
Joomla! Apprentice
Joomla! Apprentice
Posts: 29
Joined: Mon Jul 23, 2007 6:22 am

Re: Publishing certain modules only on article page?

Post by A1ex037 » Fri Feb 29, 2008 10:21 pm

That's exactly what I needed!
Thank you very much!

I really appreciate it...

buffallo
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Mon May 26, 2008 11:09 am
Location: india
Contact:

Re: Publishing certain modules only on article page?

Post by buffallo » Mon Jun 09, 2008 10:27 am

i aplied this but tis giving error at that position
Fatal error: Class 'JRequest' not found in C:\wamp\www\joomlatest\templates\canada\index.php on line 240

willyram
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Mon Jun 30, 2008 8:51 pm

Re: Publishing ads only on article page?

Post by willyram » Sun Jul 13, 2008 2:55 pm

radiant_tech wrote:I'd start with creating a position that will only be used by these banner ads (don't forget to add it to your templateDetails.xml file). Then add php logic to the template index.php file that checks whether the page being displayed is an article. Further in the template, use that logic to decide whether to display the new position.
Hi, I have the other way around question. I have a module that I would like to appear on a "blog view" but then not on the individual articles when they are clicked from that view. I see I could add the same logic with the negative condition, but perhaps there is a different way that would not require customization.

Also, some hints on writing the code for Joomla 1.0.x would be great.

Tks, Willie.

User avatar
toner728
Joomla! Intern
Joomla! Intern
Posts: 57
Joined: Wed Aug 27, 2008 1:55 pm
Location: New York City
Contact:

Re: Publishing certain modules only on article page?

Post by toner728 » Mon Sep 08, 2008 5:19 pm

Ok.. I want to display banner ads in article view.. where do i add the

<?php if( JRequest::getVar( 'view' ) == 'article' ): ?>
<jdoc:include type="modules" name="right" style="rounded" />
<?php endif; ?>

code in the index.php??

xpozay
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Oct 31, 2007 7:19 pm
Location: Singapore

Re: Publishing certain modules only on article page?

Post by xpozay » Sat Sep 13, 2008 8:36 am

I would like to take this one step further. I would like to assign different modules to different sections / categories on the articles page. So for example, module1 is linked to all articles of category 1 and section 1; whereas module 2 is assigned to all articles of category 2 section1; etc.

I cannot define this through menu assignment as the article pages are being displayed through the latestnews module.

thanks

agarza
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Thu Sep 27, 2007 4:40 pm

Re: Publishing certain modules only on article page?

Post by agarza » Thu Sep 18, 2008 6:44 pm

is there a component that could help out with this? hmm..

soylent
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Dec 05, 2008 8:49 pm

Re: Publishing certain modules only on article page?

Post by soylent » Sun Dec 07, 2008 1:59 am

Just an FYI...

One thing you could do if you want a module to show up in an article is assign the module to an unused position, then put the following code in your article:

{loadposition positionname}

This will load the module in that article only, and you can put it in any articles you want.

Not sure if this works in Joomla 1.0 or not. I've only done it in 1.5
(http://docs.joomla.org/How_do_you_put_a ... article%3F)

User avatar
ruigato
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 129
Joined: Sat Aug 20, 2005 4:12 pm
Location: Arouca - Portugal
Contact:

Re: Publishing certain modules only on article page?

Post by ruigato » Fri Dec 19, 2008 6:24 pm

is there any documentantion on this?

can someone replicate this code to J1.0

Code: Select all

<?php if( JRequest::getVar( 'view' ) == 'article' ): ?>
    <jdoc:include type="modules" name="your_custom_position" />
<?php endif; ?>
This opens lots of possibilities for me

xpozay
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Oct 31, 2007 7:19 pm
Location: Singapore

Re: Publishing certain modules only on article page?

Post by xpozay » Fri Jan 02, 2009 8:04 am

Another way of course is the "metamod". This will allow you to specify specific rules to display modules. Rules such as which sections, categories and/or article ids. Metamod, well ... its perfect :)

http://extensions.joomla.org/extensions ... 91/details

User avatar
mermedia
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri May 04, 2007 2:03 pm
Location: Virginia
Contact:

Re: Publishing certain modules only on article page?

Post by mermedia » Sun Feb 08, 2009 1:29 pm

soylent wrote:Just an FYI...

One thing you could do if you want a module to show up in an article is assign the module to an unused position, then put the following code in your article:

{loadposition positionname}

This will load the module in that article only, and you can put it in any articles you want.

Not sure if this works in Joomla 1.0 or not. I've only done it in 1.5
(http://docs.joomla.org/How_do_you_put_a ... article%3F)
Thanks! that is what I was looking for :)

guyfreer
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Wed Sep 27, 2006 6:16 am

Re: Publishing certain modules only on article page?

Post by guyfreer » Fri Feb 27, 2009 3:27 am

Hi,
This is something I need as well so thanks for the advice.
One other thing....
The module I am inserting in the article is a slideshow of images. Is there any way to wrap the text in the article around the inserted module (as you would with a single image being inserted into and article)?

harshilsh
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Jun 07, 2009 11:18 am

Re: Publishing certain modules only on article page?

Post by harshilsh » Wed Jun 24, 2009 5:57 am

hi!. I have inserted a Prayer center menu module into an article. the problem i m facing is it does not have the same look feel as the original module(when i link the module directly to menu item).
here's are the two pages please compare. and tell me what i should do.

Link1:http://knowjesus.in/joomla/prayer-center.html(the article where i have inserted the module)
Link2:http://knowjesus.in/joomla/component/pr ... ?task=view( here i have the original module when it is directly linked to the menu item )

mijalis
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Sep 07, 2007 1:48 pm

Re: Publishing ads only on article page?

Post by mijalis » Sat Aug 01, 2009 4:34 am

radiant_tech wrote:I'd start with creating a position that will only be used by these banner ads (don't forget to add it to your templateDetails.xml file). Then add php logic to the template index.php file that checks whether the page being displayed is an article. Further in the template, use that logic to decide whether to display the new position.
Another way is this:
1. Define the new position, eg articleright in templateDetails.xml
2. Modify your template's index.php and add the following code just before or after "right" module positioning:

Code: Select all

		<?php if ($this->countModules('articleright')) { ?>
		<!-- BEGIN: RIGHT COLUMN -->
		<div id="ja-col2">
			<jdoc:include type="modules" name="articleright" style="xhtml" />
		</div><br />
		<!-- END: RIGHT COLUMN -->
		<?php } ?>
3. Publish module on articleright position

The stuff that makes it automagically appear only in article view is style="xhtml" !

rrc_21
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Sun Jul 26, 2009 9:37 am

Re: Publishing certain modules only on article page?

Post by rrc_21 » Sat Aug 01, 2009 5:28 am

I am a newbie and found the following works for me and may offer some clues. I created a menu item called "articles" which goes to Joomla article page (write / read /edit) where users can select section / category. Now you can attach your module to this menu item under module manager->select module->menu assignment. If you want this module to appear only for certain categories, you can create a small custom code with few lines of custom code that allows only those articles to display. Not sure if this suits your need.

User avatar
bil7y
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Thu May 14, 2009 5:57 pm
Location: San Francisco, California
Contact:

Re: Publishing certain modules only on article page?

Post by bil7y » Thu Aug 27, 2009 7:02 pm

Modules Anywhere Extension seems to be the way to go here. Probably good to know how to doi the manual way as well. Download Modules anywhere from this link
http://www.nonumber.nl/modulesanywhere?tab=Download

or if you are more direct
http://docs.joomla.org/How_do_you_put_a ... article%3F

How do you put a module inside an article?
From Joomla! Documentation
Jump to: navigation, search
You will usually want to associate modules with articles in some way. The modules are allocated to module positions and the module positions appear somewhere on the web page as determined by the template. However, it is sometimes useful to have a module actually embedded in the article content itself.

To insert a module inside an article you use the "{loadposition xx}" command, as follows:

1.Create a module and set its position to any value that doesn't conflict with an existing template position. You can type in the position value instead of selecting it from the drop-down list. For example, use the position "myposition".
2.Assign the module to the Menu Items that contain the articles that you want the module to show in. You can also just assign the module to "All" Menu Items.
3.Edit the articles where you want this module to show and insert the text "{loadposition myposition}" in the article, at the place where you want the module to show.
The module will show at that point in the article.

Note that this only works when the plugin 'Content - Load Module' is enabled. If this plugin is disabled, the text "{loadposition myposition}" shows unchanged in the article.

stephenb
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 169
Joined: Tue Jan 22, 2008 4:05 am

Re: Publishing certain modules only on article page?

Post by stephenb » Sun Nov 15, 2009 5:51 pm

In answer to A1ex037's original question, and agarza's "is there a component that could help out with this?" I would like to point out MetaMod:

http://extensions.joomla.org/extensions ... ntrol/3391
http://www.metamodpro.com/

MetaMod is a module that you publish in the normal way. In the MetaMod configuration, you tell it when to include other modules inside of itself.

This can then achieve what you are asking for - the rules inside MetaMod can, for example, detect when you are on a particular article page. Or, when you are on the category list/blog page (as opposed to viewing an article itself). Or, it can detect which category/section the article you are viewing is actually in.

Add to that date/time detection, browser detection, browser language detection, GeoIP, whether or not the user is logged in, and more, and you have some idea of what MetaMod is capable of.

So when MetaMod detects any of these conditions, it can decide when to display other modules, or not.

All of this is achieved without having to alter your template index.php file. A little PHP is often required to craft the rules, but there are pages of examples on the web site ("recipes" section), and an active support forum.
Cheers,
Stephen
MetaMod & Chameleon developer: http://www.metamodpro.com/

Pinky2010
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Feb 10, 2010 1:35 pm

Re: Publishing certain modules only on article page?

Post by Pinky2010 » Wed Feb 24, 2010 3:28 pm

Hi,

so I have added the carousel module into one article and now I want to add another carousel module in a different position in a different article. Is this possible?

Cheers

User avatar
Ghonjez
Joomla! Exemplar
Joomla! Exemplar
Posts: 8770
Joined: Sat Oct 18, 2008 3:02 am
Location: Mars
Contact:

Re: Publishing certain modules only on article page?

Post by Ghonjez » Thu Feb 25, 2010 12:50 pm

Hi...

Yes, it's possible. There are several methods for insert / embed module in article. You can embed any modules in any articles
Tutorial >>> http://docs.joomla.org/How_do_you_put_a ... article%3F
Or with extensions >>> Modules Anywhere and Metamod. See also extension on Embed & Include section on JED. There are a lots of extensions for do this

hope helps :)

Pinky2010
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Feb 10, 2010 1:35 pm

Re: Publishing certain modules only on article page?

Post by Pinky2010 » Thu Feb 25, 2010 2:04 pm

ok, so i did this {loaduser1 yoo-slider} and it won't work. But when I do this {loadright yoo-carousel} it works?!

zacharyrs
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 135
Joined: Fri May 02, 2008 11:57 pm

Re: Publishing certain modules only on article page?

Post by zacharyrs » Mon May 10, 2010 1:27 pm

how would you should a different module per each article using php if/elseif/else? If I can get the info on figuring out the Article ID then I could do this easy.

Alfredo Tester
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 103
Joined: Thu Jun 29, 2006 7:31 pm

Re: Publishing certain modules only on article page?

Post by Alfredo Tester » Sun Jul 18, 2010 2:38 am

I am trying to go the {loadposition positionname} route. I have the module showing up in the article like I want.

I am using a postion that I don't need. However when I do the above it also shows in that module postion. How do I make it so that it doesn't show up in that module position. Is that possible going this route

User avatar
Ghonjez
Joomla! Exemplar
Joomla! Exemplar
Posts: 8770
Joined: Sat Oct 18, 2008 3:02 am
Location: Mars
Contact:

Re: Publishing certain modules only on article page?

Post by Ghonjez » Mon Aug 16, 2010 1:27 pm

Hi...

For display certain modules in certain article, you could try also this extension :
Advanced Module Manager >>> http://extensions.joomla.org/extensions ... ment/10307

hope helps ;)

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30934
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Publishing certain modules only on article page?

Post by Per Yngve Berg » Mon Aug 16, 2010 4:10 pm

Alfredo Tester wrote:I am trying to go the {loadposition positionname} route. I have the module showing up in the article like I want.

I am using a postion that I don't need. However when I do the above it also shows in that module postion. How do I make it so that it doesn't show up in that module position. Is that possible going this route

Use a position name that does not exist in your template.

Tip. You can type in a name in Module Manager without opening the dropdown box.

hannur35
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Aug 21, 2010 4:33 pm

Re: Publishing certain modules only on article page?

Post by hannur35 » Sat Aug 21, 2010 4:41 pm

Thanks

rameshkumar
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Wed Sep 29, 2010 5:08 am

Re: Publishing certain modules only on article page?

Post by rameshkumar » Tue Oct 05, 2010 5:53 am

Hi All,
I am bit confused,
Now i divided the middle part into three parts(COLUMN),
By default, two columns are already filled with contents,
now i need to add some more content(Article) into the third column.Now its blank.
How can i achieve this.

Please find the attached screenshot.

Thanks in Advance,
IpRameshKumar.
You do not have the required permissions to view the files attached to this post.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30934
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Publishing certain modules only on article page?

Post by Per Yngve Berg » Tue Oct 05, 2010 1:55 pm

It will be filled in automatically when you publish the 4. article. Remember to tick the Publish on Frontpage option.


Locked

Return to “Templates for Joomla! 1.5”