Forums / Setting Up Categories, Products, Attributes / Can I make my subcategory image dependent on language?

Can I make my subcategory image dependent on language?

Locked

Started by js5729 on 17 Nov 2008, 7:50 AM · Views: 1,474

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
17 Nov 2008, 7:50 AM
#1
js5729 avatar

js5729

New Zenner

Join Date:
Jul 2007
Location:
Germany
Posts:
21
Plugin Contributions:
0

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!

Blog :: Etsy :: DaWanda

18 Nov 2008, 7:19 AM
#2
js5729 avatar

js5729

New Zenner

Join Date:
Jul 2007
Location:
Germany
Posts:
21
Plugin Contributions:
0

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

Have I stumped all the programmers out there? :P

Blog :: Etsy :: DaWanda

18 Nov 2008, 7:53 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

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.

    //    $categories->fields['products_name'] = zen_get_products_name($categories->fields['products_id']);

[B]    if (file_exists(DIR_WS_IMAGES . $_SESSION['languages_code'] . '_' . $categories->fields['categories_image'])) $categories->fields['categories_image'] = $_SESSION['languages_code'] . '_' . $categories->fields['categories_image'];
[/B]    
    $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?main_page=infopages&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.

18 Nov 2008, 1:09 PM
#4
js5729 avatar

js5729

New Zenner

Join Date:
Jul 2007
Location:
Germany
Posts:
21
Plugin Contributions:
0

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.

Blog :: Etsy :: DaWanda

18 Nov 2008, 1:17 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

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.

18 Nov 2008, 1:25 PM
#6
js5729 avatar

js5729

New Zenner

Join Date:
Jul 2007
Location:
Germany
Posts:
21
Plugin Contributions:
0

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

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

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

Blog :: Etsy :: DaWanda

18 Nov 2008, 1:27 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

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.

18 Nov 2008, 1:29 PM
#8
js5729 avatar

js5729

New Zenner

Join Date:
Jul 2007
Location:
Germany
Posts:
21
Plugin Contributions:
0

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!

Blog :: Etsy :: DaWanda

18 Nov 2008, 1:30 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

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.