如何在Opencart中使用页面ID [英] How to use Page Id in Opencart

查看:98
本文介绍了如何在Opencart中使用页面ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Opencart模板中的页面ID仅显示该特定页面的内容?还是类似的东西?

How can I use the id of a page in a Opencart template to show content only for that specific page? Or something similar?

非常感谢 标记

推荐答案

对于Product.tpl

product_id

对于Category.tpl

path

对于Content.tpl

information_id

编辑这些.tpl文件,并使用我已陈述的变量.您可以在.tpl文件中实践使用该文件,例如:

Edit those .tpl files and use the variables I have stated. You can use in practice in the .tpl files like:

<?
if(isset($_GET["product_id"])==""){
 // yes
} else {
 // do something else   
}
?>

为了安全起见.您可以使用 mysql_escape_string();

For security. You can use mysql_escape_string();

您还可以在某些情况下使用该库.我相信这是您想要的Content.tpl中的示例.我建议不要进行此类更改.制定模块或更合理的逻辑.

You can also use the library in certain instances. Example in Content.tpl which I believe is the issue you want. I recommend against changes like this. Make modules or better logic.

此外,$ _ GET可以替换.

Also, $_GET can be replaced.

请注意,$this->request->get$_GET相同,但是在使用SEO关键字时,OpenCart可以并且通常在页面加载后更改$this->request->get中的值,例如路由键值,因此建议使用而不是$_GET而不是$_GET.它还清除了值以防止任何恶意值. (参考Jay: Opencart:如何在某些页面?)

Note that $this->request->get and $_GET are the same, however OpenCart can and usually does change values in $this->request->get after the page load for things like the route key value when using SEO keywords, therefore its advisable to use that instead of $_GET instead of $_GET. It also has the values cleaned to prevent any malicious values. (Reference Jay: Opencart: How to include a script on certain pages?)

这篇关于如何在Opencart中使用页面ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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