How to use Page Id in Opencart

六月ゝ 毕业季﹏ 提交于 2019-12-11 06:46:15

问题


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

Thanks so much Mark


回答1:


For Product.tpl

product_id

For Category.tpl

path

For Content.tpl

information_id

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   
}
?>

For security. You can use mysql_escape_string();

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.

Also, $_GET can be replaced.

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?)



来源:https://stackoverflow.com/questions/17375445/how-to-use-page-id-in-opencart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!