Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Archived

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

bkellum

Different Header for each category

Recommended Posts

I need to incorporate a different flash movie in the header per each category.

So far, this is the only way I can think of to make this work (there has to be a better way):

 

 

I create my flash movie as below:

  • default.swf (default movie that will be seen on all non-catalog pages such as the home page, privacy, shipping, contact us, etc.)
  • movie_cat1.swf (flash movie for category 1)
  • movie_cat2.swf (flash movie for category 2)
  • movie_cat3.swf (flash movie for category 3)
  • etc. (follow suit for each category name)

Now, I will create a duplicate copy of header.php and modify it so that it brings up the correct flash movie. I will follow this format:

  • header.php (default header that will be seen on all non-catalog pages such as the home page, privacy, shipping, contact us, etc.)
  • header1.php (header that will show flash for category 1)
  • header2.php (header that will show flash for category 2)
  • header3.php (header that will show flash for category 3)
  • etc. (follow suit for number of categories in shop.)

I then add this code in my different pages where I need the amended header.php:

 

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

I change the '2' to whatever header above that I want to include.

 

 

Is there a better way of doing the above by creating some auto generating code in the header.php file to choose which flash movie to play depending upon which category page is being viewed? If so, this would at least save me from having to create a separate header.php, header1.php, header2.php, etc.

 

I realize I will still need to have a flash movie for each category to be pulled in dynamically but if I could save some coding by not having to create the several header files would be great.

 

I'm already utilizing the category images in the category.php files so I can't use the tep image swf swap contribution.

 

Any ideas or maybe even a better way of accomplishing a different header flash movie per category?

Thanks for any input,


Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Share this post


Link to post
Share on other sites

Why not add an extra field to your categories table and a little mod to the admin/categories.php file where you could set the flash file to use in the header. Then modify the header.php file to grab that file based on a query to the database. That way you could have a single header.php file and have as many different flash files/category headers as you wanted.

Share this post


Link to post
Share on other sites
I need to incorporate a different flash movie in the header per each category.

So far, this is the only way I can think of to make this work (there has to be a better way):

I create my flash movie as below:

  • default.swf (default movie that will be seen on all non-catalog pages such as the home page, privacy, shipping, contact us, etc.)
  • movie_cat1.swf (flash movie for category 1)
  • movie_cat2.swf (flash movie for category 2)
  • movie_cat3.swf (flash movie for category 3)
  • etc. (follow suit for each category name)

Now, I will create a duplicate copy of header.php and modify it so that it brings up the correct flash movie. I will follow this format:

  • header.php (default header that will be seen on all non-catalog pages such as the home page, privacy, shipping, contact us, etc.)
  • header1.php (header that will show flash for category 1)
  • header2.php (header that will show flash for category 2)
  • header3.php (header that will show flash for category 3)
  • etc. (follow suit for number of categories in shop.)

I then add this code in my different pages where I need the amended header.php:

 

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

I change the '2' to whatever header above that I want to include.

Is there a better way of doing the above by creating some auto generating code in the header.php file to choose which flash movie to play depending upon which category page is being viewed? If so, this would at least save me from having to create a separate header.php, header1.php, header2.php, etc.

In the header.php file use something like this pseudo code
<?php if ($categoires_id == 1)
require(DIR_WS_INCLUDES . 'header1.php'); 
else if ($categoires_id == 2)
require(DIR_WS_INCLUDES . 'header2.php'); 
and so on

 

Jack


Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Need Help? See this thread and provide the information requested.

How to Upgrade to the latest version

Recommended SEO Addons

Share this post


Link to post
Share on other sites

Thanks...I like both of these ideas. I'll give them a try and then post back.

I still welcome any other examples or ideas.

 

vasttech... Is there any contributions close to what you mentioned before I go and reinvent the wheel so to speak? I really like the concept that you posted.


Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Share this post


Link to post
Share on other sites

There is not a contribution that does exactly what you are looking to do. There is one that allows you to provide category descriptions but that is just text that appears before the products in each category. You could take a look at that contribution to get an idea of what changes need to be made from an admin perspective to add the necessary field. As for making the change to mySQL just add an extra varchar(255) field to the categories or categories_description table. Then in header.php use the cPath to grab the category from the URL and run a query to get the header image.

 

Hope that helps it has been a long day and going to be a longer night :)...

Share this post


Link to post
Share on other sites

I got the above to work! Very Cool!

If there is a better way of doing the mod below or you see any potential problems, PLEASE ADVISE!!

 

I modified the Categories Descriptions contribution to meet my needs. (http://www.oscommerce.com/community/contributions,4294)

 

I needed to implement the category description field to be used in the admin as an input for a category Flash file since the final goal was to have a separate Flash Movie in the header.php for each specific category being displayed.

 

Here is what I did different from the above contribution to make this work:

 

In my default language under admin/includes/languages/categories.php, I added the following line after the line that defines "TEXT_EDIT_CATEGORIES_IMAGE":

 

define('TEXT_EDIT_CATEGORIES_DESCRIPTION', 'Category Flash Movie Code:');

This gave me my input field in the admin per category.

 

I ran the SQL code in my database via phpMyadmin:

ALTER TABLE categories_description ADD categories_description text [size="2"]AFTER categories_name;[/size]

 

I followed the installation of Category Descriptions in admin/actegories.php but left out the modifications in the index.php file (I needed mine to be in the header.php).

 

I added the following in header.php:

<!-- Begin Flash Movie --><?php $cat_description_query = tep_db_query ("select categories_description from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $current_category_id . "' and language_id = '" . (int)$languages_id . "'");
$cat_description = tep_db_fetch_array ($cat_description_query);
if ((int)$current_category_id <= 0) {echo' <center><object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="[url="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0[/url]" border="0" width="552" height="300" align="right" hspace="0">
<param name="movie" value="images/banner-top.swf">
<param name="quality" value="High">
<embed src="images/banner-top.swf" pluginspage="[url="http://www.macromedia.com/go/getflashplayer"]http://www.macromedia.com/go/getflashplayer[/url]" type="application/x-shockwave-flash" name="obj1" width="552" height="300" quality="High"></object></center>';}
else echo '<center><h1>' . $cat_description['categories_description'] . '</h1></center>'; ?><!-- End Flash Movie -->

The above code creates a default Flash Movie for all non-category pages as well as create an "else" statement allowing for a dynamic Flash Movie for each specific category page depending upon what is being displayed at the time.

Now in the Categories Flash Movie input field in the admin, the user can enter the following PHP script exchanging the Flash Movie Name for any .swf file he chooses to use for that particular category:

<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="[url="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0[/url]" border="0" width="552" height="300" align="right" hspace="0">
<param name="movie" value="images/Flash Movie Name.swf">
<param name="quality" value="High">
<embed src="images/Flash Movie Name.swf" pluginspage="[url="http://www.macromedia.com/go/getflashplayer"]http://www.macromedia.com/go/getflashplayer[/url]" type="application/x-shockwave-flash" name="obj1" width="552" height="300" quality="High"></object>

 

This is very sweet. A special thanks to the original author of Categories Descriptions for making it so very easy to modify to one's specific needs.

 

Also thanks to all above who nudged me in the right direction. I have been having severe headaches and have not been able to concentrate on my work so I VERY MUCH APPRECIATE the posts above. :thumbsup: :thumbsup: :thumbsup:


Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Share this post


Link to post
Share on other sites

Hi Guys

 

Would anyone be able to help me here? im trying a similar thing but i like what Jack was talking about and would like to try and implement something like this

 

In the header.php file use something like this pseudo code

CODE

<?php if ($categoires_id == 1)

require(DIR_WS_INCLUDES . 'header1.php');

else if ($categoires_id == 2)

require(DIR_WS_INCLUDES . 'header2.php');

and so on

 

I am trying to do the same thing with my site but have the header logo change to each category, i placed that code

 

<?php

if ($categoires_id == 21)

require(DIR_WS_INCLUDES . 'header21.php');

else if ($categoires_id == 23)

require(DIR_WS_INCLUDES . 'header23.php');

else if ($categoires_id == 25)

require(DIR_WS_INCLUDES . 'header25.php');

else if ($categoires_id == 26)

require(DIR_WS_INCLUDES . 'header26.php');

?>

 

in the header.php and uploaded the required files but nothing happened, i was wondering if this is all you need to do or if you need to put the code in other .php files of the site? my website is http://www.thefeelgoodregister.com/catalog/index.php

 

Any suggestions would be great as i have been searching the forums endlessly and you lot seem to know what your talking about!

 

Many thanks

 

Steve

Share this post


Link to post
Share on other sites

×