Design patterns

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

Christopher, again a very clear explanation of a simple concept which gets people confused nonetheless. You're probably familiar with that one 16 page sticky thread on that other forum, trying to clarify, something you just did in one post :)
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Hockey - re: Navigation problems with controllers.

I've found it easier to maintain navigation links with controllers than I have with seperate pages for the different actions.

I have a 'menu module' that dynamically collects and creates the menu items (navigation) based on the users access privileges. The info is stored in an array of page information in the format of

Code: Select all

$PAGES = array(
  array('page' => '<pagename>', 'permission' => 0, 'action' => '<pageaction>');
);
(action being the keyword to use in the url generation - which is handled by another module)

This array can be static - i.e. in a config file, or generated from a DB table. (Flexibility has been my buzzword for the past month or so :P)

The menu module is passed the above array for the pages, and the user object, then iterates through comparing the permissions of the user, and the permissions of the page/action in the array. If they have the right access, then it is added to the menu and so forth.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

The thing that Front Controllers and Page Controllers share is what Fowler calls an Input Controller -- Actions do not contain the Input Controller part
That's the distinction I've been missing...and why I was refering to them as page controllers...I wish you realized that earlier...instead of making me write these long replies you could have said that right off the hop and I would have got it... :P

Cheers :)
Post Reply