Add position to theme OpenCart 1.5.1.1
Many of your questions why OpenCart no more locations to place the module in the theme like joomla or simply need more position (position) than the default only “content top”, “content bottom”, “column right “,” column left “. This article will guide and explain how to get more position.
What you need to know is:
– I should start by saying that I am not an expert OpenCart. So, I’m not sure this works with older versions of OpenCart 1.5.1.1.
– The changes in this guide is made to change the contents of files that may be overwritten when you upgrade or update to a new version of OpenCart future.
Began:
First you download and install the free module Hildebrando Youtube OpenCart v1.5.1.1. I chose this mod mainly because it was highly relevant and not so much in the back-end functions. I suppose you could change any components similar.
1. Add position in admin (administration)
First, you need to edit the language file of the module in / admin / language / english / modules / s_youtube.php and added to your new position. For this tutorial we will be adding a new position called: Content Middle.
[Codesyntax lang = “php”]
$ _ [‘Text_content_middle’] = ‘Content Middle’;
[/ Codesyntax]
Second, you need to edit the the admin module template file in the / admin / view / template / modules / s_youtube.tpl and add a “position”.
– Add the following code:
[Codesyntax lang = “php”]
“><? Php if ($ module [‘position’] == ‘content_middle’) {?>
“>
<? php echo $ text_content_middle;?> “><? Php} else {?>
“>
<? php echo $ text_content_middle;?> “><? Php}?>
[/ Codesyntax]
on the bottom line:
[Codesyntax lang = “php”]
<? php echo $ text_content_bottom;?> ‘;[/ Codesyntax]Third, you need to edit the file’s controller module in / admin / controller / modules / s_youtube.php and add a new line anywhere around 35.Add the line:[Codesyntax lang = “php”]data[‘text_content_middle’] = $this->language->get(‘text_content_middle’);”>$ This-> data [‘text_content_middle’] = $ this-> language-> get (‘text_content_middle’);[/ Codesyntax]on the following lines:[Codesyntax lang = “php”]data[‘text_content_bottom’] = $this->language->get(‘text_content_bottom’);”>$ This-> data [‘text_content_bottom’] = $ this-> language-> get (‘text_content_bottom’);[/ Codesyntax]Now you can see the new location in your module settings. Also you need to make sure that the layout of the module is set to “Home”.2. Add position to your themeFirst, you must add the location of the array in / catalog / controller / common / home.phpAdd the line:[Codesyntax lang = “php”]’Common / content_middle’,[/ Codesyntax]on the following lines:[Codesyntax lang = “php”]’Common / content_bottom’,[/ Codesyntax]Second, you need to create the corresponding PHP files in the / catalog / controller / common / (for example: “content_middle.php”). Add the following code, pay attention to the lines 2, 50, 79, 80, and 82) will need to reflect your position:[Codesyntax lang = “php”]<? Phpclass ControllerCommonHomeOne extends Controller { public function index () { load->model(‘design/layout’);”>$ This-> load-> model (‘design / layout’); load->model(‘catalog/category’);”>$ This-> load-> model (‘catalog / category’); load->model(‘catalog/product’);”>$ This-> load-> model (‘catalog / product’); load->model(‘catalog/information’);”>$ This-> load-> model (‘catalog / information’); request->get[‘route’])) {“>if (isset ($ this-> request-> get [‘route’])) { request->get[‘route’];”>$ Route = $ this-> request-> get [‘route’]; } Else { $ Route = ‘common / home’; } $ Layout_id = 0; request->get[‘path’])) {“>if (substr ($ route, 0, 16) == ‘product / category’ && isset ($ this-> request-> get [‘path’])) { request->get[‘path’]);”>$ Path = explode (‘_’, (string) $ this-> request-> get [‘path’]); model_catalog_category->getCategoryLayoutId(end($path));”>$ Layout_id = $ this-> model_catalog_category-> getCategoryLayoutId (end ($ path)); } request->get[‘product_id’])) {“>if (substr ($ route, 0, 15) == ‘product / product’ && isset ($ this-> request-> get [‘product_id’])) { model_catalog_product->getProductLayoutId($this->request->get[‘product_id’]);”>$ Layout_id = $ this-> model_catalog_product-> getProductLayoutId ($ this-> request-> get [‘product_id’]); } request->get[‘information_id’])) {“>if (substr ($ route, 0, 23) == ‘information / information’ && isset ($ this-> request-> get [‘information_id’])) { model_catalog_information->getInformationLayoutId($this->request->get[‘information_id’]);”>$ Layout_id = $ this-> model_catalog_information-> getInformationLayoutId ($ this-> request-> get [‘information_id’]); } if (! $ layout_id) { model_design_layout->getLayout($route);”>$ Layout_id = $ this-> model_design_layout-> getLayout ($ route); } if (! $ layout_id) { config->get(‘config_layout_id’);”>$ Layout_id = $ this-> config-> get (‘config_layout_id’); } $ Module_data = array (); load->model(‘setting/extension’);”>$ This-> load-> model (‘setting / extension’); model_setting_extension->getExtensions(‘module’);”>$ Extensions = $ this-> model_setting_extension-> getExtensions (‘module’); foreach ($ extensions as $ extension) { config->get($extension[‘code’] . ‘_module’);”>$ Modules = $ this-> config-> get ($ extension [‘code’]. ‘_module’); if ($ modules) { foreach ($ modules as $ module) { if ($ module [‘layout_id’] == $ layout_id && $ module [‘position’] == ‘home_one’ && $ module [‘status’]) { $ Module_data [] = array ( $extension[‘code’],”>’Code’ => $ extension [‘code’], $module,”>’Setting’ => $ module, $module[‘sort_order’]”>’Sort_order’ => $ module [‘sort_order’] ); } } } } $ Sort_order = array (); $value) {“>foreach ($ module_data as $ key => $ value) { $ Sort_order [$ key] = $ value [‘sort_order’]; } array_multisort ($ sort_order, SORT_ASC, $ module_data); data[‘modules’] = array();”>$ This-> data [‘modules’] = array (); foreach ($ module_data as $ module) { getChild(‘module/’ . $module[‘code’], $module[‘setting’]);”>$ Module = $ this-> getChild (‘modules /’. $ Module [‘code’], $ module [‘settings’]); if ($ module) { data[‘modules’][] = $module;”>$ This-> data [‘modules’] [] = $ module; } } config->get(‘config_template’) . ‘/template/common/home_one.tpl’)) {“>if (file_exists (DIR_TEMPLATE. $ this-> config-> get (‘config_template’). ‘/ template / common / home_one.tpl’)) { template = $this->config->get(‘config_template’) .”>$ This-> template = $ this-> config-> get (‘config_template’). ‘/ Template / common / home_one.tpl’; } Else { template = ‘default/template/common/home_one.tpl’;”>$ This-> template = ‘default / template / common / home_one.tpl’; } render();”>$ This-> render (); }}”>?>[/ Codesyntax]Third, create the corresponding file in the / view / theme / your-theme / template / common / (eg: “content_middle.tpl” TPL). Add the following code:”><? Php foreach ($ modules as $ module) {?>”><? Php echo $ module;?>”><? Php}?>Now, you can call insert your position wherever your in theme home.tpl file by calling[Codesyntax lang = “php”]”><? Php echo $ content_middle;?>[/ Codesyntax]