views:

12

answers:

1

I am rewriting a client's application from a crappy built as one huge blob of a project into a MVC application for obvious reasons.

In doing a view for pieces of it I am noticing the original programmer has plenty of statements where they change up images or put in different links based on the logged in user.

How does everybody that writes MVC applications handle this? Do you pass the username from the controller to the view to do this simple logic or should the controller handle all of that?

A: 

This should be set up either in the controller or the session, with generic place holders for the links.

i.e. if in Session

$_SESSION['userLink1']= "URL";

//Later in the views create it as this

<a href="<?php echo $_SESSION['userLink1'];">

Keep in mind this assumes that these images/links will consistently be there regardless of the user, only that the link content itself will change. If its on the user level as you described, load all the links into the session once at log in and the views will yank them out appropriately.

To actually get them in the session use your login controller to set them up upon the successful log in and when starting the session populate in some default place holders if non authorized users can also view the given pages.

CogitoErgoSum