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?
load module position in component layout template
- Sergey Romanov
- I've been banned!
- Posts: 279
- Joined: Thu Dec 01, 2005 11:32 am
- Location: Kyrgyzstan
- Contact:
- imanickam
- Joomla! Master
- Posts: 28202
- Joined: Wed Aug 13, 2008 2:57 am
- Location: Chennai, India
Re: load module position in component layout template
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.
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
Joomla! - Global Moderators Team | Joomla! Core - Tamil (தமிழ்) Translation Team Coordinator
Former Joomla! Translations Coordination Team Lead
Eegan - Support the poor and underprivileged
- 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
Of course I have module assigned in the position I try to load.
How I use this function
and in templates
<?php echo load_module_position('user12', 'xhtml'); ?>
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;
}
<?php echo load_module_position('user12', 'xhtml'); ?>
- ooffick
- Joomla! Master
- Posts: 11615
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: load module position in component layout template
Why do you want to make it so complicated? What is wrong with the normal way?Sergey Romanov wrote: <?php echo load_module_position('user12', 'xhtml'); ?>
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
And then click on save.
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Fledgling
- Posts: 2
- Joined: Wed Dec 26, 2012 8:36 pm
Re: load module position in component layout template
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
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);
?>