Jump to content

[solved] Displaying Content based on "user"


louisstephens
 Share

Recommended Posts

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

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");

 

 

  • Like 4
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...