0

Is there a php function to insert in the template which prints the name of the menu item of the displayed page?

2
  • Welcome to JSE, please take our tour. Can you please edit your question to include any research/attempts that you've already done? By showing us which documentation pages you have already read, volunteers will know that they do not need to be recommended to you. Commented Mar 29, 2020 at 10:09
  • have you tried echo Factory::getApplication()->getMenu()->getActive()->title;
    – jonboy
    Commented Mar 30, 2020 at 13:29

1 Answer 1

0

In this case, the name of the menu item is called "Page Heading" in the Joomla! backend, first you need to have is this option enabled .

  • Go to the Global Configuration > Menus > and change "Show Page Heading" to "Yes"

  • You also have this option into your menu items, in the tab called "Page Display", by default is enabled.

So, the code is generated by com_content, and here is the code:

<?php if ($this->params->get('show_page_heading')) : ?>
    <div class="page-header">
        <h1> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1>
    </div>
<?php endif; ?>

If you need to add this code, maybe the best optión is create an override for one of the com_content options, once this is done you can find a folder called html inside your template.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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