PeterDK Posted January 30, 2014 Posted January 30, 2014 Hi! Quick question. Hopefully... Is it possible to rename users to 'riders' and move those pages from behind the 'admin'? The url of 'users' would then be /riders/ridername (instead of /admin/users/ridername) This without breaking 'permissions' and 'groups'. Thanks!
kongondo Posted January 30, 2014 Posted January 30, 2014 (edited) Someone more knowledgeable than I will give you a better answer but am wondering..why not just create pages outside admin for each user if that's what you are after? Behind the scenes, users (i.e. those under admin/users) are also pages! So, you can create a parent page "riders" with child pages "ridername". You will just have to access them with the $page or $pages variables rather than $user. You can then associate users (created in Admin) with their pages (those under "riders"). A search of the forums will reveal this has been done before (and it gives you more options quickly, although users under Admin can also be extended [via the user template]). You might also want to check out the various PW modules that help manager user access on a page or field level. Edited for clarity Edited January 30, 2014 by kongondo 1
PeterDK Posted January 30, 2014 Author Posted January 30, 2014 Very good question! I see that in the future 50 to 100 of my 300 users (riders) would like to log in (for using the discussion module) or something something. Other (future) uses, subscribe them to the 'news' and 'new discussions' so they get a mail every time someone starts a topic. Good use case or not?
ryan Posted February 7, 2014 Posted February 7, 2014 You can make up your own users system, and sometimes it's the simplest route to achieve something. But I would try to get it done with regular PW users first. You can always map fictional page names to usernames via URL segments. For instance, if you had a template called 'riders' and you enabled 'URL segments' in the 'URLs' tab of your template, then your /site/templates/riders.php file could have code like this: if($input->urlSegment1) { $rider = $users->get("name=$input->urlSegment1"); if(!$rider->id || !$rider->hasRole("rider")) throw new Wire404Exception("Unknown rider"); // display rider echo "<h1>$rider->name</h1>"; echo $rider->body; // ...or whatever fields you wanted to output } else { // display list of riders foreach($users as $rider) { if(!$rider->hasRole("rider")) continue; echo "<li><a href='./$rider->name/'>$rider->name</a></li>"; } } 5
adrian Posted February 7, 2014 Posted February 7, 2014 Ryan, If Peter went with that approach, what would you recommend he implement in his search.php script to make it possible to find those fictional rider pages? Maybe something like this: $matches = $pages->find("title|body|sidebar~=$q, limit=50"); $rider_matches = $users->find("name~=$q, limit=50"); $matches->append($rider_matches); foreach($matches as $m) { if($m->template == 'riders'){ $out .= "<li><p><a href='/riders/$m->name/'>{$m->name}</a></p></li>"; } else{ $out .= "<li><p><a href='{$m->url}'>{$m->title}</a><br />{$m->summary}</p></li>"; } } 2
renobird Posted February 7, 2014 Posted February 7, 2014 I have 400+ users, and have done essentially what Ryan suggested above. It works quite well, and allows you to continue using all the build-in things related to users. 1
ryan Posted February 9, 2014 Posted February 9, 2014 If Peter went with that approach, what would you recommend he implement in his search.php script to make it possible to find those fictional rider pages? Your solution looks good, but would make the riders always appear at the bottom of the results. Maybe that's okay, but I think riders and other types of pages might be different enough that they'd warrant further segmentation or their own search, perhaps their own tabs at the top of the page, or regular pages in left column, riders in right column, etc. 1
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