Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Side Banners - Linking to a Category not a Product


Mort-lemur

Recommended Posts

Posted

Hi,

 

I have installed the side-banners contribution - which works great.

 

However I need to have some of the banners link to a category rather than a specific product.

 

The code in side_banners.php is:

 

//change only the values of the array, this will help create the desired links to the product (i.e. http://www.example.com/products_info.php?products_id=22
$image = array('image1' => 130);
//			   'image2' => 33,
//			   'image3' => 31,
//			   'image4' => 30,
//			   'image5' => 29);

//image dimensions (change this if needed)
define('W', 125);
define('H', 160);

//image format (i.e. .png, .gif, .jpg)
$ext = '.jpg';

//none of this should be touched.
$info_box_contents = array();
new infoBoxHeading($info_box_contents, false, false);

$side_banner_loop = '<table width="33%" cellspacing=0 cellpadding=0 border=0 align="right" />' . "\n";
foreach($image as $side_banner_images => $product_info_id) {
$side_banner_loop .= "<tr>\n<td>" . '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO) . '?products_id='
. $product_info_id . '"> <img src="' . tep_href_link(DIR_WS_IMAGES) . 'side_banners/' 
. $side_banner_images . $ext . '" width="' . W . '" height="' . H . '">' . "</img></a><br></td>\n</tr>\n";
}
$side_banner_loop .= '</table>';

$info_box_contents = array();
$info_box_contents[] = array('text' => $side_banner_loop);

new infoBox($info_box_contents);
?>	

 

How should this be changed to allow links to categories as well as products?

 

Many Thanks

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Posted

I would repeat the code and amend one of them to point to category pages rather than products

 

index.php?cPath=75

 

put a second "link" in to point to a category page

 

suspect it is

 

<a href="' . tep_href_link(FILENAME_DEFAULT) . '?cPath='

. $product_info_id . '">

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Posted

Hi Geoffrey,

 

Tried duplicating the code, and although the box is displayed, and when I hover over it I see the correct url (I know its correct cos I tried it in the address bar) when I click on the box I get an error stating that the redirect will never complete.

 

Here is the code I have now:

 

<?php
/*
 $Id: side_banners.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

//change only the values of the array, this will help create the desired links to the product (i.e. http://www.example.com/products_info.php?products_id=22
$image = array('image1' => 1364);
//			   'image2' => feeders/drinkers);
//			   'image3' => 31,
//			   'image4' => 30,
//			   'image5' => 29);

//image dimensions (change this if needed)
define('W', 105);
define('H', 160);

//image format (i.e. .png, .gif, .jpg)
$ext = '.jpg';

//none of this should be touched.
$info_box_contents = array();
//new infoBoxHeading($info_box_contents, false, false);

$side_banner_loop = '<table width="33%" cellspacing=0 cellpadding=0 border=0 align="right" />' . "\n";
foreach($image as $side_banner_images => $product_info_id) {
$side_banner_loop .= "<tr>\n<td>" . '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO) . '?products_id='
. $product_info_id . '">
<img src="' . tep_href_link(DIR_WS_IMAGES) . 'side_banners/' 
. $side_banner_images . $ext . '" width="' . W . '" height="' . H . '">' . "</img></a><br></td>\n</tr>\n";
}
$side_banner_loop .= '</table>';

$info_box_contents = array();
$info_box_contents[] = array('text' => $side_banner_loop);

new infoBox($info_box_contents);

//test Code 
$image = array('image1' => feeders-drinkers-c-130);
//		  'image2' => home-and-gifts-c-130);
//			   'image3' => 31,
//			   'image4' => 30,
//			   'image5' => 29);

//image dimensions (change this if needed)
define('W', 105);
define('H', 160);

//image format (i.e. .png, .gif, .jpg)
$ext = '.jpg';

//none of this should be touched.
$info_box_contents = array();
//new infoBoxHeading($info_box_contents, false, false);

$side_banner_loop = '<table width="33%" cellspacing=0 cellpadding=0 border=0 align="right" />' . "\n";
foreach($image as $side_banner_images => $product_info_id) {
$side_banner_loop .= "<tr>\n<td>" . '<a href="' . tep_href_link(FILENAME_DEFAULT) . '?cPath='
. $product_info_id . '"> 
<img src="' . tep_href_link(DIR_WS_IMAGES) . 'side_banners/' 
. $side_banner_images . $ext . '" width="' . W . '" height="' . H . '">' . "</img></a><br></td>\n</tr>\n";
}
$side_banner_loop .= '</table>';

$info_box_contents = array();
$info_box_contents[] = array('text' => $side_banner_loop);

new infoBox($info_box_contents);
?>	

 

Thanks

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Archived

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

×
×
  • Create New...