Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Different Banner for Different category


juniorprg

Recommended Posts

Posted

Hi All,

 

Im using the BANNER AS DEFAULT PAGE TITLEv1.0 contribution, Im getting the banner on the defult page, but how do i tweak it, when i select a particular category, it would change it to that categories banner.

 

Somthing similar to whts been done in this site Ecopia

 

I read somwhere in the forum that we need to do a IF statment, but can somone explain please.

 

thanks

l8ter

  • 1 year later...
Posted

Aha! Lucky for you, I was looking up all posts mentioning my id, so I stumbled upon this question, gone unanswered. LOL. As I am the creator of both the contribution and ecopeia the website, I am the best person to answer this. Hopefully, someone with the same question will find this answer :D I see there were many views...

 

The whole contraption is quite simple but tedious to do. Basically, you will need to install a separate banner.php module for each category, renaming each banner.php file to a unique name like banner1.php, banner2.php etc. Then, you will have to insert this:

 

<!--CATEGORY 1//-->
	  <?php
 if ((int)$cPath_array[0] == 1) {
?>
 <tr>
 <td class="smallText"><?php include(DIR_WS_MODULES . FILENAME_BANNER_BOX_CATEGORY1); ?></td>
 </tr>
<?php
}
?>
<!--CATEGORY 2//-->
	  <?php
 if ((int)$cPath_array[0] == 2) {
?>
 <tr>
 <td class="smallText"><?php include(DIR_WS_MODULES . FILENAME_BANNER_BOX_CATEGORY2); ?></td>
 </tr>
<?php
}
?>
<!--CATEGORY 3//-->
	  <?php
 if ((int)$cPath_array[0] == 3) {
?>
 <tr>
 <td class="smallText"><?php include(DIR_WS_MODULES . FILENAME_BANNER_BOX_CATEGORY3); ?></td>
 </tr>
<?php
}
?> 
<!--CATEGORY BANNER END//-->

...somewhere after this on or around line 47:

<!-- body_text //-->
<?php
 if ($category_depth == 'nested') {
$category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
$category = tep_db_fetch_array($category_query);
?>
<td width="100%" align="center" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td>
<!--CATEGORY BANNER START//-->

 

Don't forget to change the cPath array. that is this bit:

if ((int)$cPath_array[0] == 3) {

See the 3? That is the cPath, or cateogry path, aka, category ID. The easiest way to discover the cpath is to click on the category and look for the bit in the address that says cPath=#(a number). You repalce the 1, 2, or 3 with the cpath from the address. This controls what banner shows up where. (If the browser is on the cateogry with the ID 3, then BANNER_BOX_CATEGORY3 will show up.

 

Do not forget. You must fully install this contribution Banner as default page title for each instance of banner module you desire. If you want a banner on every category, you must install a sepearate module, renamed as described above, for each seperate category.

 

You will also have to add this to /include/languages/english.php

define('BOX_AD_BANNER_TYPE_CATEGORY1_MODULE', 'cateogry1');
define('BOX_AD_BANNER_TYPE_CATEGORY2_MODULE', 'category2');
define('BOX_AD_BANNER_TYPE_CATEGORY3_MODULE', 'jcategory3');

This bit controls your banner groups. When you add banners, you will add them to a group you create named category1, category2, category3, etc. You place the cateogry specific banners in their proper category.

 

Then, you will open each banner.php file and change this bit:

<?php
 if ($banner = tep_banner_exists('dynamic', BOX_AD_BANNER_TYPE_CATEGORY1_MODULE)) {
?>

Now that I'm looking at it, you might be able to shorten these names if you have enough knowledge to do it. I don't think shortening the name would bother it, except you'll have to change every instance.

 

I think that's it. If you have any questions, ask on this thread. I'm tracking it. :) Good Luck

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...