[英]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;
但是,当我将此代码放入Joomla模块中时,它没有回显任何内容。 Not even when I insert the module inside the article itself (with Modules Anywhere from Regular Labs).
甚至当我将模块插入到文章本身中时(常规实验室的Modules Anywhere也没有)。
How can I make use of the Joomla variables (or this one in particular) within a module? 如何在模块中使用Joomla变量(特别是这个变量)?
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). 显然,这将返回URL字符串的最后一部分(最后一个斜杠后面的所有字符)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.