2

I'm trying to make the breadrumbs module to display also the page title but with no luck.

All i want is breadcrumbs and page title (of an article or menu) to display in same div!

Example here: http://www.astemplates.com/itempreview/315

For example breadcrumbs float left and page title float right in same div!


I tried your advice but i recieve fatal error.

I did override the breadcrumbs module the default.php file and before i put a div with the php that you wrote!

Here it is:

<?php
    defined('_JEXEC') or die;

JHtml::_('bootstrap.tooltip');

?>

<div class="title<?php echo JSite::getMenu()->getItem(&JSite::getMenu()->getActive()->tree[0])->title; ?>">

</div>

<ul class="breadcrumb<?php echo $moduleclass_sfx; ?>">
    <?php
    if ($params->get('showHere', 1))
    {
        echo '<li class="active">' . JText::_('MOD_BREADCRUMBS_HERE') . '&#160;</li>';
    }
    else
    {
        echo '<li class="active"><span class="divider icon-location"></span></li>';
    }

Whay i'm doing wrong here?

  • 1
    If you want to add additional information, edit your question, don't add more questions as an answer. – David Fritsch Mar 1 '15 at 19:32
2

Looder has reason JSite it's deprecated use

$app = JFactory::getApplication();

echo $app->getMenu()->getItem($app->getMenu()->getActive()->tree[0])->title;

Now it works! (tested in a Joomla! 3.3.6)

But your html it's not valid if you want to show the breadcrumbs to the left and the page title to the right... must be something like:

<div class = "breadcrumbs<?php echo $moduleclass_sfx; ?>">
<?php if ($params->get('showHere', 1))
{
    echo '<span class="showHere">' .JText::_('MOD_BREADCRUMBS_HERE').'</span>';
}

// Get rid of duplicated entries on trail including home page when using multilanguage
for ($i = 0; $i < $count; $i++)
{
    if ($i == 1 && !empty($list[$i]->link) && !empty($list[$i - 1]->link) && $list[$i]->link == $list[$i - 1]->link)
    {
        unset($list[$i]);
    }
}

// Find last and penultimate items in breadcrumbs list
end($list);
$last_item_key = key($list);
prev($list);
$penult_item_key = key($list);

// Generate the trail
foreach ($list as $key => $item) :
// Make a link if not the last item in the breadcrumbs
$show_last = $params->get('showLast', 1);
if ($key != $last_item_key)
{
    // Render all but last item - along with separator
    if (!empty($item->link))
    {
        echo '<a href="' . $item->link . '" class="pathway">' . $item->name . '</a>';
    }
    else
    {
        echo '<span>' . $item->name . '</span>';
    }

    if (($key != $penult_item_key) || $show_last)
    {
        echo ' '.$separator.' ';
    }

}
elseif ($show_last)
{
    // Render last item if reqd.
    echo '<span>' . $item->name . '</span>';
}
endforeach; ?>

<div style="float:right;"><?php echo JFactory::getApplication()->getMenu()->getItem(JFactory::getApplication()->getMenu()->getActive()->tree[0])->title; ?></div></div>
-1

You can override the breadcrumbs module from your template adding some html and styles to insert a right floating div and print inside the menu title with

<?php echo JSite::getMenu()->getItem(&JSite::getMenu()->getActive()->tree[0])->title; ?>
  • JSite::getMenu() is deprecated and has been for a long time. If you want to get the active menu item, see here: docs.joomla.org/… – Lodder Mar 1 '15 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.