OpenCart中的自定义助手功能 [英] Custom helper functions in OpenCart
本文介绍了OpenCart中的自定义助手功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试在opencart中创建自定义PHP函数.基本上,我需要知道我们是在查看购物车页面还是在结帐页面.我知道最简单的方法是访问路由请求参数.我想创建一个可重用的功能,但是该功能在整个站点范围内都可用.
Trying to create a custom PHP function within opencart. Basically I need to know if we are viewing the cart or checkout pages. I understand the simplest way to accomplish this is by accessing the route request param. I want to create a re-usable function however that is available site wide.
这可能吗?它会去哪里?
Is this possible? Where would it go?
该函数看起来像这样:
function isCheckout() {
$route = $this->request->get['route'];
//is cart?
if($route == 'checkout/cart')
return 'cart';
$parts = explode('/', $route);
if($parts[0] == 'checkout')
return 'checkout';
return false;
}
推荐答案
将您的帮助文件放在系统目录的帮助文件夹中
Put your helper file inside a helper folder inside a system directory
system/helper/myhelper.php
并将其包含到
system/startup.php
文件
像这样
require_once(DIR_SYSTEM . 'helper/myhelper.php');
您已经完成.
这篇关于OpenCart中的自定义助手功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文