简体   繁体   中英

How do I use Joomla article variables inside modules?

For getting the article alias of the current/active article, I can use

<?php echo $article->alias;?>

This will work fine if I put that code inside the article itself. However when I put this code inside a Joomla module, it echos nothing; Not even when I insert the module inside the article itself (with Modules Anywhere from Regular Labs).

How can I make use of the Joomla variables (or this one in particular) within a module?

Many thanks!

For now I have found an alternate solution that seems to give me the desired result.

<?php $alias=basename($_SERVER['REQUEST_URI']);?>

<?php echo $alias;?>

This apparently returns the last part of an URL string (everything behind the last slash).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM