load module position in component layout template

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
User avatar
Sergey Romanov
I've been banned!
Posts: 279
Joined: Thu Dec 01, 2005 11:32 am
Location: Kyrgyzstan
Contact:

load module position in component layout template

Post by Sergey Romanov » Thu Oct 01, 2009 2:33 pm

Hello,

I have strange thing. If i insert in to my template

<jdoc:include type="module" name="breadcrumbs" />

Then I see reeal breadcrumbs like Home->Category->Article but if I insert

<jdoc:include type="module" name="user1" />

Or any other name nothing happen. I would understand when it ia always nothing but some (breadcrumbs) module position it encapsulate and otyher not.

What is the good way to insert module position in component layout template or subtemplate?

User avatar
imanickam
Joomla! Master
Joomla! Master
Posts: 28202
Joined: Wed Aug 13, 2008 2:57 am
Location: Chennai, India

Re: load module position in component layout template

Post by imanickam » Thu Oct 01, 2009 3:53 pm

The syntax basically says render all the modules that are published in the position mentioned in the parameter name - remember, it is not the name of the module; rather it is the name of a module position.

I believe that you have a module published to the module position breadcrumbs. That is the main reason you are seeing the module.

Do you have modules assigned to user1 and other module positions? If not, you will not see any modules.
Ilagnayeru (MIG) Manickam | இளஞாயிறு மாணிக்கம்
Joomla! - Global Moderators Team | Joomla! Core - Tamil (தமிழ்) Translation Team Coordinator
Former Joomla! Translations Coordination Team Lead
Eegan - Support the poor and underprivileged

User avatar
Sergey Romanov
I've been banned!
Posts: 279
Joined: Thu Dec 01, 2005 11:32 am
Location: Kyrgyzstan
Contact:

Re: load module position in component layout template

Post by Sergey Romanov » Fri Oct 02, 2009 4:13 am

Of course I have module assigned in the position I try to load.

How I use this function

Code: Select all

function load_module_position( $position, $style = 'xhtml')
{
	switch($style)
	{
		case 'table':
			$style = 1;
			break;
		case 'horz':
			$style = 1;
			break;
		case 'none':
			$style = -1;
			break;
		case 'xhtml':
			$style = -2;
			break;
		case 'rounded':
			$style = -3;
			break;
		default:
			$style = -2;
			break;
	}

	$document	= &JFactory::getDocument();
	$renderer	= $document->loadRenderer('module');
	$params		= array('style'=>$style);

	$contents = '';
	foreach (JModuleHelper::getModules($position) as $mod)  {
		$contents .= $renderer->render($mod, $params);
	}
	return $contents;
}
and in templates

<?php echo load_module_position('user12', 'xhtml'); ?>

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11615
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: load module position in component layout template

Post by ooffick » Fri Oct 02, 2009 12:35 pm

Sergey Romanov wrote: <?php echo load_module_position('user12', 'xhtml'); ?>
Why do you want to make it so complicated? What is wrong with the normal way?
You might want to open the module which is published in the module position user1, and write into the position field the following:

Code: Select all

user1
Yes, you can write into this dropdown field. (don't select it, just delete the entry which is there and write user1 into it)

And then click on save.

Olaf
Olaf Offick - Global Moderator
learnskills.org

deltadan79
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Dec 26, 2012 8:36 pm

Re: load module position in component layout template

Post by deltadan79 » Tue Jun 18, 2013 7:51 pm

Hey Guys,

I've found a solution that works to add a module position to a component manually where the typoical method does not work. Similar in concept to the loadposition principle. Sometimes you'd like to add a module/position to a components layout page and of course loadposition does not work many times. After heargin a lot of the answers i constantly end up going back to this one as it seems to work every time. But i always forget where i found it. so im posting it here for others to see. Thanks to the person who originally suggested as i can't remember now :)

Code: Select all

<?php $document = &JFactory::getDocument();
$renderer   = $document->loadRenderer('modules');
$position   = 'custompositionname';
$options   = array('style' => 'raw');
echo $renderer->render($position, $options, null); 
?>


Locked

Return to “Joomla! 1.5 Coding”