caribou Posted June 19, 2014 Posted June 19, 2014 Here's an odd problem. Suggestions welcome! In one of my templates, I list the 5 most recent items. After installing multi-language, the default (English) contiues to work as expected. In the other language, the recents stopped updating the day I installed the module. See attached. Edit: On further exploration, anywhere I list pages in any order, pages created after I installed the module don't show up in any language but default. Compare the recent updates menu here: http://wwfgap.org/tracker/jaguar/puerto-iguazu/ and here: http://wwfgap.org/tracker/es/jaguar/puerto-iguazu/ Here's the code: <?php $recents = array(); foreach($pages->find("template=placemark, limit=5, sort=-created") as $placemark){ $since = $placemark->created; $since = date("Y-m-d",$since); $recents[] = "<li><a href='{$placemark->parent->url}'><img src='{$placemark->parent->icon->url}' alt='icon'>{$placemark->parent->parent->parent->title}: {$placemark->parent->title}</a><br><em>{$since}</em></li>"; } $recents = implode($recents); echo "{$recents}"; ?>
caribou Posted June 20, 2014 Author Posted June 20, 2014 Further research - this only happens if I specify the template in the query. So this shows all recent pages of any type in any language: $placemarks = $pages->find("sort=-created, limit=5"); foreach($placemarks as $placemark){ $since = date("Y-m-d",$placemark->created); echo "{$since}<br/>"; } But this only shows pages created before I installed the multilanguage module, if I access any language other than the default (foo.com/es instead of foo.com, for example). $placemarks = $pages->find("sort=-created, limit=5, template=placemark "); foreach($placemarks as $placemark){ $since = date("Y-m-d",$placemark->created); echo "{$since}<br/>"; } Which indicates that by installing the module, something changed with my templates - but what?
caribou Posted June 20, 2014 Author Posted June 20, 2014 More sleuthing! I'm a regular Sherlock over here. Only one template is exhibiting this problem. The only difference between this and other templates is that it doesn't have a template file associated with it. I created a file for it, but it didn't make a difference. I'm stumped. To sum up, If I look for sort=-created, limit=5, I get the same results at foo.com and foo.com/es. If sort=-created, limit=5, template=x, same results at both But if sort=-created, limit=5, template=y, I get the expected results at foo.com, but at foo.com/es, It only gets pages added before I installed the multilanguage modules. I haven't made any other changes to template y. Any ideas on troubleshooting template y?
caribou Posted June 20, 2014 Author Posted June 20, 2014 Good catch - they were being added through the API, and they weren't being set as active. I see this thread addresses the issue - I'll give it a try. https://processwire.com/talk/topic/4383-how-to-set-language-active-via-api/
caribou Posted June 20, 2014 Author Posted June 20, 2014 That worked! I just added this to my form after retroactively updating the other ones: <?php foreach ($languages as $language){ echo "<input type='hidden' name='status{$language}' value='1'>"; //Make active in all languages } ?> Thanks very much for your help!
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