DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Qtranslate + Magic Fields

09.29.2010
| 4489 views |
  • submit to reddit
        // I usually work using qtranslate, 
you can choose 2 ways: 
1) use multiline text fields in your panel and qtranslate intercept   
them, makin them multilanguage 
2) if you need to you any other field type, create one for each   
language naming it: fieldname-langcode (example: myfield-en) 
then retrieve it with:  get('myfield-'. qtrans_getLanguage()) 


<?php echo get('myfield-'. qtrans_getLanguage()); ?>

//If you don't want empty fields to appear
<?php if ( get('myfield-'. qtrans_getLanguage(),true) ) {
                  echo "<li>"; 
                  echo get_label('myfield-'. qtrans_getLanguage());
                  echo ": ";
                  echo get('myfield-'. qtrans_getLanguage());
                  echo "</li>";
                  } else {
                  echo get('myfield-'. qtrans_getLanguage());
                  }
                ?>
    

Comments

Snippets Manager replied on Sat, 2011/09/03 - 9:45pm

i need it too!