IkBenBen Posted October 2, 2014 Posted October 2, 2014 Sorry if this has been asked before but had no luck finding an answer so far on the forums, so here I go! I made a list that shows all the languages which works perfectly. My question now is, how do I exclude the (user's) language that's currently active from the list? For example, I'm viewing the English site, how do I exclude English from the list... Dutch English German ... so it only shows... Dutch German ... and when viewing the Dutch site excluding Dutch, when viewing the German site excluding German.. etc.. This is my code: <?php foreach($languages as $language) { if(!$page->viewable($language)) continue; // check if page not published for this language $url = wire('page')->localUrl($language); $title = $language->getUnformatted('title')->getLanguagevalue($language->id); $name = $language->get('language_name'); $location = $config->urls->templates; echo "<li>$title</a></li>"; } ?> Just started with Processwire so forgive me for asking a stupid question! Thanks in advance!
SiNNuT Posted October 3, 2014 Posted October 3, 2014 I think you can get some inspiration from Ryan's example over here: http://processwire.com/api/multi-language-support/multi-language-urls/#language-switcher 1
Gayan Virajith Posted October 3, 2014 Posted October 3, 2014 Hi Bueno, Try this foreach($languages as $language) { if(wire('user')->language->id == $language->id) continue; // skip current language if(!$page->viewable($language)) continue; // check if page not published for this language $url = wire('page')->localUrl($language); $title = $language->getUnformatted('title')->getLanguagevalue($language->id); $name = $language->get('language_name'); $location = $config->urls->templates; echo "<li>$title</a></li>"; } 4
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now