Joomla中特定于页面的逻辑

编程入门 行业动态 更新时间:2024-10-28 07:31:27
本文介绍了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脚本:这可以工作,但似乎对我在这里想要做的事有些过分.
  • 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中特定于页面的逻辑

本文发布于:2023-10-30 00:11:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541181.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中特   逻辑   页面   Joomla

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!