Warning: Illegal string offset '_imagedir' in /home/cakephpf/public_html/lofiversion/index.php on line 545

Warning: Illegal string offset '_emodir' in /home/cakephpf/public_html/lofiversion/index.php on line 546
CakePHP UnOfficial Community Forum > How to make a link for a new page
Help - Search - Member List - Calendar
Full Version: How to make a link for a new page
CakePHP UnOfficial Community Forum > Layouts and Design

I am learning cakephp and my installation is as follow


now I created a basic page and in the elements I created the top navigation links. I wanted to create an About us page, so under pages folder, where I have my home.ctp page, I created a page called about.ctp. Then in elements top.ctp page I entered the link as

<li><a href="wordpress/pages/about">About Us</a></li>
and when I click it doesnt find the page. Then I tried this

<li><a href="/pages/about">About Us</a></li>
and that didnt work either
You don't want to be adding links manually. Use the HtmlHelper link function instead, like this:

echo '<li>' . $this->Html->link('About Us', array('controller' => 'pages', 'action' => 'display', 'about')) . '</li>';

That way Cake will figure out what the right URL to the page is, saving you a lot of headaches wink.gif

Also try reading the basics/tutorial on http://book.cakephp.org/ , it covers these kind of essential things.
Hi, this post is a little bit older but I am also currently learning cakephp and stuck on a linking problem too.

I'm using this Code

<?php echo $this->Html->link($test2['content'], $this->Html->url(array('controller' => 'users', 'action' => 'add', '?' => array('group' => 'company') ))); ?>

My Project is located under localhost/test

what I expect is that:


what I got is:


even if I put out the whole URL I get:


Is the line of code wrong or do I have to customize something with routes?! blink.gif
Sir P
Hello winniwinter,

When you use the url attribute I don't think you can pass the controller value..try not something like this (untested) ...


echo $html->link($test2['content'], array('controller'=>'users', 'action' => 'add', '?' => array('group'=>'company')));

As I said, that is untested. A sure fire way (not very cake though) would be:


echo $html->link($test2['content'], array("controller"=>"users", "action" => "add", "?group=company"));

Or even:


echo $html->link($test2['content'], array("controller"=>"users", "action" => "add?group=company"));

Have a play.

Good luck.
I'm just geeting started with this one, where should I start guys?
Sir P


hey mr biggrin.gif
you can use this way:

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

this code: Router::url('/',true); definiting about your base url: http://localhost/wordpress/blabla/

/pages/about : controller = pages | action = about


okey, hopefully help biggrin.gif
sorry, if my bad english: D
So nice thread, thanks to all of you for sharing your suggestion. its really so hlepful for me.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2015 Invision Power Services, Inc.
Lo-Fi 1.1 iDS Beta, Originally written by Matt,
re-written by Shaun Harrison, Layer 04.com, for pre IPB2.0 versions.