Emiel
Emiel

Reputation: 33

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!

Upvotes: 0

Views: 253

Answers (1)

Emiel
Emiel

Reputation: 33

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).

Upvotes: 0

Related Questions