Results 1 to 12 of 12

Thread: MVC - a question about the relevance of controllers

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Posts
    7

    MVC - a question about the relevance of controllers

    Hi all,

    I am trying to create a PHP/MVC application without the help of a framework. When I start to do some serious development in PHP I may use a framework, but before that I thought it would be a good idea to gain an understanding of the principles of MVC.


    Suppose I have a page WidgetView.php containing the following code

    Code:
    <ul>
    <?php   
      $cList = new Widgets();
       for($j= 0; $j < $cList->count(); ++$j) {
              $c = $cList->item($j);
              	 print '<li>'.$c->getName().
              	 ' <a href= /"index.php?route=widget/edit&amp;widget_id=/"'
                   .$c->getID().'>edit</a></li>';    
        }
    
    ?>
    </ul>
    This page simply lists the names of widgets (fetched from the database table) and displays a link to edit an individual widget item.

    Now, clicking the "edit" link invokes the controller and the controller in turn serves up EditWidget_View.

    My question is : Why shouldn't the edit link directly invoke EditWidget_View ? The controller takes the input parameters from WidgetView and passes them on to EditWidget_View without any processing of any sort, it's merely functioning as a postman here. What is the practical use of routing the edit action through the controller ?


    Pardon me if the question sounds stupid. I hope someone here can help me.

    Thanks

    Crusoe
    Last edited by Crusoe; Sep 14th, 2010 at 11:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width