Joomla中特定于页面的逻辑 [英] Page-specific logic in Joomla

查看:133
本文介绍了Joomla中特定于页面的逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使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 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中特定于页面的逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆