Articles Anywhere

Add menu title with shortcode

2 months 3 weeks ago #90034

Seppi's Avatar Seppi

Hi dear Regular Labs Team

We love the ability to add the current article's title by using:

{article}[title]{/article}

Now what I'd like to know is this: Can the title of the menu item also be displayed like this? Like for example:
[menu-title]

I get that it's not actually an article thing. But maybe it's possible with a different component of yours?

Thanks & best regards

2 months 3 weeks ago #90035

Peter van Westen's Avatar Peter van Westen Admin

You can use Sourcerer to output custom php code.
www.regularlabs.com/extensions/sourcerer

The php code for echoing out the active menu title is not so complicated:

{source}<?php echo JFactory::getApplication()->getMenu()->getActive()->title; ?>{/source}

2 months 3 weeks ago #90036

Peter van Westen's Avatar Peter van Westen Admin

If you want to make this easier to use across your website via 'plugin' tags, you can also use ReReplacer Pro.
www.regularlabs.com/extensions/rereplacer

Make a replacement that replaces something like [menu-title] (or whatever syntax you want) with this php code:

<?php echo JFactory::getApplication()->getMenu()->getActive()->title; ?>

2 months 3 weeks ago #90037

Seppi's Avatar Seppi

Dear Peter

Once again, worked like a charm! I chose Sourcerer for now as no user needs to edit this in our case.

Let me just point out once more how awesome your support and your components are! 😲 😉

Best regards
Seppi

2 months 3 weeks ago #90039

Peter van Westen's Avatar Peter van Westen Admin

Thank you and my pleasure 🙂