Support Forums

Old 05-01-2006, 02:11 PM   #1
Senior Member
 
 
Join Date: Mar 2006
Location: Calif/San Franisico Bay Area
Posts: 110
Rep Power: 16
newone is on a distinguished road
Default Header V3.0.15

Is it possible to have a header for each category. so when viewing a category you could have the categorys name there?
newone is offline   Reply With Quote
Old 05-01-2006, 02:27 PM   #2
Coder
 
Join Date: Mar 2006
Posts: 4,585
Rep Power: 111
Lhotch is just really niceLhotch is just really nice
Default

are you looking at displaying a whole new header image?
__________________
Larry.
Lhotch is offline   Reply With Quote
Old 05-01-2006, 02:37 PM   #3
Senior Member
 
 
Join Date: Mar 2006
Location: Calif/San Franisico Bay Area
Posts: 110
Rep Power: 16
newone is on a distinguished road
Default

Yes I would build a new header gif for each category, I could put the name of the category in the header gif. so when viewing the category you will see the name there to.
newone is offline   Reply With Quote
Old 05-01-2006, 03:12 PM   #4
Coder
 
Join Date: Mar 2006
Posts: 4,585
Rep Power: 111
Lhotch is just really niceLhotch is just really nice
Default

Here is just one of the many ways you can do it.

Ok, try something like this. Make a backup of your layout.tpl.php file Then open it up and around line 24 you should see this.

PHP Code:
<!-- // Header // -->
    
<div id="header"><a href="index.php"><img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/header.gif" width="633" height="93" border="0" alt="{$title}" /></a></div>
        <!-- 
// Header // --> 
we need to put a conditional statement in there to check for the category and if there isnt one assume the viewer is not on a category page. We can find out what (if any) category the user is viewing by looking at the template variable $breadcrumb. Its actaully an array that will have an element for each layer down we are.

For example, if you have a classifieds site that has Ford then a subcategory called cars and in that another category for mustangs the breadcrumb would put each of those in its own element. For us we just want to know what the last element is and we can do that by using "foreach" which will loop through each element of the array and assign the value of an array to a variable. This is helpfull if you want to list each element within the array, you could echo its contents on each iteration of the loop. For example the following...

{foreach from=$breadcrumb item=section}
Your are viewing {$section}
{/foreach}

Now if we were viewing the ford category we would see.....

Your are viewing Ford.

if we were in the cars subcategory we would see.....

Your are viewing Ford.
Your are viewing Cars.

and if we were in the cars subcategory viewing mustangs the output would be

Your are viewing Ford.
Your are viewing Cars.
Your are viewing Mustangs.

As I mentioned though we are only concerned with the last one, so we could change the foreach loop to look like this......

{foreach from=$breadcrumb item=section}
{/foreach}
Your are viewing {$section}

Each time the loop is processed the value of the variable $section gets assigned a new value, each overwriting the previous which will leave us with just the final value and then we can use that after the loop instead of within the loop.

Ok, so now we know how we can get the category title lets use that to determine if the default or category specific header image should be shown.

First loop through the breadcrumb to get the category name and assign it to the variable "section"

Then check to see if it is empty and if it is display the default header. If the section is not empty the {else} section will be used and to make things simple I used the value of the section variable for the name of the image to load. Then at the end overwrite the value of section so its blank just in case.
PHP Code:
{foreach from=$breadcrumb item=section}
{/foreach}
{if 
$section==""}
<!-- 
// Header // -->
    
<div id="header"><a href="index.php"><img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/header.gif" width="633" height="93" border="0" alt="{$title}" /></a></div>
        <!-- 
// Header // -->
{else}
<!-- 
// Header // -->
    
<div id="header"><a href="index.php"><img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/{$section}.gif" width="633" height="93" border="0" alt="{$title}" /></a></div>
        <!-- 
// Header // -->
{/if}
{
assign var=section value=""
The only problem with the above is that if your category names have spaces or any special characters it could cause problems since using them in filenames could cause problems. One of the easiest ways around that would be if none of your category names had any spaces or special characters in the first 5 characters of the category name you could truncate the $section variable to 5 characters and when you make your images just use the 1st 5 characters for the images filename. Just replace {$section} in the img src section to {$section|truncate:5}

Then lets say you have a category called "Trucks and cars" the value of the variable $section would be "Trucks and cars" but the path to the image would be
"templates/{$smarty.const.MAIN_TEMPLATE}/images/{$section|truncate:5}.gif" and the name of the file would be truck.gif
__________________
Larry.
Lhotch is offline   Reply With Quote
Old 05-01-2006, 03:23 PM   #5
Senior Member
 
 
Join Date: Mar 2006
Location: Calif/San Franisico Bay Area
Posts: 110
Rep Power: 16
newone is on a distinguished road
Default

is this going to install the name of the categories in the header gif automaticly. or will I have to build each category gif.
newone is offline   Reply With Quote
Old 05-01-2006, 03:31 PM   #6
Coder
 
Join Date: Mar 2006
Posts: 4,585
Rep Power: 111
Lhotch is just really niceLhotch is just really nice
Default

Quote:
Originally Posted by newone
is this going to install the name of the categories in the header gif automaticly. or will I have to build each category gif.
No, it will simply point to an image file and load it in place of the default image.

Generally speaking an image file has to be manipulated with special software you cant just write text into an image file. The closest you can get to it would be to use a background image and then text could be written over it.
__________________
Larry.
Lhotch is offline   Reply With Quote
Old 05-01-2006, 03:51 PM   #7
Senior Member
 
 
Join Date: Mar 2006
Location: Calif/San Franisico Bay Area
Posts: 110
Rep Power: 16
newone is on a distinguished road
Default

In V2.3.4 I was given this to add the the header.php file

<tr>
<?php
$filename = $template_path . '/images/' . $type . '.gif' ;
if (file_exists($filename)) {
echo "<td colspan=\"2\"><a href=\"index.php\"><img src=\"" . $template_path . "/images/" . $type . ".gif\" width=\"767\" height=\"127\" border=\"0\" alt=\"" . $title . "\" /></a></td>" ;
} else {
echo "<td colspan=\"2\"><a href=\"index.php\"><img src=\"" . $template_path . "/images/header.gif\" width=\"767\" height=\"127\" border=\"0\" alt=\"" . $title . "\"/></a></td>" ;
}
?>
</tr>


all I needed to do was was hover over the category and view the status bar and it would say something like this
http://www.mysite.com/category.php?type=5
where it says type=5
I then would use photo shop, or paint and make a gif and name it 5.gif and upload it to the template/default/images folder. this I think would be better, this way you would not worry about special characters. and the name of the gif would be simple. 1.gif , 2.gif , and so on .

Could this be done for V3.0.15 I hope so
newone is offline   Reply With Quote
Old 05-02-2006, 03:05 PM   #8
Coder
 
Join Date: Mar 2006
Posts: 4,585
Rep Power: 111
Lhotch is just really niceLhotch is just really nice
Default

Quote:
Originally Posted by newone
all I needed to do was was hover over the category and view the status bar and it would say something like this
http://www.mysite.com/category.php?type=5
where it says type=5
I then would use photo shop, or paint and make a gif and name it 5.gif and upload it to the template/default/images folder. this I think would be better, this way you would not worry about special characters. and the name of the gif would be simple. 1.gif , 2.gif , and so on .

Could this be done for V3.0.15 I hope so
I dont beleive its quite that easy in 3.0.x. naviogate around in your categories and look at the status bar you will see that some categories have "type" and and some have "type" and "sec". Type is the parent highest level category and "sec" is the subcategory. If you dont have any ads in the main categories and they are all in subcategories you could probably get away with using the sec variable.
__________________
Larry.
Lhotch is offline   Reply With Quote
Old 05-03-2006, 03:35 PM   #9
Senior Member
 
 
Join Date: Mar 2006
Location: Calif/San Franisico Bay Area
Posts: 110
Rep Power: 16
newone is on a distinguished road
Default Header V3.0.15

this is what I got

<body>


<div id="wrapper">
{foreach from=$breadcrumb item=section}
{/foreach}
{if $section==""}
<!-- // Header // -->
<div id="header"><a href="index.php"><img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/header.gif" width="633" height="93" border="0" alt="{$title}" /></a></div>
<!-- // Header // -->
{else}
<!-- // Header // -->
<div id="header"><a href="index.php"><img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/{$section|truncate:5}.gif" width="633" height="93" border="0" alt="{$title}" /></a></div>
<!-- // Header // -->
{/if}
{assign var=section value=""}

<!-- // Top Bar // -->


Then I took the default header gif and modify it with some text so I could tell which gif it is, and named it pets.gif

on the home page it displays the default header.gif but when I go to a category like pets & animals It shows no header gif not even the default gif
It only shows this text, = "mysite name > pets & animals"

did I miss something?
newone is offline   Reply With Quote
Old 05-03-2006, 03:44 PM   #10
Coder
 
Join Date: Mar 2006
Posts: 4,585
Rep Power: 111
Lhotch is just really niceLhotch is just really nice
Default

Do you have a link to your site so I can see what its doing?
__________________
Larry.
Lhotch is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Featuered Listings Table Header brian-bear v3.1 Questions & Support 1 10-21-2006 05:57 AM
Header Changer v3.0.15 - v3.1.5 MSeven HTML, CSS, and Design Help 24 10-13-2006 05:42 PM
Header on Featured Ads lbrown13 HTML, CSS, and Design Help 10 05-23-2006 04:09 PM
header change newone v3.0 Questions & Support 0 04-28-2006 11:25 PM
where is the header php files at? PonyTrader v3.0 Questions & Support 1 04-19-2006 12:02 PM


All times are GMT -4. The time now is 04:48 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0