Jump to content

stange behavior


virtualgadjo
 Share

Recommended Posts

Hi all,

first of all, as it's my first post here, thanks so much for this incredible CMS, thanks for all my question i've found answers here without even asking them and, of course, i can't say thanks enough to Ryan incredible job...

i'm currently working on a bilingual website (pw 3.0.165 php 7.2), funny enough (i'm french), this time default language is english and the second one french but i think that doesn't matter...
this website stores events and i have an page having itself all the events as hidden chidren pages, template for an event is... un_event with many fields, some of them bilingual
as i'm supposed to display the number of events available on all the pages at different places ("see the xx events" with a link to the event page) in my _init.php file i've set a count of the one_event pages and this is where the funny thing is
 

$nevents = $pages->count('template=un_event, include=hidden');
// in the default language see the <?php echo $nevents; ?> language works fine
// in french $nevents is 0
$nevents = $pages->count('template=un_event, include=all');
// works fine in both languages but implies that even unpublished pages would be taken in account

just to be complete, same behaviour with count($pages->get(1032)->children) count($pages->find('template=un_event, include=hidden')) and so on, in english, correct number as the result, in french 0

as a test, wondering if it was the fact that this was in the _init.php file, same thing if i use the same code on top of a page (all my files have the namespace processwire statement on top, i'm essentially a php guy ?)

other test, i've done the same thing but setting all the one_event pages as visible (not hidden), same result

is there something i haven't undestood or have forgotten with this all/hidden option when it comes to multilingual websites? probably ?

have a nice day
chris

Link to comment
Share on other sites

Bonjour Chris, and welcome to the ProcessWire forums.

You should be able to get the correct counts with this method. The digit you see there is simply the language page ID (setup -> languages -> hover over the language code).

I agree that this is not very intuitive, compared to most PW API methods... An alias selector like lang=fr (language shortcode) would be easier to memorize.

Link to comment
Share on other sites

Hi Dragan,

and thanks a lot for your answer ?
actually, that's the kind of method i've ended with, i just found strange that the result worked for one language, the default one, and not a secondary one but thanks to you all guys here, i've learnt a lot of ways to filter results with pw options (for example excluding unpublished pages after an include=all in a foreach) and everything works fine for me, it was a little surprising when i first ran into this 0

being french i mostly make multilingual website when it comes to job ones and gosh, pw made this so easy for even complicated application that the first time it just coughed a little i had to tell my surprise ?

have a nice day

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...