Fiji Web Design
Welcome, Guest
Please Login or Register.    Lost Password?
Plaing Module Position inside PHP pages (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Plaing Module Position inside PHP pages
#1152
wolfeblog (User)
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
Plaing Module Position inside PHP pages 2 Years, 1 Month ago Karma: 0  
What code would I have to include in my custom php page to get joomla to load a user module position inside it?

Tried ...

<?php echo mosLoadModules ( 'user4' ); ?> // legency mode
<jdoc:include type="modules" name="user3" /> // joomla 1.5
Any Ideas really need this. Wolfe
 
Report to moderator   Logged Logged  
 
Last Edit: 2010/01/05 12:43 By admin.
 
  The administrator has disabled public write access.
#1153
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
Re:Plaing Module Position inside PHP pages 2 Years, 1 Month ago Karma: 10  
Here is a basic example of loading a single module:

$title = 'Latest News';
$name = 'mod_latestnews';

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

$mod =& JModuleHelper::getModule($name, $title);
$content = $renderer->render($mod, $_params);
To load a modules in a position:
$document	= &JFactory::getDocument();
$renderer	= $document->loadRenderer('module');
$_params	= array('style'=>$style);

$contents = '';
foreach (JModuleHelper::getModules($position) as $mod)  {
	$contents .= $renderer->render($mod, $_params);
}
echo $contents;
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#1314
tokkie (User)
Fresh Boarder
Posts: 10
graphgraph
User Offline Click here to see the profile of this user
Re:Plaing Module Position inside PHP pages 1 Year, 1 Month ago Karma: 0  
Hi,
I am using com_php to make my page. This part works fine. WHen I try and include

<? 
$title = 'Login';   
$name = 'mod_login';   
  
$document   = &JFactory::getDocument();   
$renderer   = $document->loadRenderer('module');   
$_params    = array('style'=>'-2');   
  
$mod =& JModuleHelper::getModule($name, $title);   
$content = $renderer->render($mod, $_params);   ?>
nothing happens ? Npot sure what I'm doing wrong, any help appreciated, many thanks
 
Report to moderator   Logged Logged  
 
Last Edit: 2010/12/22 13:13 By admin. Reason: Please highlight your code with [code] tags
  The administrator has disabled public write access.
#1315
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
Re:Plaing Module Position inside PHP pages 1 Year, 1 Month ago Karma: 10  
Try to echo the variable $content;

echo $content;
Just a note: It is best to use <?php rather then <? as the later only works with short open tags enabled which I believe is no longer PHP default.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#1316
tokkie (User)
Fresh Boarder
Posts: 10
graphgraph
User Offline Click here to see the profile of this user
Re:Plaing Module Position inside PHP pages 1 Year, 1 Month ago Karma: 0  
yes that worked,

pretty stupid of me just to set the variable and not display it.

Many thanks for what looks like a terrific component, and something thats going to really help me .
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#1317
tokkie (User)
Fresh Boarder
Posts: 10
graphgraph
User Offline Click here to see the profile of this user
Re:Plaing Module Position inside PHP pages 1 Year, 1 Month ago Karma: 0  
This code

$title = 'Mortgage Calculator';   
$name = 'mod_mortgagecalc';   
$document   = &JFactory::getDocument();   
$renderer   = $document->loadRenderer('module');   
$_params    = array('style'=>'-2');   
$mod =& JModuleHelper::getModule($name, $title);   
$content = $renderer->render($mod, $_params);   
echo $content;
works fine for a simple module. However if you try and load something a little more complicated it fails, i try ;
$name = 'mod_jea_emphasis';   
$document   = &JFactory::getDocument();   
$renderer   = $document->loadRenderer('module');   
$_params    = array('style'=>'-2');   
$mod =& JModuleHelper::getModule($name, $title);   
$content = $renderer->render($mod, $_params);   
echo $content;
in the mod_jea_emphasis directory i have the following files; helper.php mod_jea_emphasis.php what else do I need to include ? Thanks,
 
Report to moderator   Logged Logged  
 
Last Edit: 2010/12/26 14:09 By admin. Reason: Please wrap your code in [code]...[/code] tags
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Joomla Downloads

DownloadsDownload our free Joomla! Components, Modules and Plugins.