Results 1 to 5 of 5

Thread: Different Image per Category

  1. #1
    gspinney's Avatar
    gspinney is offline Registered User
    Join Date
    Jul 2003
    Posts
    128

    Question Different Image per Category

    Does anyone have a suggestion as to select a different header image per category.

    To be clear...

    Real Estate ----> photo of House

    Restaurants ----> photo of Plate of Food

    Health ------> photo of Doctors office

    ...and so on.

    Any ideas??

  2. #2
    FSGDAG's Avatar
    FSGDAG is offline Moderator
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    The only way I think it can be done is to use a different header per category. You can specify different headers for each category in the Admin section. Each category has the possibility of having its own header, in the properties of each category.

    Be careful though, I think you loose some functionality when using something other than the default template header.
    FSGDAG | IndexU Hosting | Owner
    Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
    Follow Us On Twitter | FaceBook Profile | YouTube Videos

  3. #3
    Harkster is offline Registered User
    Join Date
    Mar 2008
    Posts
    127

    Default

    It would seem that one could do a block thing to display an image based on the category.

    There would have to be a consistent image naming system.

    The logic would go something like - <%if%> <%site_url%>/.../<%$cat_image%>.jpg exists display <%/if%>. $cat_image would be either the category name or number.

    That way you could place the image where you wanted. That is just off the top of my head and would need work to keep from being very error prone.

  4. #4
    Gus
    Gus is offline Registered User
    Join Date
    Aug 2008
    Location
    Paris, France
    Posts
    46

    Smile This should (almost ?) work

    Hi Harkster,

    Create a cat_header.html by using the custom template function and copying/pasting header.html contents into it : cat_header.html will be the header of your categories instead of header.html.

    Copy/paste this at the beginning of your cat_header.html :

    <%php%>

    /* category images will be stored in images directory */
    /* filename of an image is catimage + category number */
    /* there must be a cat00.jpg for absent images */

    /* getting hold of category number */
    $image_name = $this->get_template_vars('cat');
    /* creating image name */
    $image_name = "images/".image_name.".jpg";

    /* if image_name does not exist let us get cat00.jpg */
    if (!file_exists($image_name)) {
    $image_name = images/cat00.jpg;
    }

    $this->_tpl_vars['image_name'] = $image_name;

    <%/php%>


    Now $image_name should contain the path to your image to use in your cat_header.html file

    You just have now to replace header.html by cat_header.html in your browse.html.

    I did not test it, but I derived it from a code of mine that works fine.
    So let's hope this will do ...

    Have a nice day
    Gus

  5. #5
    Gus
    Gus is offline Registered User
    Join Date
    Aug 2008
    Location
    Paris, France
    Posts
    46

    Cool Sorry, replaces all the php code

    <%php%>

    /* category images will be stored in images directory */
    /* filename of an image is catimage + category number */
    /* there must be a catimage00.jpg for absent images */

    /* getting hold of category number */
    $image_name = $this->get_template_vars('cat');
    /* creating image name */
    $image_name = "images/catimage".image_name.".jpg";

    /* if image_name does not exist let us get cat00.jpg */
    if (!file_exists($image_name)) {
    $image_name = "images/catimage00.jpg";
    }

    $this->_tpl_vars['image_name'] = $image_name;

    <%/php%>

    Should be better now !
    Gus

Similar Threads

  1. Category 01 [Image-01]
    By StudioZ in forum Pre-Sales Questions
    Replies: 0
    Last Post: 09-17-2009, 11:20 AM
  2. Category image location
    By twomiracles in forum Blocks and Modification
    Replies: 6
    Last Post: 03-31-2008, 10:52 PM
  3. Image for Category Listing
    By L.Murugesan in forum Tutorials, Hints & Tips
    Replies: 0
    Last Post: 05-26-2007, 11:32 PM
  4. Category folder image above text
    By ozrace in forum v5.x
    Replies: 2
    Last Post: 08-08-2006, 02:06 AM
  5. Replies: 3
    Last Post: 06-29-2004, 05:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •