I am building a forum into an existing website with CakePHP 3, and I have controllers Users and Forumposts (among others).
I am making a page (/forumposts/user/<user_id>) that looks up all the forum posts where the user id of the post matches the user id in the url.
That works great since I save the ID as part of the forum post in the user, but I want the user lookup page to contain the username and some other user information from the usercontroller.
I have properly setup my modal assosiations, but I can’t figure out how to exactly display userdata in the forumpost controller for the user page. Here is my current code for the forumpost controller and the user page:
The key conceptual takeaway here is that you’re not getting data “from another controller”. You’re getting data from another table. The other controller just happens to use that table as it’s default source.
I do not have any existing code for accessing userdata. All I am doing is rendering the two paginators for the user’s posts and replies, but that isn’t grabbing any userdata, just filtering the user_id to match the id in the url. The page just renders 2 tabs, one for replies, one for posts.
I don’t understand how they relate to looking up a user’s name and profile picture based on a user ID, and I would rather not post the view code since it is unnecessary. If you can share why you need the code or what specific part you need, I can post that.
Once again, all I need to do is use a variable that I already have (user_id), and look up the user’s information based on it.
Here is a screenshot of what the page currently looks like. I want the spots in brackets to have userdata in them, based on the ID in the URL. The two paginators are working fine and nothing about them needs to be changed. I think you guys misunderstood my issue.