Created
June 12, 2012 19:38
-
-
Save rvsjoen/2919664 to your computer and use it in GitHub Desktop.
Component routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->_segment_map = array( | |
"items" => array( | |
"item" => array( | |
"layout" => array( | |
"new" => "new" | |
"edit" => "edit" | |
) | |
) | |
), | |
"item" => "items, | |
"featured" => "items", | |
"broken" => "items" | |
) | |
1. Look up view (from Itemid or otherwise) in the keys of first level | |
2. If lookup in first level returns a string, do another lookup with that string to see if we | |
can find a better root alias | |
3. If lookup in first level returns an array, add key to segments and continue to next level | |
4. Look up view in second level | |
5. If we get another array, add the key and continue, if we get a string | |
- Check this array for a layout="" match and add the required prefix if need be | |
We have 3 menu items (with aliases) | |
test-items Itemid 12 | |
test-featured Itemid 13 | |
test-broken Itemid 14 | |
Now, the following URL mappings should apply | |
&Itemid=12 /test-items | |
&Itemid=13 /test-featured | |
&view=items /test-items | |
&view=featured /test-featured | |
&view=broken /test-broken | |
&view=item&id=1 /test-items/item/1 | |
&view=item&id=1&layout=edit /test-items/item/1/edit | |
&view=item&layout=edit /test-items/item/new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In addition, generating a link using JRoute::_('&view=item&id=1') on test-broken or test-featured, should also provide the link /test-items/item/1 instead of the default which is /test-broken/item/1 or /test-featured/item/1