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:
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:
<center> <a href="index.php?option=com_login\">You need to login first before you can add a listing</a> </center>
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>
<center> <?php $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); ?> </center>
…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.