Joomla! Discussion Forums



It is currently Mon Nov 23, 2009 5:25 pm (All times are UTC )

 


Forum rules

Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.



Post new topic Reply to topic  [ 7 posts ] 
Author Message
Posted: Tue Jul 21, 2009 12:02 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Tue Jul 21, 2009 11:37 am
Posts: 3
Hey there,
New to Joomla (just a few days), but so far I've been having a blast customizing it. Coming from a few other CMS' before, I was excited to see all the cool options Joomla has to offer.

After tinkering for a bit, I ran across my first question that I'd imagine there's a "best" or proper way to accomplish.

My goal is to add a module into a particular com_content's default.php override file on this custom template I'm working on. I recognize that the templates->my_custom_template->index.php makes use of JDOC's to call down and display modules and whatnot, but when I attempt to use a JDOC in my_custom_template->html->com_contact->contact->default.php (for example), it doesn't display.

I suspect this has to do with the way JDOC's are parsed and cached. So my question is: is there a more efficient or proper way to load a module on any of the html overrides?

A simple example:

Say I made a custom menu module containing a handful of external links and I *only* want it to display on the com_contact->contact->default.php page under the address, etc, but above the form. I also plan on using this module/menu of links on other pages down the road (hence the reason I made it a reusable module).

Now in the templates->my_custom_template->index.php file, I realize I could quite simply call it by doing the following:
Code:
<jdoc:include type="modules" name="contactsmenu" />
Is there a trick to getting jdoc's to work in the html default.php overrides, or is there another way to do this?

Appreciate the help, I feel Joomla has so much to offer, and tricks like this could come in handy!


Top
  E-mail  
 
Posted: Tue Jul 21, 2009 12:27 pm 
User avatar
Joomla! Hero
Joomla! Hero
Offline

Joined: Wed Oct 11, 2006 1:12 pm
Posts: 2597
Location: Kristiansand, Norway
Quote:
Say I made a custom menu module containing a handful of external links and I *only* want it to display on the com_contact->contact->default.php page under the address, etc, but above the form. I also plan on using this module/menu of links on other pages down the road (hence the reason I made it a reusable module).
What about assigning the modules to the spesific menu items. See the module parameters on each module.

Another solution can be creating more modulepositions in your template, then use {loadeposition xxxx} in contents.

_________________
Kristian (K.P) Pettersen
General Support Moderators | Sites & Infrastructure (Norway)
Joomla! i Norge | http://www.joomlainorge.no/


Top
  E-mail  
 
Posted: Tue Jul 21, 2009 12:55 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Tue Jul 21, 2009 11:37 am
Posts: 3
Hey Sone,
Thanks for the response! I love the idea of {loadposition xxx}, I experimented with that a little, but then I realized there has to be a better way to do this without giving the article author a chance to accidentally delete/forget to enter the {loadposition xxx} in the submission.

I guess I should be more specific about what I'm really trying to accomplish, I was trying to simplify it in the example above. But in actuality, I've altered the template for com_content->frontpage to be split up into multiple sections. Two editable sections to be exact: A Module, and the default content further below. For example:

Image

Note: the header and footer are not actually part of the frontpage->default.php, but rather the templates->my_custom_template->index.php file.

Because Module #1 is surrounded by non-editable design elements (graphics that I've manually put in the com_content->frontpage->default.php file), I was hoping to be able to manually call modules from the actual com_content->frontpage->default.php file so that I can still edit the module from the admin area, yet still have it be separate from the display of blog articles further down the page.

I'm probably missing something extremely obvious :eek:


Top
  E-mail  
 
Posted: Tue Jul 21, 2009 1:55 pm 
User avatar
Joomla! Hero
Joomla! Hero
Offline

Joined: Wed Oct 11, 2006 1:12 pm
Posts: 2597
Location: Kristiansand, Norway
Try this code...
Code:
// extra code to make this work
$style = -2; // set the style
$position = "left"; // set the position of the modules to be loaded
// end of extra code

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

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

// more extra code
    echo $contents; // do something with the module output

_________________
Kristian (K.P) Pettersen
General Support Moderators | Sites & Infrastructure (Norway)
Joomla! i Norge | http://www.joomlainorge.no/


Top
  E-mail  
 
Posted: Wed Jul 22, 2009 5:42 am 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Tue Jul 21, 2009 11:37 am
Posts: 3
Exactly what I was looking for, worked great. Thank you Kristian!


Top
  E-mail  
 
Posted: Wed Sep 02, 2009 4:09 pm 
Joomla! Intern
Joomla! Intern
Offline

Joined: Thu Dec 14, 2006 3:33 pm
Posts: 51
+1 Thank you Kristian!

I've been looking all over for a method to include modules in template overrides, this works perfectly :-)

_________________
--
Els
http://locusmeus.com/
http://locusoptimus.com/


Top
   
 
Posted: Sat Nov 07, 2009 5:38 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Thu Nov 24, 2005 1:05 pm
Posts: 82
Location: Vilnius, Lithuania
Thank you very much! This was very useful


Top
   
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

Quick reply

 



Who is online

Users browsing this forum: julieat, Per Yngve Berg, walleye69 and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group