我正在尝试使Joomla模板中的JavaScript的行为根据页面而有所不同.特别是,我已经设置了关键参考,是我可以为此目的找到的最合适的值.不幸的是,我似乎无法在代码中访问它.我试过了:
I am trying to enable JavaScript in a Joomla template to behave differently depending on the page. In particular, I have set the Key Reference as that appears to be the most appropriate value I could find for this purpose. Unfortunately, I can't seem to access it in my code. I tried:
$this->params->get("keyref")和其他一些变体,但它们只是返回了一个空白.如何获取该值,或者有没有更好的方法来编写页面特定的逻辑.
and a few other variations, but they simply returned a blank. How can I retrieve this value or is there a better way of writing page specific logic.
相关文章
- 在特定页面中加载Joomla脚本:这可以工作,但似乎对我在这里想要做的事有些过分.
- Joomla load script in a specific page: This would work, but seems like overkill for what I want to do here.
可以为每个页面提供别名.我们可以使用论坛中的代码检索别名: /p>
Each page can be given an alias. We can retrieve the alias using code from the forum:
function getCurrentAlias() { $menu = &JSite::getMenu(); $active = $menu->getActive(); return $active->alias; }然后我们可以将其注入Javascript:
We can then inject this into the Javascript:
var alias= '<?php echo getCurrentAlias(); ?>';更多推荐
Joomla中特定于页面的逻辑
发布评论