Page 1 of 1

Show module on all pages

Posted: Thu Jun 13, 2013 12:06 pm
by ryan_pl
I hope this helps somebody. This has been tested on v1.5.5.1

Steps:
1. Create a new Layout at admin > system > design > layout and name it 'All Pages'

2. On catalog > model > design > layout.php, add the ff:

Code: Select all

public function getLayoutForAllPages()
{
	$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout
		WHERE name like '%all pages%'
		LIMIT 1");

	if ($query->num_rows) {
		return $query->row['layout_id'];
	} else {
		return 0;
	}
}
3. There are four default positions - column_left, column_right, content_top and content_bottom. We need to edit the controller files for those positions in the catalog.

Here are the steps for the column left position

a. open /catalog/controller/common/column_left.php:

b. look for

Code: Select all

$module_data = array();
in the index function (at line 39) and add this before that line:

Code: Select all

$all_pages_layout_id = $this->model_design_layout->getLayoutForAllPages();
c. look for

Code: Select all

if ($module['layout_id'] == $layout_id && $module['position'] == 'column_left' && $module['status']) {
(line 50) and replace it with this line:

Code: Select all

if (($module['layout_id'] == $layout_id || $module['layout_id'] == $all_pages_layout_id) && $module['position'] == 'column_left' && $module['status']) {
Do the same steps for the other three positions.

4. Go to admin > extension > modules, select the module you want to display on all pages and set the Layout to 'All Pages' .

Attached is the vqmod for all code changes

Re: Show module on all pages

Posted: Sun Jun 30, 2013 4:10 am
by acesfp
will try your method in another opencart site, thanks for your share!

Re: Show module on all pages

Posted: Sat Jul 13, 2013 11:56 pm
by nnnhi
it may works for version 1.5.4.1 non vay your

Re: Show module on all pages

Posted: Mon Jul 15, 2013 9:25 pm
by tora
ryan_pl wrote:I hope this helps somebody. This has been tested on v1.5.5.1
......
Thanks for sharing this useful bit of code. Do you know how to make it work separately for multi-store?
Currently it works on all pages regardless of the store. What I want to achieve is have a separate "all pages" layout for each store. With other layouts, we can use the layouts for each store by using different routes. Any idea on how to do this for all pages?

Re: Show module on all pages

Posted: Sat Jul 20, 2013 8:24 pm
by rajithg
perfect solution.. We too checked your solution on v1.5.5.1 and its working smoothly.. 8) 8)

Re: Show module on all pages

Posted: Fri Aug 02, 2013 8:01 pm
by dariogene
Thanks for sharing this code, really useful and should be a native feature.
I'm using 1.5.4 and to get it to work, you have to make sure that the LIKE string (e.g. "All Pages") in the query matches the name you give the layout in the admin i.e. it is case sensitive.

This don't work

Posted: Tue Aug 20, 2013 9:51 pm
by yapjj1214
Hi, I tested this but I failed. Is the vqmod essential? I installed vqmod and added the xml but still failed. Is it I need to reinstall vqmod?

Re: Show module on all pages

Posted: Mon Sep 09, 2013 1:54 am
by fabius
works perfect on oc 1.5.5.1, why don't you publish this solution in the extensions section?

Re: Show module on all pages

Posted: Sat Nov 16, 2013 8:53 pm
by thazer
Work's perfectly on Opencart 1.5.1.3 (i've tested the manual version, not the VQmod, but they are the same) with only one issue: You must add the layout with lowercase on PHP 5.3 as 'all pages' is not exactly like "All Pages" (as you pointed out in the post).

Anyways - THANK YOU!

Re: Show module on all pages

Posted: Sun Nov 17, 2013 7:49 pm
by bevang
I registered just for this post to thank you so much for this. Saved me sooo much time. Appreciate the effort to write up your solution. I can't believe it's not a standard feature for such a common site design!

Re: Show module on all pages

Posted: Sun Jan 12, 2014 5:14 pm
by bevang
For anyone reading this, is there a way to have a module show on all pages except the home page? I've tried playing around with the 'if' statement in the column_right, left, top, bottom with no luck. Also tried editing home.tpl but it doesn't recognise the $all_pages_layout_id variable.

Re: Show module on all pages

Posted: Sat Feb 14, 2015 5:28 pm
by sunsys
@bevang,

Sir will this xml work with OC-1.5.6.4

TY

Re: Show module on all pages

Posted: Tue Mar 17, 2020 2:35 pm
by Erielama
Someone please share how to do this in V 3.0.3.2

Re: Show module on all pages

Posted: Thu Mar 19, 2020 11:28 pm
by IP_CAM

Re: Show module on all pages

Posted: Thu Oct 15, 2020 2:20 pm
by joanneli
Hiiii,

Do you know how to make it work separately for multi-store?
Thanks for sharing this bit code.