Nov 27, 2010
admin

Verifying the index page

At this step, all is done to get the index action showing the list. Make sure you pointed your virtual host to the www directory. the conf directory contains a virtual host sample that allows you to do that. Here is the steps to do that :

$ sudo cp conf/virtual-host-sample.conf /etc/apache2/sites-enabed/simplemvc.conf
$sudo vi /etc/apache2/sites-enabed/simplemvc.conf
// put your ServerName and the path to the DocumentRoot and Directory
<VirtualHost *:80>
ServerName www.simplemvc.dev
DocumentRoot /var/www/simpleMVC/www
<Directory /var/www/simpleMVC/www>
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
// save the file and exit.
$ sudo vi /etc/hosts
// add the following line to your hosts file
127.0.0.1 www.simplemvc.dev
// save the file and exit
Type now http://www.simplemvc.dev/?controller=Feed&action=index you should see a page like : http://jquerymobile.demo.simplemvc.berejeb.com!

Pretty cool no?
A question that I see coming is : why should I add /?controller=Feed&action=index if This is my first page? You are absolutely right. This can be solved either by a rewrite rule, or by 2 lines added in the bootstrap file. Let’s add them right now. Open the www/index.php file and add the following as the first lines in your try block :

$_REQUEST['controller'] = Toolbox::getArrayParameter($_REQUEST, 'controller', 'Feed');
$_REQUEST['action'] = Toolbox::getArrayParameter($_REQUEST, 'action', 'index');

This should add a default action and controller names if nothing is provided from the request.
You can see the rendering on the iphone, it is really good.
This is all for the indexAction. When clicking on the feed title, we are redirected to the detail page, which we will start implementing right now!

1 Comment

Leave a comment