(2015-07-17, 22:52:19)stwneu Wrote: I am using this plugin in one section of my site, where I would also like to have a link to the english and german version.
Right now in my sidebar i have this:
Code:<div align="left"><a href="<?php echo htmlspecialchars(return_i18n_setlang_url('de')); ?>">deutsch</a> | <a href="<?php echo htmlspecialchars(return_i18n_setlang_url('en')); ?>">english</a></div>
Is it possible to show this link only if the given page is availible in the other language,too?
Use return_i18n_available_languages(return_page_slug()), e.g.:
Code:
<div align="left">
<?php $langs = return_i18n_available_languages(return_page_slug()); ?>
<?php if (in_array('de', $langs)) { ?>
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url('de')); ?>">deutsch</a>
<?php } ?>
<?php if (in_array('de', $langs) && in_array('en', $langs)) { echo '|'; } ?>
<?php if (in_array('de', $langs)) { ?>
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url('en')); ?>">english</a>
<?php } ?>
</div>