Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/30/2021 in all areas

  1. This week we focus in on a new and unique Inputfield module added to the core that enables a lot of useful new input capabilities for tags, sortable multiple selection and custom user input. I introduced it in last week's forum post, but it was further improved this week and reached a point where I thought it would need some dedicated documentation, so this post dips into that and goes quite a bit more in-depth than last week’s. I never got around to bumping the version to 3.0.176 because the module wasn't quite done till Thursday (kept updating with improvements), but just in case there's any confusion about versions between last week and this week, I bumped it to 3.0.177 even though it contains what was originally intended for 3.0.176, plus more— https://processwire.com/blog/posts/pw-3.0.177/
    14 points
  2. Maybe a bit off-topic but still interesting (for Linux users at least)
    1 point
  3. I've been itching to show this one off for ages.... JoinTheRez.com is the companion website to a science fiction podcast and comic which aims to help pre-teens build emotional resilence and mental well being. The story includes supportive themes and messages based on research by the University of Sussex CRESS Lab led by Professor Robin Banerjee, Professor of Kindness at the University of Sussex (no really). In the comic, which is set in the future, our heroes are able to contact young people in the current day using a mobile phone. We ran with this idea to create a phone interface for the site which enables users to undertake lots of different activities including games (Fart Cow Frisbee!) , puzzles, a podcast player, and even recording audio messages to send to the characters. There's a section for adults which includes lesson plans and teaching resources. We used PW to allow the client to manage various bits of content including messages, a news feed and the podcasts themselves. We created a bespoke module for an online Survey for the site as well building the code to handle distribution of the podcasts including the RSS feed and scheduled release of episodes - although in the end the podcast was picked up by GenZ / PRX in the states so they are handling the audio feed now. Notable modules we used were: ProCache (first time we've used it - works well) ProForms (for a contact form, we ended up building our own module for a more complex survey) Tracey Debugger (of course). It was a lot of work - I did have to spend much too long chosing the best fart noises for some of the games - but it was a lot of fun.
    1 point
  4. @Orkun, do you know about $page->listable()? It determines whether a page may appear in Page List (and also PageListSelect inputfields, which is probably something you want too). So you could do: $wire->addHookAfter('Page::listable', function(HookEvent $event) { /* @var Page $page */ $page = $event->object; if(!$page->editable() && !$page->addable()) $event->return = false; }); You can hook ProcessPageListRender::getNumChildren to customise the child count. But in some cases depending on what is determining a page's listable status you might decide it's not worth the trouble. Here's one way you might do it (in /site/ready.php): // Work out which templates are editable or addable for the user and store them on the $user object // Doing this here to avoid doing it repeatedly in the getNumChildren hook if(!$user->isSuperuser() && $page->template == 'admin') { $user_roles_ids = $user->roles->explode('id'); $allowed_templates = []; foreach($templates as $template) { $edit_add_roles = array_merge($template->editRoles, $template->addRoles); if(count(array_intersect($user_roles_ids, $edit_add_roles))) $allowed_templates[] = $template->name; } $user->allowed_templates = $allowed_templates; } // Set a selector to correct the children count $wire->addHookBefore('ProcessPageListRender::getNumChildren', function(HookEvent $event) { $user = $event->wire('user'); if($user->isSuperuser()) return; $selector = 'template=' . implode('|', $user->allowed_templates); $event->arguments(1, $selector); }); Be aware that there are some other areas you probably want to consider if you are hiding pages in Page List. Here are some pointers to get you started: Pages that can be found in the admin search - look at manipulating the selector by hooking ProcessPageSearch::findReady Pages that can be found in Lister - look at manipulating the selector by hooking ProcessPageLister::getSelector
    1 point
×
×
  • Create New...