|
I am trying to use the redirector action helper to call gotoRoute.
The page I need to go to is something like http://mywebsite.com/blog/documentation/tags/#add which would take me to the "add" anchor in the tags page. To go to that URL, my code is: $this->_helper->redirector->gotoRoute(array('module' => 'blog', 'controller' => 'documentation', 'action' => 'tags')); That takes me to http://mywebsite.com/blog/documentation/tags/ but I need to add "#add" to the end of that. Any idea how one would accomplish that? Thanks Jason -- Jason Austin Senior Solutions Implementation Engineer NCSU - OIT - Outreach Technology [hidden email] |
|
The gotoRoute() method doesn't support hashes, but you can accomplish this by using the url action helper to construct the url based on your route, and then concatenate your hash to it. Then call the redirector's gotoUrl method:
$url = $this->_helper->url->url(array('module' => 'blog', 'controller' => 'documentation', 'action' => 'tags')); $url .= "#add"; $this->_helper->redirector->gotoUrl($url); -- Hector On Wed, Dec 9, 2009 at 1:51 PM, Jason Austin <[hidden email]> wrote: I am trying to use the redirector action helper to call gotoRoute.
--
Hector Virgen |
|
In reply to this post by Jason Austin
Funny that you posted this because I have the same issue I was about to tackle with a comments anchor. I hope you get a good response. I will let you know if I find out anything.
On Wed, Dec 9, 2009 at 4:51 PM, Jason Austin <[hidden email]> wrote: I am trying to use the redirector action helper to call gotoRoute. |
|
In reply to this post by Hector Virgen
Maybe one could add a target to the gotoRoute method in the future. I can't believe that people don't need to do something like this often.
Similar to $url = $this->_helper->url->url(array('module' => 'blog', 'controller' => 'documentation', 'action' => 'tags', 'anchor' =>'comments')); On Thu, Dec 10, 2009 at 1:02 PM, Hector Virgen <[hidden email]> wrote: The gotoRoute() method doesn't support hashes, but you can accomplish this by using the url action helper to construct the url based on your route, and then concatenate your hash to it. Then call the redirector's gotoUrl method: |
|
It should be possible to extend the redirector helper to create your own that accepts a hash as the 5th parameter. Since the action helper broker uses a LIFO stack, you can even use the same helper name "redirector".
-- Hector On Thu, Dec 10, 2009 at 10:06 AM, Fred Jiles <[hidden email]> wrote: Maybe one could add a target to the gotoRoute method in the future. I can't believe that people don't need to do something like this often.
--
Hector Virgen |
|
Thanks guys. The most straight forward way was using the URL helper,
adding the hash to the end of the URL, then using gotoUrl(). One caveat was that I had to do the following to not get the baseUrl() to be added twice: $this->_helper->redirector->setPrependBase('')->gotoUrl($this->_helper->url->url(array(..options...), 'default', true) . '#hash'); If you don't setPrependBase to '' in the redirector you will get something like http://mywebsite.com/subdir/subdir/module/... instead of http://mywebsite.com/subdir/module/... Hope this helps. I smell a feature request for adding hashes to routes & url helpers :) Thanks! Jason On Thu, Dec 10, 2009 at 1:09 PM, Hector Virgen <[hidden email]> wrote: > It should be possible to extend the redirector helper to create your own > that accepts a hash as the 5th parameter. Since the action helper broker > uses a LIFO stack, you can even use the same helper name "redirector". > > -- > Hector > > > On Thu, Dec 10, 2009 at 10:06 AM, Fred Jiles <[hidden email]> wrote: >> >> Maybe one could add a target to the gotoRoute method in the future. I >> can't believe that people don't need to do something like this often. >> Similar to >> $url = $this->_helper->url->url(array('module' => 'blog', >> 'controller' => 'documentation', 'action' => 'tags', 'anchor' >> =>'comments')); >> >> >> On Thu, Dec 10, 2009 at 1:02 PM, Hector Virgen <[hidden email]> wrote: >>> >>> The gotoRoute() method doesn't support hashes, but you can accomplish >>> this by using the url action helper to construct the url based on your >>> route, and then concatenate your hash to it. Then call the redirector's >>> gotoUrl method: >>> $url = $this->_helper->url->url(array('module' => 'blog', >>> 'controller' => 'documentation', 'action' => 'tags')); >>> $url .= "#add"; >>> $this->_helper->redirector->gotoUrl($url); >>> -- >>> Hector >>> >>> >>> On Wed, Dec 9, 2009 at 1:51 PM, Jason Austin <[hidden email]> >>> wrote: >>>> >>>> I am trying to use the redirector action helper to call gotoRoute. >>>> The page I need to go to is something like >>>> http://mywebsite.com/blog/documentation/tags/#add which would take me >>>> to the "add" anchor in the tags page. To go to that URL, my code is: >>>> >>>> $this->_helper->redirector->gotoRoute(array('module' => 'blog', >>>> 'controller' => 'documentation', 'action' => 'tags')); >>>> >>>> That takes me to http://mywebsite.com/blog/documentation/tags/ but I >>>> need to add "#add" to the end of that. Any idea how one would >>>> accomplish that? >>>> >>>> Thanks >>>> Jason >>>> >>>> -- >>>> Jason Austin >>>> Senior Solutions Implementation Engineer >>>> NCSU - OIT - Outreach Technology >>>> [hidden email] >>> >> > > -- Jason Austin Senior Solutions Implementation Engineer NCSU - OIT - Outreach Technology [hidden email] |
|
I can see this being useful to many people, too. Maybe instead of a 5th parameter, there can be a setHash() method. So usage would be like this:
$redirector = $this->_helper->redirector;
$redirector->gotoRoute(/* ... */); $redirector->setHash('add');
$redirector->redirectAndExit(); -- Hector On Thu, Dec 10, 2009 at 11:53 AM, Jason Austin <[hidden email]> wrote: Thanks guys. The most straight forward way was using the URL helper,
--
Hector Virgen |
|
Possibly. Although I think its more than just a redirector helper
issue, as the url view and action helpers also don't account for the hash. That's why I was thinking it should happen at the route level, where 'module', 'controller', and 'action' are reserved words, you could do the same with 'anchor' or 'hash'. So you would build the following URL: http://mywebsite.com/blog/documentation/tags/#add like: $routeArgs = array( 'module' => 'blog', 'controller' => 'documentation', 'action' => 'tags', 'anchor' => 'add', ); $this->_helper->redirector->gotoRoute($routeArgs); or in the view like: $this->view->url($routeArgs); so they both would build the URL the same way. Thoughts? - Jason On Thu, Dec 10, 2009 at 4:31 PM, Hector Virgen <[hidden email]> wrote: > I can see this being useful to many people, too. Maybe instead of a 5th > parameter, there can be a setHash() method. So usage would be like this: > $redirector = $this->_helper->redirector; > $redirector->gotoRoute(/* ... */); > $redirector->setHash('add'); > $redirector->redirectAndExit(); > -- > Hector > > > On Thu, Dec 10, 2009 at 11:53 AM, Jason Austin <[hidden email]> > wrote: >> >> Thanks guys. The most straight forward way was using the URL helper, >> adding the hash to the end of the URL, then using gotoUrl(). One >> caveat was that I had to do the following to not get the baseUrl() to >> be added twice: >> >> >> $this->_helper->redirector->setPrependBase('')->gotoUrl($this->_helper->url->url(array(..options...), >> 'default', true) . '#hash'); >> >> If you don't setPrependBase to '' in the redirector you will get >> something like http://mywebsite.com/subdir/subdir/module/... instead >> of http://mywebsite.com/subdir/module/... >> >> Hope this helps. I smell a feature request for adding hashes to >> routes & url helpers :) >> >> Thanks! >> Jason >> >> On Thu, Dec 10, 2009 at 1:09 PM, Hector Virgen <[hidden email]> wrote: >> > It should be possible to extend the redirector helper to create your own >> > that accepts a hash as the 5th parameter. Since the action helper broker >> > uses a LIFO stack, you can even use the same helper name "redirector". >> > >> > -- >> > Hector >> > >> > >> > On Thu, Dec 10, 2009 at 10:06 AM, Fred Jiles <[hidden email]> >> > wrote: >> >> >> >> Maybe one could add a target to the gotoRoute method in the future. I >> >> can't believe that people don't need to do something like this often. >> >> Similar to >> >> $url = $this->_helper->url->url(array('module' => 'blog', >> >> 'controller' => 'documentation', 'action' => 'tags', 'anchor' >> >> =>'comments')); >> >> >> >> >> >> On Thu, Dec 10, 2009 at 1:02 PM, Hector Virgen <[hidden email]> >> >> wrote: >> >>> >> >>> The gotoRoute() method doesn't support hashes, but you can accomplish >> >>> this by using the url action helper to construct the url based on your >> >>> route, and then concatenate your hash to it. Then call the >> >>> redirector's >> >>> gotoUrl method: >> >>> $url = $this->_helper->url->url(array('module' => 'blog', >> >>> 'controller' => 'documentation', 'action' => 'tags')); >> >>> $url .= "#add"; >> >>> $this->_helper->redirector->gotoUrl($url); >> >>> -- >> >>> Hector >> >>> >> >>> >> >>> On Wed, Dec 9, 2009 at 1:51 PM, Jason Austin <[hidden email]> >> >>> wrote: >> >>>> >> >>>> I am trying to use the redirector action helper to call gotoRoute. >> >>>> The page I need to go to is something like >> >>>> http://mywebsite.com/blog/documentation/tags/#add which would take me >> >>>> to the "add" anchor in the tags page. To go to that URL, my code is: >> >>>> >> >>>> $this->_helper->redirector->gotoRoute(array('module' => 'blog', >> >>>> 'controller' => 'documentation', 'action' => 'tags')); >> >>>> >> >>>> That takes me to http://mywebsite.com/blog/documentation/tags/ but I >> >>>> need to add "#add" to the end of that. Any idea how one would >> >>>> accomplish that? >> >>>> >> >>>> Thanks >> >>>> Jason >> >>>> >> >>>> -- >> >>>> Jason Austin >> >>>> Senior Solutions Implementation Engineer >> >>>> NCSU - OIT - Outreach Technology >> >>>> [hidden email] >> >>> >> >> >> > >> > >> >> >> >> -- >> Jason Austin >> Senior Solutions Implementation Engineer >> NCSU - OIT - Outreach Technology >> [hidden email] > > -- Jason Austin Senior Solutions Implementation Engineer NCSU - OIT - Outreach Technology [hidden email] |
|
That's a good point. Making it a reserved word would make a lot of sense, but I'd be afraid of breaking sites that already use "anchor" (like maybe an Anchors R Us website that sells anchors for ships?) "Hash" may also already be in use by some sites. But I really like the idea, maybe you should open a feature request to get some more input on the implementation.
-- Hector On Thu, Dec 10, 2009 at 1:49 PM, Jason Austin <[hidden email]> wrote: Possibly. Although I think its more than just a redirector helper
--
Hector Virgen |
|
In reply to this post by Jason Austin
+1 -- takeshin |
|
+1 On 10 Dec 2009, at 22:54, takeshin <[hidden email]> wrote: > > > > Jason Austin wrote: >> >> >> Hope this helps. I smell a feature request for adding hashes to >> routes & url helpers :) >> >> > > +1 > > -- > takeshin > > -- > View this message in context: http://n4.nabble.com/Adding-a-to-a-URL-using-gotoRoute-tp957210p960642.html > Sent from the Zend Framework mailing list archive at Nabble.com. |
|
isn't the use of named anchors deprecated?
On Fri, Dec 11, 2009 at 7:23 AM, Daniel Latter <[hidden email]> wrote:
|
|
The "name" attribute is deprecated in XHTML, in favor of the "id" attribute (which behaves like the old "name" attribute did).
-- Hector On Thu, Dec 10, 2009 at 5:17 PM, Cameron <[hidden email]> wrote: isn't the use of named anchors deprecated?
--
Hector Virgen |
|
I've added an improvement request to Zend_Controller for this.
http://framework.zend.com/issues/browse/ZF-8522 On Thu, Dec 10, 2009 at 8:34 PM, Hector Virgen <[hidden email]> wrote: > The "name" attribute is deprecated in XHTML, in favor of the "id" attribute > (which behaves like the old "name" attribute did). > > -- > Hector > > > On Thu, Dec 10, 2009 at 5:17 PM, Cameron <[hidden email]> wrote: >> >> isn't the use of named anchors deprecated? >> >> On Fri, Dec 11, 2009 at 7:23 AM, Daniel Latter <[hidden email]> >> wrote: >>> >>> +1 >>> >>> On 10 Dec 2009, at 22:54, takeshin <[hidden email]> wrote: >>> >>>> >>>> >>>> >>>> Jason Austin wrote: >>>>> >>>>> >>>>> Hope this helps. I smell a feature request for adding hashes to >>>>> routes & url helpers :) >>>>> >>>>> >>>> >>>> +1 >>>> >>>> -- >>>> takeshin >>>> >>>> -- >>>> View this message in context: >>>> http://n4.nabble.com/Adding-a-to-a-URL-using-gotoRoute-tp957210p960642.html >>>> Sent from the Zend Framework mailing list archive at Nabble.com. >> > > -- Jason Austin Senior Solutions Implementation Engineer NCSU - OIT - Outreach Technology [hidden email] |
| Powered by Nabble | Edit this page |
