the mainmenu showing only these menuitems which are translated into the active language
(ex.: “blog” will display in the mainmenu for /en/ users only if there is a file /en/blog/blog.en.txt"… and so on)
the sitewidetagcloud in the footer should be filtered by language as well
(each .txt file contains “Tags:” field with tags labeled in appropriate language)
3a)
the “listbytags” page where, without changing the active language, users could choose to see all “language1tags”, “language2tags”, language3tags" by clicking the appropriate button
3b)
still the same “listbytags” page where, without changing the active language, users could list all the pages tagged with “Year” (nevermind the language)
a private webmaster page that lists all the pages/subpages/subsubpages… where I could see, at a glance, side-by-side, available translations
I mean a table like :
| UID | LANG 1 | LANG 2 | LANG 3 |
| uid | not yet | ok | not yet |
seems logical and would be nice. The problem is that
content($lang)->exists()
sends true (or is ignored ?) even if there is no translation available.
What it may come from ?
The function should return false if the content file does not exist; it will, however, return true, if the file exists and there is no translated content in it. The content file for the default language is always created via the panel, even if you only create content in a non-default language. The other languages are not created by default, only if you actually save the (empty) content.
So does the function really return true even if the file does not exist?
Kirby 2.3 will have the $field->isTranslated() method which will let you check if a field is actually translated (as compared to the default language).
Edit: I just tested this and indeed, it does not seem to work. I could have sworn it worked when I tested this a little while ago.
Are you testing $page->content($lang)->exists() or $page->content($lang)->$field()->exists()? The latter should work, while the first example would just return an empty “exists” field.
I just checked in the source code. There is a Content::exists() method and it checks if the content file exists. So the docs are correct. Strange that it is not working for you.
Yeah, I checked the source code as well, but maybe it is language agnostic? I wonder if any of these work with the language code; I just added the codes after @distantnative’s remark … Need to check that again, or it should be implemented in the upcoming version.
I meant that your workaround seems hard to be converted as replacement of “if($page->content($lang)->exists())… do the stuff” because it applies to 1 language at a time, while - to solve my point 4 (see my first post) - I need all languages side-by-side
as for lang sensitive tagclouds (pt 2, 3a, 3b) I don’t see how to convert your workaround into a variable. I’ve tried some other ways :
I added an appropriate language code to each “Tags:” field in aim to “filterby(’tags’, $activelang)” the results coming from tagcloud plugin. The final results are incorrect, depending on language.
I’ve tried to add “case ‘lang’” to tagcloud plugin $options. Unsuccessfully (the new “case” was ignored).
I’ve tried multiple tagclouds but once I loose pagination, once home pages.
Yeah, but you should be able to get all the relevant information by looping through all languages and then check for each language if the page exists, something like that:
Here is what I found to satisfy pt 4 (see initial post above) thanks to your suggestions, Texnixe.
The table lists pages/urls in given language only if corresponding “.lang.txt” file phisically exists. It bypasses Kirby internal logic with strpos() which allows to have correct aswers even when there are pages that doesn’t exist in default language.