Hi,
I am just wondering if it is possible to show Feature Product Sidebox on other pages but not on the main page? Is there a button where I can simply turn it off? Please let me know. Thanks.
Best regards,
Ethan
Printable View
Hi,
I am just wondering if it is possible to show Feature Product Sidebox on other pages but not on the main page? Is there a button where I can simply turn it off? Please let me know. Thanks.
Best regards,
Ethan
You can customize the side box to disable when the variable:
$this_is_home_page
is true ...
Hi Ajeh,
Thanks for your quick response. Where do I find the variable $this_is_home_page? I got no luck using the Developers Tool Kit. Please let me know. Thanks again.
Best regards,
Ethan
Sorry this was new in v1.3.5 ... and updated in v1.3.6 ...
I just realized you are v1.2.7 ...
You can download a v1.3.6 and see how this is done to cover all the possible settings for determining a true home page ...
It will be something like this that you could use:
PHP Code:
$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );
Hi Ajeh,
Thanks for your reply. It sounds complicated. Can you provide me with more instructions?
Regards,
Ethan
Add that to the top of the sidebox ...
When $this_is_home_page is true then you do not want to show the sidebox ...
NOTE: this is already built into v1.3.6 and above ... so you will not need it in the sidebox when you upgrade ...
the /includes/modules/sideboxes/featured.php already has in it:
When $show_featured is true the sidebox shows ...Quote:
// test if box should display
$show_featured= true;
NOTE: there is a second check following the select of the featured products for whether or not there is "something" to show ... you only care if you are on the main page, from there the sidebox can run normally ...
So below the
$show_featured = true;
You could add the code:
NOTE: This is written in two lines so that you can find it easily in the future for upgrading ...PHP Code:
$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );
$show_featured = $this_is_home_page;
What this will do is turn on/off the featured sidebox based on if you are on the home page or not ...
Hi Ajeh,
I took your suggestion to add the following code under $show_featured= true;
$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );
$show_featured = $this_is_home_page;
However, the Featured Product Sidebox still shows up on the homepage. What did I miss?
Regards,
Ethan
You just set $show_featured to true on the main page ... so it shows ... :eek:
You need it the other way ...
Now when the it is the main page, this is false and when not the main page it is true ...PHP Code:
$show_featured = !$this_is_home_page;
When false it is skipped and when true it runs ...
Got all that? :lamo:
Hi Ajeh,
Thanks for getting back to me. Sorry, I am afraid I need more help as I am not familar with php code. There are two $show_featured, which one did you refer to? Do you mean to change this code from:
$show_featured= true;
$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );
$show_featured = $this_is_home_page;
to this code:
$show_featured= false;
$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );
$show_featured = $this_is_home_page;
OR to this code:
$show_featured= !$this_is_home_page;
$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );
$show_featured = $this_is_home_page;
I try all these and none of them work. Please help. Thanks again.
Best regards,
Ethan
You are setting $show_featured to false ...PHP Code:
$show_featured= false;
$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );
$show_featured = $this_is_home_page;
Then you setting the main page value to $this_is_home_page ...
Then you are setting the results to $show_featured but you want the opposite result ...
When main page do not show, as in: !$this_is_home_page meaning if I am the home page, don't show, so I need to be false ... !true is false ...
So the results would be:
PHP Code:
if (true) {
// show box
}
Hi Ajeh,
So are you saying the correct code I should use is:
$show_featured= false;
$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );
$show_featured = !$this_is_home_page;
if (true) {
// show box
}
Is that it? If not, can you give me the "cut and paste" code to make my life easier? :) Thanks for your patience. Much appreciated.
Regards,
Ethan
Old Code:
New Code:PHP Code:
// test if box should display
$show_featured= true;
if ($show_featured == true) {
PHP Code:
// test if box should display
$show_featured= true;
$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );
$show_featured = !$this_is_home_page;
if ($show_featured == true) {
Hi Ajeh,
I tried the new code but the Feature sidebox is still showing on the main page I am afraid. What should I do now?
Regards,
Ethan
Do you have an override for the file:
/includes/modules/sideboxes/featured.php
in your overrides directory?
/includes/modules/sideboxes/your_template_dir/featured.php
Are you changing the right file?
Hi Ajeh,
Thank you. I got that to work now :)
I also want to turn off the New Product Sidebox on the main page. Do I apply the same principle? I had a look at the file and the coding is slightly different. Not sure how to fit the code you gave me in there.
Regards,
Ethan
On the new products sidebox ... you need to add an IF around the whole code ...
This is not using the:
But you could add one similar to the featured for:PHP Code:
if ($show_something) {
And build the $show_whats_new in the same manner ...PHP Code:
if ($show_whats_new == true) {
// all code here
}
Hi Ajeh,
Thanks very much :) It worked. Magic!
Regards,
Ethan
You are most welcome ... glad you are starting to get the hang of this now ... :smile:
Hi,
I am looking for a solution similar to this issue.
Is there a flag like $show_featured for the information box? I don't see any test to show the information box in any of the information box pages. I want to hide the information box on all pages except one ez page. The original post is located here:
http://www.zen-cart.com/forum/showthread.php?t=51520
If I could just grab the flag to show/hide the info box, then I should be set.
Any help would be great! Thanks.
You can build an IF surrounding the code for any of the sideboxes to test any condition you like ...
PHP Code:
$some_condition_here = something_is_evaluated;
if ($some_condition_here == true) {
// code here
}
Can this be applied for Categories box?
Axel
You can control all sideboxes by setting a given condition and just not letting it run ...
Same holds true of any page, column, centerbox, etc.
That is the beauty of being able to customize the code ... just need to find the trigger to manage the element that you are trying to control ... :cool:
Hi there,
Just did what was suggested in that thread, it works great.
I have a question though: I'd rather not touch the code that is not in MY_TEMPLATE.
Is there any suggestion to be able to do the same thing as changing into modules/incription.php (example given) but to keep this change in MY_TEMPLATE?
I've modified the tpl_information.php with the if statement suggested here , but the header of "information" still appears. (which is logical). Anyway to pick up whatever sidebox you want for different pages/ categories without touching the core code?
THanks!
cristele
Copy the file and place it within your template folder beneath modules/.
Use:
modules/MY_TEMPLATE/incription.php
Then you can modify that code without worrying about messing up the core file.
Keep in mind that whereever you see a classic folder, you can place your own folder with the same name as MY_TEMPLATE to override the core files, without modifying core files.
The file should be located in /includes/modules/MY_TEMPLATE/[somefile.php]
This file will override the default file located in /includes/modules
Keep in mind that whereever you see a classic folder, you can place your own folder with the same name as MY_TEMPLATE to override the core files, without modifying core files.
That's very cool....works like a charm:cool:
This is the coolest feature about ZenCart!
It's a fantastic template override system.
It's important that you don't modify core files.. you should always use template override. Just create a folder in the appropriate directory called MY_TEMPLATE (use the real name of your template) and copy the default files into it. You can modify those files. If you screw it up royally, you can remove your override file, and the cart will use the defualt files again.
See this link for some more info, and try some other searches in the tutorials or wiki
https://www.zen-cart.com/tutorials/index.php?article=36
I have really tried to follow this thread, copying and pasting and testing and ...... getting nowhere except very frustrated.
I downloaded the blank_sidebox.php. Renamed it to colour_sidebox.php
into the 3 relevant folders as per the instructions.
I am using override of merlin/. on the admin/tools/layout boxes controller I have turned on the sidebox.
It now shows on all pages. However, I do not want it to show on the home page.
What code do I use please and where do I put it.. Polite responses please..
Thank you in anticipation
Bump !
Following on from the above, I have changed my code to the following.
The Colours side box still shows on the main page. Any ideas please..
I have tried changing the false to true, but nothing happens
// test if box should display
$show_colour_sidebox = false;
$this_is_home_page = $($current_page== 'sideboxes');
$show_colour_sidebox = !$this_is_home_page;
if ($show_colour_sidebox == true) {
require($template->get_template_dir('tpl_colour_sidebox.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_colour_sidebox.php');
$title = BOX_HEADING_COLOUR_SIDEBOX;
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}
?>
If I were to do this to the Featured sidebox ... I would copy the code to the proper templates and overrides and edit the file to change:
To read:PHP Code:
// test if box should display
$show_featured= true;
Now the condition is based on the existing $this_is_home_page and only shows when false or !$this_is_home_pagePHP Code:
// test if box should display
// $show_featured= true;
$show_featured = !$this_is_home_page;
So more or less you are using:
And should be using:PHP Code:
// test if box should display
$show_colour_sidebox = false;
$this_is_home_page = $($current_page== 'sideboxes');
$show_colour_sidebox = !$this_is_home_page;
Note: commenting out the:PHP Code:
// test if box should display
// $show_colour_sidebox = false;
$show_colour_sidebox = !$this_is_home_page;
is just to eliminate confusion ... whether or not it is commented out is is reset by the next line:PHP Code:
// $show_colour_sidebox = false;
Easy smeasy, eh? :cool:PHP Code:
$show_colour_sidebox = !$this_is_home_page;
Hi Linda
I wish it was so easy.
This is the code I now have.
// test if box should display
$show_colour_sidebox = !$this_is_home_page;
if ($show_colour_sidebox == true) {
require($template->get_template_dir('tpl_colour_sidebox.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_colour_sidebox.php');
$title = BOX_HEADING_COLOUR_SIDEBOX;
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}
?>
this code resides in ..includes\modules\MY_TEMPLATE_NAME\colour_sidebox.php
Unfortunately the colour side box still shows on the main page.
This is the only colour_sidebox.php file that I have on the system. So I must be missing something else.
thank you for your prompt reply..
I will get the hang of this.......
Add this just before the IF statement in your sidebox:
Then look where you should see the sidebox and tell me what it reads ... :smile:PHP Code:
echo 'I SEE ' . ($this_is_home_page == true ? "Lucy I'm Home!" : "Rick? Where are you");
Hi I have added the code as suggested and all I get is the side box
no other description...
I am running V 1.3.7
Have you an URL to your site and do you have the sidebox currently show on your site?
And your code looks like what now?
Hi Linda
Sorry. I am working on localhost, building the site, as I am already live with a HTML site at www.merlinmounts.co.uk...
I know this is not the ideal solution, but I am sure you are aware it is the easiest option. - until that is.. one gets problems...
This is my code that I have in...
store\includes\modules\merlin\colour_sidebox.php.
merlin is my override folder..
Basically I downloaded the Blank_sidebox 2 from the site. Changed all occurences of blank_sidebox to my own name of colour_sidebox in the 3 override folders.
// test if box should display
// $show_colour_sidebox = false;
// $this_is_home_page = $($current_page== 'sideboxes');
$show_colour_sidebox = !$this_is_home_page;
echo 'I SEE ' . ($this_is_home_page == true ? "Lucy I'm Home!" : "Rick? Where are you");
if ($show_colour_sidebox == true) {
require($template->get_template_dir('tpl_colour_sidebox.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_colour_sidebox.php');
$title = BOX_HEADING_COLOUR_SIDEBOX;
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}
?>
To help me understand. could you please explain briefly where the term
$this_is_home_page
comes from. Is it an actual name of a page?
Sorry to add to the above.
Is it the same as $this_is_main_page.php
$this_is_home_page is a variable set when the main page is resolved to the actual "home" page of your site to distinguish between all of the other pages ...
You can find where it is set by going to the Developers Tool Kit in your Admin under the Tools menu ...
Enter it in the bottom input box and select Catalog/Admin and click search ...
You will see where there is a:
$this_is_home_page = blah blah blah
Now, if you do not find this ... then you have files out of date from an upgrade issue ...
I am really surprised that you are not seeing Lucy or Ricky on this as one or the other should be showing ...
Are you sure you are editing the right file?
hi, i have a similar issue -- i am trying to get my featured product sidebox to display on the right side, but no matter what i do, it won't show. this is what i currently have in my /public_html/includes/templates/12541/sideboxes/tpl_featured.php file. /tpl_featured had to be copied from the default template folder because it did not exist in my modified template (12541).
my website is: http://www.indiediggs.com
<?php
/**
* Side Box Template
*
* @package templateSystem
* @copyright Copyright 2003-2007 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_featured.php 6128 2007-04-08 04:53:32Z birdbrain $
*/
$content = "";
$featured_box_counter = 0;
while (!$random_featured_product->EOF) {
$featured_box_counter++;
$featured_box_price = zen_get_products_display_price($random_featured_product->fields['products_id']);
$content .= '<div class="sideBoxContent centeredContent">';
$content .= '<a href="' . zen_href_link(zen_get_info_page($random_featured_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_featured_product->fields["master_categories_id"]) . '&products_id=' . $random_featured_product->fields["products_id"]) . '">' . zen_image(DIR_WS_IMAGES . $random_featured_product->fields['products_image'], $random_featured_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
$content .= '<br />' . $random_featured_product->fields['products_name'] . '</a>';
$content .= '<div>' . $featured_box_price . '</div>';
$content .= '</div>';
$random_featured_product->MoveNextRandom();
}
?>
also, how do i change the "manufacturer" section to read "designer"? as seen here -- http://www.templatemonster.com/sampleView.php?type=16
btw: please explain in very elementary terms. i'm very new at this!! thx.
Hi Linda
I am most impressed by your patience and help given.
I went back to basics and installed the blank-sidebox package again.
Using your help and coding from earlier in the thread It now Works. :smile:
I am using the following code....
// test if box should display
$show_blank_sidebox = true;
$show_blank_sidebox = !$this_is_home_page;
//echo 'I SEE ' . ($this_is_home_page == true ? "Lucy I'm Home!" : "Rick? Where are you");
if ($show_blank_sidebox == true) {
require($template->get_template_dir('tpl_blank_sidebox.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_blank_sidebox.php');
$title = BOX_HEADING_BLANK_SIDEBOX;
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}
?>
Once again thankyou for your help. Will call on you again.
Glad to hear you have this working now ... thanks for the update! :smile:
hi, i want the special sidebox to show on product page only, how do i modify the codes? :smile:
As the logic on the specials sidebox is the opposite, where it shows everywhere except the product _info page ... you need to reverse the logic ...
Using your templates and overrides ... I always copy both pieces of a sidebox to the overrides so I don't confuse myself ... you can change the code:
to read the opposite:Code:if (isset($_GET['products_id'])) {
$show_specials= false;
} else {
$show_specials= true;
}
Code:if (isset($_GET['products_id'])) {
$show_specials= true;
} else {
$show_specials= false;
}
thanks linda :clap:
another question, i have links manager and blank sidebox installed, on my links page and links submit page, i only want to show links sidebox and blank sidebox. do i have to modify all of my other sidebox files such as specials, whats new, featured, category, currency ... ? or i could just modify the files of links manager ? how do i make it done?
If you want other sideboxes to not show based on some condition, you would want to clone the concept of how the specials sidebox is managed to show or not show ...