Recent Posts
- (09/10) Fixing Warning: the ECDSA host key for 'github.com' differs from the key for the IP addressTAGS:Web Server Admin
- (12/26) CakePHP 3 - Getting List of Column Definitions from a Table (like schema())TAGS:CakephpCake3
- (09/14) Change Order of Loaded Behaviors in CakePHP 3TAGS:Cake3CakephpWeb ProgrammingPhp
- (05/29) CakePHP 3 - Accept JSON Header Only Working When Debug FalseTAGS:Web ProgrammingCakephpCake3
- (05/23) Remove All Events from Google Calendar (Reset Calendar)TAGS:Web ProgrammingPhp
- (11/08) Google Tag Manager (GTM) Not Firing Default PageView EventTAGS:Web ProgrammingJavascriptGoogle Tag Manager
- (10/13) In PHP, how do you get __toString() Magic Method Result without calling echo?TAGS:CakephpCake3Cakephp 13PhpWeb Programming
- (11/14) Getting output from shell_exec() at all timesTAGS:Web ProgrammingWeb Server Admin
Subscribe to my feed
MainelyDesign.com Blog
Adding Anchors to Your CakePHP Generated Urls (#link)
Posted on 07/02/2009 at 09:02 am by Kevin Wentworth
Viewed 35,386 times | 2 comments
This may seem simple and trivial, but it took me a little while to figure out. If it saves someone a little trial-and-error then great (I know I won't forget how to do it).
I needed to create a redirect in CakePHP that redirected to an inline, on-page anchor- <a name="destination">Scroll to Here</a>. Typing the link directly into the address bar of the browser, it would need to look like this: http://www.mainelydesign.com/blog/view/1219/#destination. The #destination is what I needed to figure out how to append to the redirected url. Turns out it was easy...
Use the Pound Sign (#) as a Key in Your Link Options
- echo $html->link('Click Me, Please', array('controller'=>'blog', 'action'=>'view', 1219, '#' => 'destination'));
or, Use the Pound Sign (#) as a Key in Your Redirect Call
That was easy wasn't it? Note the '#'=>'destination'. Sometimes it's the easy things that can stop and make you think, though.
Cheers,
-Kevin Wentworth
Tags for Adding Anchors to Your CakePHP Generated Urls (#link)
Cakephp | Web Programming | Usage | Usability
Comments for this Posting
Posted by bancer
on 29/4/10
The same result you can achieve with
echo $html->link('Click Me, Please', array('controller'=>'blog', 'action'=>'view', 1219, '#destination'));
Sorry, comments are closed for this posting.
Please Email Kevin if you have any questions. Thanks!
Posted by SooxnogYBix
on 5/3/10
Wassup, First time here, this site seems like a very informative board.
Will try to help in to the best I am able :)