[Solar-talk] _getActionHref
Rodrigo Moraes
rodrigo.moraes at gmail.com
Mon Aug 6 14:03:15 CDT 2007
On 8/6/07, Jeff Surgeson wrote:
> Tipos_App_Adm_Base in _setup()
>
> // Set the main navigation menu using 'named' keys.
> $this->layout_nav = array(
> 'adm' => array(
> 'href' => $this->_getActionHref('adm', array(
> 'controller' => '',
> 'action' => 'index',
> )),
> 'text' => 'TEXT_ACTION_INDEX',
> ),
Oh, I see. I have changed it since that commit and don't have this
method anymore, so that's why I couldn't find it. So here's a
explanation for the current version - the meaning is the same. What I
have now is:
$this->layout_nav = array(
'adm' => array(
'href' => $this->helper('routeUri', array(
'controller' => '',
'action' => 'index',
))->quick(),
'text' => 'TEXT_ACTION_INDEX',
),
And it is all related to building action links for the main
navigational list using the router. First, some background: 'routeUri'
is a controller helper built using helper(), which is a method from
Tipos_Controller_Page. routeUri builds action/anchors for routes, and
yes, URI building is verbose using the router, but I think the
benefits pay the inconvenience.
'href' and 'text' are keys used by Tipos_View_Helper_ListNav to build
lists. I prefer to always use a keyed array because access is easier
if I need a URI from any list later; also because of the relatively
complex uri building process, it is easier to set the active item just
referring to its key, for example: $this->layout_nav_active = 'adm'.
The uri can change, the key is the same.
I've been thinking for ages to write a tutorial showing how to use the
router; in the mean time, if anybody here is interested to try it, I'd
love to help. Please feel to contact me, or even join #solarphp at
freenode.org - we are there 24 hours a day, 7 days a week, except on
mondays 9-10 p.m. when we make a break to watch Heroes on NBC. :)
-- rodrigo
More information about the Solar-talk
mailing list