|
|
#1 |
|
Senior Member
Join Date: Mar 2006
Location: Calif/San Franisico Bay Area
Posts: 110
Rep Power: 16 ![]() |
Is it possible to have a header for each category. so when viewing a category you could have the categorys name there?
|
|
|
|
|
|
#2 |
|
Coder
Join Date: Mar 2006
Posts: 4,585
Rep Power: 111 ![]() ![]() |
are you looking at displaying a whole new header image?
|
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Mar 2006
Location: Calif/San Franisico Bay Area
Posts: 110
Rep Power: 16 ![]() |
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.
|
|
|
|
|
|
#4 |
|
Coder
Join Date: Mar 2006
Posts: 4,585
Rep Power: 111 ![]() ![]() |
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:
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:
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 |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Mar 2006
Location: Calif/San Franisico Bay Area
Posts: 110
Rep Power: 16 ![]() |
is this going to install the name of the categories in the header gif automaticly. or will I have to build each category gif.
|
|
|
|
|
|
#6 | |
|
Coder
Join Date: Mar 2006
Posts: 4,585
Rep Power: 111 ![]() ![]() |
Quote:
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. |
|
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Mar 2006
Location: Calif/San Franisico Bay Area
Posts: 110
Rep Power: 16 ![]() |
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 |
|
|
|
|
|
#8 | |
|
Coder
Join Date: Mar 2006
Posts: 4,585
Rep Power: 111 ![]() ![]() |
Quote:
|
|
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Mar 2006
Location: Calif/San Franisico Bay Area
Posts: 110
Rep Power: 16 ![]() |
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? |
|
|
|
|
|
#10 |
|
Coder
Join Date: Mar 2006
Posts: 4,585
Rep Power: 111 ![]() ![]() |
Do you have a link to your site so I can see what its doing?
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
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 |