• Content Count

  • Joined

  • Last visited

Community Reputation

6 Neutral

About FlorianA

  • Rank
    Jr. Member
  • Birthday November 8

Profile Information

  • Gender
  • Location
    Northern Germany

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. It does work with dev version 3.0.93 Thanks a lot for your assistance, @adrian
  2. FlorianA

    That's a valuable hint. Up to now my concept was to restrict permissions not only for the "hide_year_of_birth" field but also for other more "private" user fields like street or phone numbers. That's why I didn't want to handle this one field by a global permission. But my plans break down anyway if the restricted fields aren't editable any more even for the user's own profile. So I have to look for another solution ... I think it will be something like a "view_extended_user_data" permission which applies not only to the year of birth but also to some other fields.
  3. Tracy Console? ... <google> ... Tracy Debugger ... Wow! What a wonderful tool! I should have discoverd that earlier. I think it would deserve a place on https://processwire.com/docs/tutorials/ Anyway, my problem persists even when trying the command above. My PW version is 3.0.61
  4. For one role I've tried these four cases, none of them filtered out any user with role "foo": !roles=foo roles!=foo !roles.name=foo roles.name!=foo
  5. It's easy to select all users who have a certain role. E. g.: users('roles=foo|bar') selects all users who have at least one of the roles "foo" or "bar". But I failed doing the opposite: selecting all users who don't have role "foo" or don't have role "bar". I even don't manage the case with only one role. Any ideas?
  6. FlorianA

    Not really. Every logged-in user should be able to view day and month of the birthday, but not on the year. If we want to know if the user is also allowed to see the year, we look into the "hide_year_of_birth" field. If we are not allowed to view this field we can't know if the the user wants to expose his age and therefore we assume "no".
  7. In my current project, I've extended the user template by two fields: birthday (Datetime: the user's birthday) and hide_year_of_birth (Checkbox: does the user want his year of birth to be hidden for other users?). Furthermore I'd like to have three groups of users: - Group 1 always sees years of birth for all users. - Group 2 sees only years of birth of these users who have unchecked their hide_year_of_birth flag. - Group 3 can't see a year of birth of any user. For implementing this, the field hide_year_of_birth has view permission only for groups 1 and 2. In the template file, if hide_year_of_birth is not viewable, a value true is assumed. function getBirthday($user) { return $user->hide_year_of_birth || !fields('hide_year_of_birth')->viewable() ? strftime(__('%d.%m.'), $user->getUnformatted('birthday')) : $user->birthday; } Unfortunately, this didn't work as I meant. When I logged in as a user of group 2, I saw the year of birth of another user with hide_year_of_birth checked. The debug output said that $user->hide_year_of_birth was 0, however fields('hide_year_of_birth')->viewable() was true. When I logged in as a user of group 1 or 3, it worked as expected. Edit: No, group1 doesn't work either, but that's why I've just hadn't thought about it in implementation - but it isn't relvant for this question either ;-) Could this be a bug which makes $user->hide_year_of_birth return the "empty" value for unviewable fields although the field is viewable? After I checked the field option "allow access value by API even if not viewable" for hide_year_of_birth, everything worked as expected also for the group 2.
  8. This works. Thank you very much. Florian
  9. function getSettings() { return pages()->get('/site-settings/'); } $home = $pages->get('/'); foreach ($home->children()->not(getSettings()->menu_filter) as $childPage) { // the not() part has no effect }
  10. In order to hide some pages from my site menu, I've defined a field called 'menu_filter' with field type 'Selector'. In my page editor, I assigned a value to the field by choosing the combo boxes 'template' 'Equals' 'event'. After that I tried to apply this selector to a WireArray in a template file, but the selector string was 'template=45' rather than 'template=event', that means it shows the template's id, not its name. Therefore the selector doesn't work in my code. How can I fix this?
  11. After some further thoughts I wonder if it is a good idea to activate the Multi-Language URLs at all for my site. I have a lot of pages that will probably never be published in an other than the default language, but users with other languages should see untranslated pages nevertheless in the default language - without any additional effort for the page author. Would it be a solution for this to leave the multi-language URL module away and keep only the multi-language fields? One URL for all languages would be sufficient for me. Are there any other drawbacks with this approach?
  12. FlorianA

    While it's generally a good idea to avoid globals in PHP I'm wondering what is the easiest way to access the PW API variables like $page, $user, $fields etc. from a function body within a template file. I would like to understand them as a kind of "superglobals", so I find it tediuos to pass them as parameters to every function that needs them. On the other hand, I haven't found a solution to access them as PHP globals within a function (with my humble PHP knowledge). Neither Jonathan's solution nor the $GLOBALS approach seems to work with PW "globals". Are there any best practices how to acces the PW API variables from a function?
  13. Thanks a lot @SiNNuT, it works! Would never have found it out myself - still seeing no API ...
  14. I have exactly the same problem, but I'd like to import my event pages by a command line script from another database. So I need to activate the language specific URLs programmatically, but I haven't found an API function to do this. Can anybody help me?
  15. FlorianA

    No template? But a page without template isn't possible, is it? Currently I'm setting the 'entry' page's name to it's ID in order to avoid generated names (timestamps) which seem to be longer.