Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2007
    Location
    Germany
    Posts
    21
    Plugin Contributions
    0

    Default Can I make my subcategory image dependent on language?

    Does anyone know how to make the subcategory images dependent on the language?

    For example, you can see on my site that I have the subcategories set up to show just an image. However, I can't figure out how (or if) I can have multiple images for each category, one for English and one for German. Basically, I'd like to have a different set of subcategory images for the German version of the site.

    I'm no PHP wiz, but can usually find my way around, so if someone could point me in the right direction, I'd be eternally grateful!

  2. #2
    Join Date
    Jul 2007
    Location
    Germany
    Posts
    21
    Plugin Contributions
    0

    Default Re: Can I make my subcategory image dependent on language?

    Have I stumped all the programmers out there?

  3. #3
    Join Date
    Jan 2004
    Posts
    66,447
    Plugin Contributions
    81

    Default Re: Can I make my subcategory image dependent on language?

    Well, since it's not designed to do that out-of-the-box, you need to get creative.

    So, first you find out "where" those images are being built. From browser View Source, you can find that they're in whatever page draws the indexCategories DIV.
    So, searching the files for that reveals that it's in a template, which calls the tpl_category_row template. The first thing that template does is call the category_row.php module file in order to prepare the content.

    Thus, it's in that module file that you would make your coding changes.

    Since you want the images to be language-specific, you can probably do that by adding "de_" as a prefix to all the images applicable to the "de" language.

    Thus, inserting the line of code as shown should accomplish giving the site the ability to first check to see whether an image exists with the "de_" prefix or not. If it does, it'll use it. If not, it'll default to using the image filename specified in the category details in the database, without any language prefix.
    Be sure to save any changes you make into the appropriate override folder, rather than editing the original module file directly.

    Code:
        //    $categories->fields['products_name'] = zen_get_products_name($categories->fields['products_id']);
    
        if (file_exists(DIR_WS_IMAGES . $_SESSION['languages_code'] . '_' . $categories->fields['categories_image'])) $categories->fields['categories_image'] = $_SESSION['languages_code'] . '_' . $categories->fields['categories_image'];
        
        $list_box_contents[$row][$col] = array('params' => 'class="categoryListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"',
    Remember, donations to Zen Cart can be made here: http://www.zen-cart.com/index.php?ma...es&pages_id=14
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Jul 2007
    Location
    Germany
    Posts
    21
    Plugin Contributions
    0

    Default Re: Can I make my subcategory image dependent on language?

    Hey Doc, thanks for the response.

    I had narrowed it down to the category_row.php file, but wasn't sure what to do from there. It's nice to know I was on the right track!

    I inserted the line of code you provided, but it doesn't seem to work. I'm now getting no image for the subcategory in either language. The subcategory text is showing, but I had previously edited that part of the code so that it doesn't appear. The image files are saved in my image directory, under the names 'birthday.jpg' and 'de_birthday.jpg'.

    I'm going to look through a php book and see if I can work something else out. If you have any other suggestions, I'd be glad to hear them.

    Thanks again for the help! It is much appreciated.
    Last edited by js5729; 18 Nov 2008 at 02:14 PM.

  5. #5
    Join Date
    Jan 2004
    Posts
    66,447
    Plugin Contributions
    81

    Default Re: Can I make my subcategory image dependent on language?

    Well, one thing I didn't take into consideration was the fact that you've got your category images stored in an extra subdirectory.
    Thus, maybe it's easier to create a "/images/de/categories/" folder, and put your images in there. Then change the '_' in the code I posted earlier to '/' instead.

    Then you can have your english images here:
    /images/categories/thank_you.jpg
    ...

    and your dutch images here:
    /images/de/categories/thank_you.jpg
    ...
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Jul 2007
    Location
    Germany
    Posts
    21
    Plugin Contributions
    0

    Default Re: Can I make my subcategory image dependent on language?

    If I could hug you through the computer right now, I would.

    It's working. I can't even begin to tell you how thankful I am!

  7. #7
    Join Date
    Jan 2004
    Posts
    66,447
    Plugin Contributions
    81

    Default Re: Can I make my subcategory image dependent on language?

    Glad it's working!

    Don't be shy of the donations link at the top of the page :)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Jul 2007
    Location
    Germany
    Posts
    21
    Plugin Contributions
    0

    Default Re: Can I make my subcategory image dependent on language?

    I was just going to PM you to tell you that. I just bought some Zenners some coffee. :)

    Thanks again!

  9. #9
    Join Date
    Jan 2004
    Posts
    66,447
    Plugin Contributions
    81

    Default Re: Can I make my subcategory image dependent on language?

    Thanks!
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Replies: 3
    Last Post: 13 Oct 2010, 10:53 PM
  2. Language-dependent styelsheets?
    By shirster in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 1 Feb 2008, 08:27 AM
  3. Make products language dependent
    By viepie in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 1 Nov 2007, 05:07 PM
  4. Can I make the subcategory menu links stay open?
    By bjraines in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 5 Oct 2006, 05:02 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
  •  
disjunctive-egg