0
votes

I read many posts on how to create a static page like About or Contact using CakePHP but still my page does not appear. Is there anything I missed? Please help since I started CakePHP today and I may have done some small mistake. Thanks. This is what I did.

  1. Create about.ctp inside View/Pages/

  2. Create route for the page Router::connect('/about', array('controller' => 'pages', 'action' => 'display', 'about'));

  3. Link to page in my default.ctp layout <a href="<?php echo Router::url('/about'); ?>">About</a>

2
what exactly doesn't work? if you go to www.web.com/about you don't see your page? or if you press the link (in 3) ) it takes you somewhere else? - Nunser
when I press the link url changes to www.web.com/about but the page does not load. - pabz
Please always mention your exact CakePHP version! btw. the files should be in /View/Pages with a capital P. - ndm
Ah yes it's a mistake here and I corrected it. I use version 2.4.6 (latest stable) - pabz
What you've described is the correct way, it works fine for me. Make sure debug mode is enabled (debug should be 1 or 2), try again and check the logs (app/tmp/error|debug.log) if you don't receive any error. Also check whether you can see the home page (/pages/home)? - ndm

2 Answers

0
votes

Probably you forgot to add new action in pages Controller

try this

public function about(){

}

UPDATE:

Also it is not necessary to rout display action always. Keep it simple you can do this as well

Router::connect('/about', array('controller' => 'pages', 'action' => 'about'));

Now you can view your about page at localhost/application/about

0
votes

you problem is here <a href="<?php echo Router::url('/about'); ?>">About</a>

Use this -

<?php echo $this->Html->link('about', array(
                          'controller' => 'pages',
                       'action' => 'about'
));

or

<a href="<?php echo Router::url('/pages/about'); ?>">About</a>