opencart2.x

OpenCart 2: Show all subcategories in category module by default (php)

£可爱£侵袭症+ 提交于 2019-12-07 15:14:27
问题 Really need your help to make this work. I'm using OpenCart 2.0.3.1 and I want the sidebar category module to show all subcategories of all categories by default. Currently the module shows subcategories only when you click on a category and it shows subcategories only of that category. You can have a look at it in action: http://demo.opencart.com/index.php?route=product/category&path=20 (it's the module on left sidebar) I'm just using the default module. I tried many different ways to get

How to setting global variables in OpenCart 2.3.0.2?

旧巷老猫 提交于 2019-12-07 12:32:11
问题 When I want to set a global variable in template ( .tpl files), I just use global in opencart 2.2 or older version. For example: <?php global $config; if($config->get('my_options')== 1) { ?>....<?php } ?> but, it does not work in Latest OpenCart 2.3.0.2 Because predefined global $config in controller rather inconvenient (we have use config value in many template file). Hopefully someone with more experience will have an answer to this problem. 回答1: The least code you will get defining them as

How can we use opencart events?

旧街凉风 提交于 2019-12-06 21:38:21
问题 I have searched a lot about opencart triggers but didn't find a proper example. In opencart 2.0 there are triggers on which developer can hook function and perform something just like wordpress action and filters i guess. For example in catalog/model/checkout/order.php there is a trigger $this->event->trigger('post.order.history.add', $order_id) Can someone help me to hook my function on the above trigger? 回答1: Important Note: this answer applies to OC >2.0.x.x and <2.2.x.x. The problem here

Accessing class properties and methods from template

一笑奈何 提交于 2019-12-06 15:26:37
Prior to Opencart 2.0 class properties could be accessed directly from the template. For example, $this->config->get('config_language') or $this->request->get['route'] were both accessible from an admin template file. With the new method $this->load->view() , neither of these work. Is there a simple way to pass on class methods and properties which are available in the current controller to the tpl without explicitly adding them to the $data array? Nikhil Chaudhary In Opencart version 2, if you want these variables then you can easily access them. There is slight change is code, now you can

Display block HTML only on main page?

旧时模样 提交于 2019-12-06 08:21:33
I tried to modify home controller adding new variable: $data["header_home"] = true; Then I try to check this in header.twig tetmplate like as: {% if header_home %} <div>Home</div> {% else %} <div>Not Home</div> {% endif %} When I open home page by index.php or just url address it does not work, I mean I dont see <div>Home</div> . How to fix it, what do wrong? This is home controller: <?php class ControllerCommonHome extends Controller { public function index() { $this->document->setTitle($this->config->get('config_meta_title')); $this->document->setDescription($this->config->get('config_meta

OpenCart 2: Show all subcategories in category module by default (php)

佐手、 提交于 2019-12-05 19:59:07
Really need your help to make this work. I'm using OpenCart 2.0.3.1 and I want the sidebar category module to show all subcategories of all categories by default. Currently the module shows subcategories only when you click on a category and it shows subcategories only of that category. You can have a look at it in action: http://demo.opencart.com/index.php?route=product/category&path=20 (it's the module on left sidebar) I'm just using the default module. I tried many different ways to get this work and nothing helped to achieve this. I know that I need to edit these two files: catalog

Best way to modify OpenCart without touching Core and VQMOD/OCMOD

末鹿安然 提交于 2019-12-04 08:09:50
Is there a better way then using VQMOD / OCMOD to change OpenCart's core files? Is there some "overrides" folder exists so that I can simply create any PHP file corresponding to the file structure and simply override a core file? (Like it is possible in PrestaShop and Magento ). VQMOD / OCMOD is highly inconvenient. Does someone use any hacks & tricks to achieve the result? I don't want to touch any core files to keep the system clean and manageable. Thanks a lot! If you want to call your function within the system which follows the OC structure, avoid the search/replace mods, try using the

Specific template for category and product page in OpenCart 2.2.0.0

柔情痞子 提交于 2019-12-02 18:39:30
问题 I am using OpenCart version 2.2.0.0 and trying to set different template for each category and product page. Searching online I found following code: if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category_' . $category_id . '.tpl')) { $this->template = $this->config->get('config_template') . '/template/product/category_' . $category_id . '.tpl'; } elseif (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category

Adding New Modules Positions to OpenCart 2

情到浓时终转凉″ 提交于 2019-12-02 15:50:42
问题 I want to add more Positions for modules. How can I add a new module position in opencart 2? Here, I like this information. but, it is work only for OpenCart older version. http://www.opencartnews.com/tutorials/adding-new-modules-positions/ How can the same thing be achieved in Opencart 2? Please help...! 回答1: You can achieve this by modifying the following core file. admin/view/template/design/layout_form.tpl add your new position in this select tag <select name="layout_module[<?php echo

Adding New Modules Positions to OpenCart 2

て烟熏妆下的殇ゞ 提交于 2019-12-02 11:11:55
I want to add more Positions for modules. How can I add a new module position in opencart 2? Here, I like this information. but, it is work only for OpenCart older version. http://www.opencartnews.com/tutorials/adding-new-modules-positions/ How can the same thing be achieved in Opencart 2? Please help...! Kishore Kumar You can achieve this by modifying the following core file. admin/view/template/design/layout_form.tpl add your new position in this select tag <select name="layout_module[<?php echo $module_row; ?>][position]" and also in this method at the bottom of the file function addModule(