Zen Cart Logo
Forums / General Questions / category related banners / ads? possible?

category related banners / ads? possible?

Views: 837

Results 1 to 10 of 10
25 Jun 2011, 6:38 AM
#1
kitkitng avatar

kitkitng

New Zenner

Join Date:
Dec 2010
Posts:
44
Plugin Contributions:
0

category related banners / ads? possible?

hi

sorry for my long question below. i can't find my answer in forum search. i think some of us may also interested in the answer towards this question.

i have my shop selling few categories.

electronics, clothes, toys.

i would like to know if it's possible to make specific banners / ads shown on specific categories.

ie.
when the customer is browsing electronics, they will see Iphone, ipod banners / ads. (will see toys banners when browsing toys category)

i have my banners / ads in head, footer section and i even altered products_info_display to include banners on top of product info page. but these are all not category dependent. is there any method to show specific banners for specific categories?
try to include a IF, THEN function? CASE function?
i am not expert of PHP nor coding. please advice.

thank you.

25 Jun 2011, 4:47 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: category related banners / ads? possible?

You could build your Banner Groups with a naming convention that could be coded for to alter when the Banner Group is called ...

In the tpl_main_page.php you will see the code:

<?php
  if (SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>

SHOW_BANNERS_GROUP_SET1 holds the Banner Groups set in the Configuration ... Layout Settings ... for the:

Banner Display Groups - Header Position 1

You could customize the code so that instead of using the constant:
SHOW_BANNERS_GROUP_SET1

you build your own set(s) for your Categories ...

25 Jun 2011, 6:40 PM
#3
kitkitng avatar

kitkitng

New Zenner

Join Date:
Dec 2010
Posts:
44
Plugin Contributions:
0

Re: category related banners / ads? possible?

it's a bit too complicated for me. i am not familiar with php coding. is there other easy method?

is it possible to insert a simple IF THEN code to product_info_display.

for example,
A customer is browsing a product in category 1, i want the 1.jpg to be shown.
if he is browsing category 2, i want the 2.jpg to be shown.

the IF THEN code achieve the following
IF (get current category number=1)
Then (output <img>http://www.domain.com/1.jpg</img>)

IF (get current category number=2)
Then (output <img>http://www.domain.com/2.jpg</img>)

is it possible?

thank you for your help.

25 Jun 2011, 10:46 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: category related banners / ads? possible?

You could try this ...

Put the Categories Banner in:
/images/banners

name it:
cat1.jpg
cat10.jpg

etc. etc. etc.

Then in the tpl_main_page.php

You could use this:

<?php
// image by categories_id
$cat_banner_image = 'banners/cat' . $current_category_id . '.jpg';
$cat_banner_image = zen_image(DIR_WS_IMAGES . $cat_banner_image);
?>
<div id="bannerOne" class="banners"><?php echo $cat_banner_image; ?></div>
26 Jun 2011, 3:00 PM
#5
kitkitng avatar

kitkitng

New Zenner

Join Date:
Dec 2010
Posts:
44
Plugin Contributions:
0

Re: category related banners / ads? possible?

thank you very much for your help. it works perfectly.

i am planning to make the image clickable and redirect customer to specific url like my own facebook fans page for different categories.

i am thinking of adding a <a HREF=http://www.domain.com/<?php echo $current_category_id; ?>> code in front of the <?php echo $cat_banner_image; ?>

and by rewriting the link redirection in the .htaccess, i could redirect customers to specific url for specific banners images.

is this possible? or is there any other better method? thank you

26 Jun 2011, 3:13 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: category related banners / ads? possible?

You can manage it anyway you like ...

A better way would be to adapt it to actually use the Banner Manager and you would have more control ...

Again the images ate the same as before ...

Call the Banner Group with:
cat1
cat10
etc. etc. etc.

Change the code in the tpl_main_page.php to read:

<?php
//  if (SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
$cat_banner_group = 'cat' . $current_category_id;
  if ($cat_banner_group != '' && $banner = zen_banner_exists('dynamic', $cat_banner_group)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>
26 Jun 2011, 4:17 PM
#7
kitkitng avatar

kitkitng

New Zenner

Join Date:
Dec 2010
Posts:
44
Plugin Contributions:
0

Re: category related banners / ads? possible?

your method is much much better. very smart.
every settings could be controlled in the banner manager instead of changing the php file and .htaccess file.

and may i know what's the variable for parent category id? which is one level up the $current_category_id
there are too many category to handle, i would try to use one level up the current category.

thank you.

26 Jun 2011, 4:48 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: category related banners / ads? possible?

If you want the Top Level, you can try:
$cat_banner_group = 'cat' . (int)$cPath;

If you want the parent_id of the current category you can try:
$cat_banner_group = 'cat' . zen_categories_lookup($current_category_id, 'parent_id');

26 Jun 2011, 5:28 PM
#9
kitkitng avatar

kitkitng

New Zenner

Join Date:
Dec 2010
Posts:
44
Plugin Contributions:
0

Re: category related banners / ads? possible?

thank you again Ajeh.
thank you for your great help and patient.

26 Jun 2011, 5:37 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: category related banners / ads? possible?

Sure thing ... glad you have this working now ...