Adding a Joomla login form to the Mosets Tree error page

Whilst working on a recent project, I had to implement a directory using the Joomla component Mosets Tree. As anyone who uses this component knows, when attempting a task which requires the user to be authenticated first (i.e. submit a listing, submit a listing review, report a listing, etc.), Mosets simply displays an error message, such as “You need to login first before you can add a listing / write a review / report a listing” without redirecting to a login / registration page.

A solution posted on the Mosets Tree forum recommends editing the file page_error.tpl.php, which depending on what template you are using, can be found in:

/[Joomla root]/components/com_mtree/templates/kinabalu/


/[Joomla root]/components/com_mtree/templates/m2/

The page has a few simple lines of code:

<h2><?php echo JText::_( 'Error' ) ?></h2>

<p /><center><?php echo $this->error_msg ?></center>

To which a custom link to the login page can be added, like this:


<a href="index.php?option=com_login\">You need to login first before you can add a listing</a>


This solution is better than nothing, but personally I think that having a login form on the page looks more elegant. Depending on what template you are using, navigate to its directory as described above, and find the pages page_error.tpl.php and page_errorListing.tpl.php. Under the code:

<center><strong><?php echo $this->error_msg ?></strong></center>


$document    = &JFactory::getDocument();
$renderer    = $document->loadRenderer('module');
$options    = array('style' => 'raw');
$module    = JModuleHelper::getModule('mod_login');
$module->params    = "heading=2\nlimit=10";
echo $renderer->render($module, $options);

…which then looks like this:

In fact, this is a recipe for adding any Joomla module to a Mosets Tree page, especially useful for listing details (sub_listingDetailsStyleX.tpl.php). Just replace mod_login with the name of the module which you want to add.

Good luck!

About Manuel Timita

Passionate about both human and IT systems. More curious than a cat, yet hoping to dodge its proverbial fate for a while.
This entry was posted in Hacks and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>