louisstephens Posted July 30, 2018 Share Posted July 30, 2018 So I am building a dashboard for the front-end of a small app I am making, and I was wanting to display certain pages in the side bar based on the user. So far, I made a page reference field called page_author that allows a user to select from a list of users (I just pointed the page reference field to users under the admin).So far, that is working nicely, however, I have not hit a wall. I am not so sure how to output pages based on the selected user. In my dashboard template, I know I could do $current = $pages->find("template=secondary, page_author="); foreach($current as $list) { // some code here } But I guess I am struggling to figure out how to tie the logged in user to the selected user in page_author. Hopefully to clear things up: User "Bob" has created some pages and selected "Bob" in page_author. Now when he goes to their front-end dashboard, he will only see pages that have "bob selected. But if Amy goes to the dashboard, they will not see any items accredited to Bob, but she will see her own items. Link to comment Share on other sites More sharing options...
elabx Posted July 30, 2018 Share Posted July 30, 2018 3 hours ago, louisstephens said: So I am building a dashboard for the front-end of a small app I am making, and I was wanting to display certain pages in the side bar based on the user. So far, I made a page reference field called page_author that allows a user to select from a list of users (I just pointed the page reference field to users under the admin).So far, that is working nicely, however, I have not hit a wall. I am not so sure how to output pages based on the selected user. In my dashboard template, I know I could do $current = $pages->find("template=secondary, page_author="); foreach($current as $list) { // some code here } But I guess I am struggling to figure out how to tie the logged in user to the selected user in page_author. Hopefully to clear things up: User "Bob" has created some pages and selected "Bob" in page_author. Now when he goes to their front-end dashboard, he will only see pages that have "bob selected. But if Amy goes to the dashboard, they will not see any items accredited to Bob, but she will see her own items. For this to happen you must be using somewhere the $user variable which is the one that refers to the user in session. I'm thinking this is what you are looking for, so when Bob is logged in, $user will refer to Bob, and when Amy is logged in, it will refer to her user: $current = $pages->find("template=secondary, page_author=$user"); 4 Link to comment Share on other sites More sharing options...
louisstephens Posted July 30, 2018 Author Share Posted July 30, 2018 Thanks @elabx.. I did not initially realize that $user already had that information "saved". Works like a charm. 1 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