SamC Posted January 15, 2017 Share Posted January 15, 2017 I'm thinking of extending my news section which I've posted here previously which includes the following (put over a few lines to make it easier to read): // news-index.inc //LOOP <?php $publish_date = date('d/m/y', $entry->created); $created_by = $entry->createdUser->displayName; // I added displayName field so to not show the actual login usernames on the site ?> <div class='entry-info'> <span class='fa fa-calendar' aria-hidden='true'></span> Posted by <span class='entry-highlight'><?php echo $created_by; ?></span> on <span class='entry-highlight'><?php echo $publish_date; ?></span> </div> //END LOOP Now I was thinking to link the '$created_by' output to a page which lists the news items written by that user. For example, say 'Sam' is the author, how does this work in PW? site.com/news site.com/news/sam/ << something like this? Not sure how to go about this. Could I use the same news-index.inc template to output this because the markup will be the same? Any hints are appreciated, thanks. Link to comment Share on other sites More sharing options...
kixe Posted January 15, 2017 Share Posted January 15, 2017 Allow urlSegments for this template. Create a selector including this urlSegment (user name). Read more about selectors: https://processwire.com/api/selectors/ Read more about urlSegments: https://processwire.com/api/variables/input/ 2 Link to comment Share on other sites More sharing options...
kongondo Posted January 15, 2017 Share Posted January 15, 2017 Here's a complete example from the module Blog. 2 Link to comment Share on other sites More sharing options...
SamC Posted January 15, 2017 Author Share Posted January 15, 2017 Ok thanks, I'll give it a go this week. Link to comment Share on other sites More sharing options...
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