Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Banner had for Index Page


Guest

Recommended Posts

Posted

I have inserted code into various headers to display different banner ads on my site but the home page, index.php also shows the same banner ad on the category pages. Does anyone know how to adjust the code so that a different banner ad will show in the header of JUST the home page?

Posted

The category pages and the homepage are generated by the index.php file. I am know there is a way to check to see if you're in categories but I'm not sure how to get that to work with displaying banners.

 

Maybe somebody else can help out.

Posted

The index page is split into 3 parts, top, nested and products. Top is the default part, when you have not selected a category/subcategory or a manufacturer.

 

If i understand you this is the part you want to display your banner on. Using the stock osc code from includes/footer.php find

<?php
 if ($banner = tep_banner_exists('dynamic', '468x50')) {
?>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
   <td align="center"><?php echo tep_display_banner('static', $banner); ?></td>
 </tr>
</table>
<?php
 }
?>

Change to

<?php
 if ((basename($PHP_SELF) == FILENAME_DEFAULT) && ($category_depth == 'top') && (!isset($_GET['manufacturers_id']))) {
   if ($banner = tep_banner_exists('dynamic', '468x50')) {
?>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
   <td align="center"><?php echo tep_display_banner('static', $banner); ?></td>
 </tr>
</table>
<?php
   }
 }
?>

Posted

The index page is split into 3 parts, top, nested and products. Top is the default part, when you have not selected a category/subcategory or a manufacturer.

 

If i understand you this is the part you want to display your banner on. Using the stock osc code from includes/footer.php find

<?php
 if ($banner = tep_banner_exists('dynamic', '468x50')) {
?>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
   <td align="center"><?php echo tep_display_banner('static', $banner); ?></td>
 </tr>
</table>
<?php
 }
?>

Change to

<?php
 if ((basename($PHP_SELF) == FILENAME_DEFAULT) && ($category_depth == 'top') && (!isset($_GET['manufacturers_id']))) {
   if ($banner = tep_banner_exists('dynamic', '468x50')) {
?>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
   <td align="center"><?php echo tep_display_banner('static', $banner); ?></td>
 </tr>
</table>
<?php
   }
 }
?>

Posted

Thanks for responding so quickly, but I'm not sure I understand. Are you saying that if I put this in the footer it will display at the top of the page inside the header?

Posted

Are you saying that if I put this in the footer it will display at the top of the page inside the header?

No.

 

In a stock osc the banner code is in the includes/footer.php. If you have your banner in your includes/header.php then either you added it there or it is a template. I can only give you an idea of how to do it based on the stock osc code.

 

If you need further help you will have to supply your code.

Posted

No.

 

In a stock osc the banner code is in the includes/footer.php. If you have your banner in your includes/header.php then either you added it there or it is a template. I can only give you an idea of how to do it based on the stock osc code.

 

If you need further help you will have to supply your code.

Posted

I don't think you quite understand what my problem is. I already kow how to get the banner to display in the header. The problem is that I only want it to display on index.php. I want a different header to display on the category pages. What I need is some code that will be on index.php that says if a category page, display this different header.

Posted

What I need is some code that will be on index.php that says if a category page, display this different header.

Are you using the banner manager in admin to manage your banners? If so see if this helps.

 

Click Me

Posted

Are you using the banner manager in admin to manage your banners? If so see if this helps.

 

Click Me

Posted

No, I'm not. This seems a bit complicated to my novice eye, but I will keep it bookmarked in case I can't find any other way. The problem with this is that the banners won't be in the header which is where I need it. Thanks anyway for trying to help. I appreciate it.

Posted

it's not as complicated as you think. If you post your code for header.php maybe I can help you. Right now I'm shooting in the dark.

Posted

Here is the code for my header, but again. That's not the problem. the header shows up just fine. the problem is that I only want it to show on one page. Right now, it shows in the index page AND all the category pages. The code change I need is not in the header, but in index.php.

 

 

headerhome.php

 

 

<?php

/*

$Id: header.php 1739 2007-12-20 00:52:16Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

// check if the 'install' directory exists, and warn of its existence

if (WARN_INSTALL_EXISTENCE == 'true') {

if (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install')) {

$messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning');

}

}

 

// check if the configure.php file is writeable

if (WARN_CONFIG_WRITEABLE == 'true') {

if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) && (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) {

$messageStack->add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning');

}

}

 

// check if the session folder is writeable

if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') {

if (STORE_SESSIONS == '') {

if (!is_dir(tep_session_save_path())) {

$messageStack->add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning');

} elseif (!is_writeable(tep_session_save_path())) {

$messageStack->add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning');

}

}

}

 

// check session.auto_start is disabled

if ( (function_exists('ini_get')) && (WARN_SESSION_AUTO_START == 'true') ) {

if (ini_get('session.auto_start') == '1') {

$messageStack->add('header', WARNING_SESSION_AUTO_START, 'warning');

}

}

 

if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') && (DOWNLOAD_ENABLED == 'true') ) {

if (!is_dir(DIR_FS_DOWNLOAD)) {

$messageStack->add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning');

}

}

 

if ($messageStack->size('header') > 0) {

echo $messageStack->output('header');

}

?>

<table border="0" width="900" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff">

<tr class="header">

<td valign="top"><img src="/images/handyclr.gif" border=0 width=1 height=20 alt="BlackShortStories.com">

<br><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'weblogo.jpg', STORE_NAME) . '</a>'; ?></td><td valign="bottom"><img src="/images/handyclr.gif" border=0 width=1 height=30 alt="BlackShortStories.com"><br><img src="/images/handyclr.gif" border=0 width=10 height=1 align="left"><a href="/submit.shtml"><font face="Geneva, Arial, Helvetica, sans-serif" size=2 color="#006633"><strong>Submissions</strong></font></a><img src="/images/divbutton.gif" border=0 vpsace=3 hspace=8 width=10 height=11><a href="/links.shtml"><font face="Geneva, Arial, Helvetica, sans-serif" size=2 color="#006633"><strong>Resources</strong></font></a></td><td valign="top" align="center"><img src="/images/handyclr.gif" border=0 width=1 height=5><br><script language="JavaScript" type="text/javascript" src="http://vhss-d.oddcast.com/vhost_embed_functions_v2.php?acc=1503929&js=1"></script><script language="JavaScript" type="text/javascript">AC_VHost_Embed(1503929,150,200,'FFFFFF',1,1, 2001929, 0,0,0,'d8672cd7e78b6e5aa222ca8d6f79cc80',9);</script></td><td align="right" valign="bottom"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_account.gif', HEADER_TITLE_MY_ACCOUNT) . '</a>  <a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image(DIR_WS_IMAGES . 'header_cart.gif', HEADER_TITLE_CART_CONTENTS) . '</a>  <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_CHECKOUT) . '</a>'; ?>  </td>

</tr>

</table>

<table border="0" width="900" cellspacing="0" cellpadding="1" align="center" height=25>

<tr class="headerNavigation">

<td class="headerNavigation">  <?php echo $breadcrumb->trail(' » '); ?></td>

<td align="right" class="headerNavigation"><?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LOGOFF; ?></a>  |  <?php } ?><a href="<?php echo tep_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a>  |  <a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a>  |  <a href="<?php echo tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CHECKOUT; ?></a>   </td>

</tr>

</table>

<?php

if (isset($HTTP_GET_VARS['error_message']) && tep_not_null($HTTP_GET_VARS['error_message'])) {

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr class="headerError">

<td class="headerError"><?php echo htmlspecialchars(stripslashes(urldecode($HTTP_GET_VARS['error_message']))); ?></td>

</tr>

</table>

<?php

}

 

if (isset($HTTP_GET_VARS['info_message']) && tep_not_null($HTTP_GET_VARS['info_message'])) {

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr class="headerInfo">

<td class="headerInfo"><?php echo htmlspecialchars(stripslashes(urldecode($HTTP_GET_VARS['info_message']))); ?></td>

</tr>

</table>

<?php

}

?>

Posted

This seems a bit complicated

 

You're right. This is getting complicated.

 

That's not the problem. the header shows up just fine. the problem is that I only want it to show on one page. Right now, it shows in the index page AND all the category pages.

 

Are you sure you only want it show on one part of the index page. Doing that means you lose your store logo, links to my account shopping cart etc, and the breadcrumb trail.

 

The problem with this is that the banners won't be in the header which is where I need it.

 

The code change I need is not in the header, but in index.php.

 

Where is the code for your banner??

 

If you want it in the header then you need to make changes in the header.

 

If you want it in the index page then that is where we need to be.

 

 

I have inserted code into various headers to display different banner ads on my site

 

Cam you provide a link so I can see what you have and are trying to do?

Posted

I appreciate your trying to help, I really do! But I just don't think you are getting what I am trying to do and I don't see how I can make it any clearer. I need code that will live in index.php that calls header 1 to display on the index page and header 2 to display on the category pages. There are NO changes that need to be made in the header. The header is fine.

Posted

Ok back to the original code i gave you with a little tweak.

 

In index.php find

<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

Change to

<?php
 if (($category_depth == 'top') && (!isset($_GET['manufacturers_id']))) {// default header for non category pages
?>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<?php
 } else {// header for category pages
?>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header_2.php'); ?>
<!-- header_eof //-->
<?php
 }
?>

Change the name of header_2.php to your header file name.

Posted

YES!!!!!!

 

This is just what I needed. Thanks a Bunch! Here's the URL to my site if you want to take a peek. The unique Home page header now doesn't show on the category pages.

 

http://www.blackshortstories.com

Archived

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

×
×
  • Create New...