We are doing this exact same thing for a long long long list of
counties in the United States. Each having their own sub-domain.
Here's our route:
Router::connect('/court-records-search/:thestate', array
('controller'=>'states','action'=>'index'), array('pass'=>array
('thestate')));
It will turn http://www.countycriminal.com/court-records-search/OH
into /states/index/OH
So in your case you could put: http://domain.com/products/milkjug, /
milk, /cofffee, /miproduct
Route: Router::connect('/products/:productname', array
('controller'=>'products','action'=>'view'), array('pass'=>array
('productname')));
If you categorize (using products/) it will help your SEO rankings.
Since Google/Yahoo/Bing like to keep track of where they are in the
page it would provide some consistency in what they are looking at.
It will group all of your products together so it knows where to put
things. Just throwing it out there to you.
Happy baking,
Chad
On Dec 16, 11:33 am, iWorm <[email protected]> wrote:
> Hi,
>
> I've found a method to implement Dynamic Route in CakePHP.
> If we develop a CMS program using CakePHP, we often let people to
> define their menu code. The menu code basically is the URL path.
> For example: An admin create a menu named 'Milk Product', and give
> this menu a code 'product'.
> He wish to access this menu via /product
>
> So we can add a static route in routes.php
> Router::connect('/product', array('controller' => 'product', 'action'
> => 'index'));
>
> But one day, he want to change the menu code from 'product' to
> 'milkproduct'? What to do then? Ask the site admin to edit the
> routes.php? Of course not.
>
> We can use the code below to resolve this problem.
>
> [CODE]
> $menus = '';
> $cache = ClassRegistry::init('cache');
> $cache->delete('routemenus');
> if($menus = $cache->read('routemenus') === false){
> $menusModel = ClassRegistry::init('Menu');
> $menus = $menusModel->find('all', array('conditions' => array
> ('parent_id' => '1')));
> $cache->write('routemenus', $menus);
>
> }
>
> foreach($menus as $menuitem){
> Router::connect('/' . $menuitem['Menu']['code'] . '/:action/*',
> array('controller' => $menuitem['MenuType']['code'], 'action' =>
> 'index'));
>
> }
>
> Router::connect('/', array('controller' => 'homepage', 'action' =>
> 'index'));
> [/CODE]
>
> We have 2 menu related tables: menus and menu_types.
> Their structure as belows:
> menus
> id
> menu_type_id
> parent_id
> lft
> rght
> code
> name
> created
> modified
>
> menu_types
> id
> code
> name
> created
> modified
>
> The code in menu_types means the controller name, and the code in
> menus means the path.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en