- (11/14) Getting output from shell_exec() at all timesTAGS:Web ProgrammingWeb Server Admin
- (06/12) View Layer - Getting count of Entities in View in Cakephp 3TAGS:CakephpCake3
- (05/23) Changing URL in beforeRedirect() in Component - Cakephp 3TAGS:CakephpCake3Web Programming
- (01/28) Foundation CSS Framework ResourcesTAGS:FoundationCss
- (01/27) Change View File from Controller in CakePHP 3TAGS:CakephpCake3UsageWeb Programming
- (01/13) Loading Model/Table Anywhere in Cake3TAGS:Cake3Cakephp
- (10/06) CURL PHP 5.5 Issue on Windows (Using Twilio SDK)
Subscribe to my feed
Adding Anchors to Your CakePHP Generated Urls (#link)
Posted on 07/02/2009 at 09:02 am by Kevin Wentworth
Viewed 27,012 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
- $this->redirect(array('controller'=>'blog', 'action'=>'view', 1219, '#'=>'destination'));
That was easy wasn't it? Note the '#'=>'destination'. Sometimes it's the easy things that can stop and make you think, though.