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 <[email protected]> wrote:

> 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 <[email protected]> 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 <[email protected]>
> > 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 <[email protected]>
> 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 <[email protected]>
> >> > 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 <[email protected]>
> >> >> 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 <[email protected]
> >
> >> >>> 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
> >> >>>> [email protected]
> >> >>>
> >> >>
> >> >
> >> >
> >>
> >>
> >>
> >> --
> >> Jason Austin
> >> Senior Solutions Implementation Engineer
> >> NCSU - OIT - Outreach Technology
> >> [email protected]
> >
> >
>
>
>
> --
> Jason Austin
> Senior Solutions Implementation Engineer
> NCSU - OIT - Outreach Technology
> [email protected]
>

Reply via email to