WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Transposh - switch slider with $lang (6 posts)

  1. kenjidd
    Member
    Posted 2 years ago #

    Hi guy's
    i need help with transposh.
    I can't find the right $tag to switch lang with transposh.
    I have a slider with 2 category, one in french and the other in english. What i need to do is to change the category slider with the right language.

    Here is my code :

    <?php
       if($lang == 'fr')
          echo do_shortcode ('[promoslider width="930px" height="350px" category="francais"]');
       else if($lang == "en")
          echo do_shortcode ('[promoslider width="930px" height="350px" category="anglais"]');
    ?>

    i know my code is good cause it work with qtranslate, and i know that the problem is because i have the wrong $tag it is NOT $lang that's for sure, so what it is ????

    i tried with $languages, $language, $transposh etc.... so many !!!! lol
    is someone can help ? please....

  2. Ofer Wald
    Member
    Posted 2 years ago #

    Hello,

    $my_transposh_plugin->target_language

    You might have to declare it as global if you are inside a function

    also, you might be able to use the shortcode you wanted embedded in transposh shortcode, but that's probably a bit trickier

    Good luck

  3. kenjidd
    Member
    Posted 2 years ago #

    Hi Ofer,
    thanks for answered....
    I already tried as you told me.... but it doesn't work.
    My last shot was :

    <?php
       if($my_transposh_plugin->target_language == 'fr')
    echo do_shortcode ('[promoslider width="930px" height="350px" category="francais"]');
    else if($my_transposh_plugin->target_language == "en")
    echo do_shortcode ('[promoslider width="930px" height="350px" category="anglais"]');
    
    ?>

    But it doesn't work. The code is ok, but nothing happen cause it doesn't find the language.

    What is strange is that when i write the code in page.php it's fine, but in the header.php ( as i need to do) it dosn't work anymore.

    The only solution for the code works in the header.php, is to put this code in all the pages who call the header :

    <?php define('MY_CUR_LANG',$my_transposh_plugin->target_language); ?>

    that solution is not so good.... do you have any idea ?

  4. Ofer Wald
    Member
    Posted 2 years ago #

    As I previously wrote, you need a global;
    use the line

    global $my_transposh_plugin
  5. kenjidd
    Member
    Posted 2 years ago #

    and of course to change the code in the header.php

    <?php
       if(MY_CUR_LANG == 'fr')
    echo do_shortcode ('[promoslider width="930px" height="350px" category="francais"]');
    else if(MY_CUR_LANG == "en")
    echo do_shortcode ('[promoslider width="930px" height="350px" category="anglais"]');
    
    ?>
  6. kenjidd
    Member
    Posted 2 years ago #

    thansk again for your REALLY QUICK answer....

    i was test with global without any success, but it's because i made a mystake in the code...

    so you rock ! Thank you very much ! it's work perfectly and sorry to ask you twice the same question.... it was my mystake....

    thanks ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic