Manaus Posted July 25 Posted July 25 (edited) I'm managing my users base with the built in users API. Some of the users are learners, some are teachers. I tag them with the roles property. Now, I would like to have in my webiste a section, let's call it 'teachers' whose children bear the same informations I put in the users pages. That is if I load /teachers/paul/ I see on that page users->get('paul')->allDataBlabla . Is there a way to automatize this process of displaying and if possible also creataing pages under the /teachers/ root page? Maybe intercepting the querystring and doing the logic on a 'teacher' page? Thank you very much Edited July 25 by Manaus
Jan Romero Posted July 25 Posted July 25 (edited) If you were doing this you could just make user pages available whereever you want: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users Otherwise you could use UrlSegments or Path Hooks to load the requested user, such as: //requesting /teachers/paul $teacher = users()->get('roles=teacher, name=' . input()->urlSegment1); //urlsegments are already sanitized if (!$teacher->id) throw new Wire404Exception(); echo $teacher->firstname . ' ' . $teacher->lastname; Edited July 25 by Jan Romero 2
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