ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Multi Language Site, Global Variables and CSS background images

April 03, 2014 4:53pm

Subscribe [2]
  • #1 / Apr 03, 2014 4:53pm

    mebner

    5 posts

    Hi.

    In addition to English, I need my site to be available in Spanish. Most things seem to be working except background images in my stylesheet.

    I’ve set a “user_language” global variable for the english version in my index.php file:

    $assign_to_config['global_vars'] = array(
        'user_language' => 'en'
    );

    I’ve also created a folder named “es” with a duplicate index.php file but with the “user_language” global variable set to “es”:

    $assign_to_config['global_vars'] = array(
        'user_language' => 'es'
    );

    So when a user shows up to mysite.com, the global variable “user_language” is set to “en”

    And when a user shows up to the mysite.com/es directory, the global variable “user_language” is set to “es”.

    I then use the global variable to access the appropriate language channel field or image:

    {{user_language}-body-copy}
    images/{user_langauge}-hero-img.jpg

    Like I said above, everything works well except when I try to use the {user_language} variable for the background property in my stylesheet:

    background:url({site_url}images/{user_language}-home-img.jpg) no-repeat;

    When I look at the code inspector, what seems to be happening is that, even if the user goes to mysite.com/es, where the “user_language” variable should be set to “es”, the tag in the stylesheet is somehow acting as though the user landed at mysite.com where the variable is set to “en”, only showing the English version of the image when it should be showing the Spanish.

    I am using

    href="{path='site/stylesheet'}"

    to call my css so the tags are all parsing.

    Not sure where to go from here. I’ve been trying to figure this out for two days.

    Any help is appreciated.

    Thanks,
    Michael

  • #2 / Nov 09, 2014 4:38pm

    hoideg

    1 posts

    If you need to use multiple background, I would recommend you to read this article: multiple backgrounds using only CSS3. it’s quite new feature of CSS3, if you need to make it work in older versions of IE, try to use PIE.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases