Re: Route question

2010-09-01 Thread Miles J
You could try using a custom route class:

http://mark-story.com/posts/view/using-custom-route-classes-in-cakephp

http://cakedc.com/eng/pierre_martin/2010/08/05/i18n-routes-with-cakephp-1-3

On Aug 31, 10:27 am, cricket zijn.digi...@gmail.com wrote:
 2010/8/30 Harald Martin Bråttbåkk wynksaiddest...@googlemail.com:

  Hello,

  i simply want to change the default routing pattern http://
  example.com/controller/action/param1/param2/param3 into http://
  example.com/param1/controller/action/param2/param3. Is there a simple
  way to do this?

 I'm not sure about doing it with generic controller and action. Also,
 the regular expressions necessary will depend on what the params are
 expected to be. For example, if you wanted URLs like so:

 http://www.whatever.com/en/catalogs/some_string123/456

 Router::connect(
         '/:param1/catalogs/:param2/:param3',
         array(
                 'controller' = 'catalogs',
                 'action' = 'view'
         ),
         array(
                 'param1' = '[a-z]{2}',
                 'param2' = '[_a-z0-9]+',
                 'param3' = '[0-9]+'
                 'pass' = array(
                         'param1', 'param2', 'param3'
                 )
         )
 );

 function view($param1, $param2, $param3) { ... }

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Route question

2010-08-31 Thread cricket
2010/8/30 Harald Martin Bråttbåkk wynksaiddest...@googlemail.com:
 Hello,

 i simply want to change the default routing pattern http://
 example.com/controller/action/param1/param2/param3 into http://
 example.com/param1/controller/action/param2/param3. Is there a simple
 way to do this?

I'm not sure about doing it with generic controller and action. Also,
the regular expressions necessary will depend on what the params are
expected to be. For example, if you wanted URLs like so:

http://www.whatever.com/en/catalogs/some_string123/456

Router::connect(
'/:param1/catalogs/:param2/:param3',
array(
'controller' = 'catalogs',
'action' = 'view'
),
array(
'param1' = '[a-z]{2}',
'param2' = '[_a-z0-9]+',
'param3' = '[0-9]+'
'pass' = array(
'param1', 'param2', 'param3'
)
)
);

function view($param1, $param2, $param3) { ... }

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Route question

2010-08-30 Thread Harald Martin Bråttbåkk
Hello,

i simply want to change the default routing pattern http://
example.com/controller/action/param1/param2/param3 into http://
example.com/param1/controller/action/param2/param3. Is there a simple
way to do this?

Regards

Harald

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Route question

2010-08-16 Thread Dr. Loboto
?php echo $this-Html-link(__('View', true), array('controller' =
'galleries' , 'action' = 'view', 'gal_slug' = $gallery['Gallery']
['slug'])); ?

On Aug 16, 8:02 am, Dave Maharaj m...@davemaharaj.com wrote:
 I have my gallery controller and each gallery has a slug so the url looks
 like gallery/fishing (if manually typed in)

 Routed like - Router::connect('/gallery/:gal_slug',array('controller' =
 'galleries' , 'action' = 'view'), array( 'gal_slug' =
 '[-_A-Za-z0-9]+','pass' = array('gal_slug' ) ) );

 Then in my gallery index.ctp I have ?php echo $this-Html-link(__('View',
 true), array('controller' = 'galleries' , 'action' = 'view',
 $gallery['Gallery']['slug'])); ? but the url when hover/clicked over the
 link shows view -  gallery/view/fishing.

 How can I get it so it removes the view from the url?

 Thanks

 Dave

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


RE: Route question

2010-08-16 Thread Dave Maharaj
Thanks guys.

Dave

-Original Message-
From: Dr. Loboto [mailto:drlob...@gmail.com] 
Sent: August-16-10 4:10 AM
To: CakePHP
Subject: Re: Route question

?php echo $this-Html-link(__('View', true), array('controller' =
'galleries' , 'action' = 'view', 'gal_slug' = $gallery['Gallery']
['slug'])); ?

On Aug 16, 8:02 am, Dave Maharaj m...@davemaharaj.com wrote:
 I have my gallery controller and each gallery has a slug so the url looks
 like gallery/fishing (if manually typed in)

 Routed like - Router::connect('/gallery/:gal_slug',array('controller' =
 'galleries' , 'action' = 'view'), array( 'gal_slug' =
 '[-_A-Za-z0-9]+','pass' = array('gal_slug' ) ) );

 Then in my gallery index.ctp I have ?php echo
$this-Html-link(__('View',
 true), array('controller' = 'galleries' , 'action' = 'view',
 $gallery['Gallery']['slug'])); ? but the url when hover/clicked over the
 link shows view -  gallery/view/fishing.

 How can I get it so it removes the view from the url?

 Thanks

 Dave

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Route question

2010-08-15 Thread Dave Maharaj
I have my gallery controller and each gallery has a slug so the url looks
like gallery/fishing (if manually typed in)

Routed like - Router::connect('/gallery/:gal_slug',array('controller' =
'galleries' , 'action' = 'view'), array( 'gal_slug' =
'[-_A-Za-z0-9]+','pass' = array('gal_slug' ) ) );

 

Then in my gallery index.ctp I have ?php echo $this-Html-link(__('View',
true), array('controller' = 'galleries' , 'action' = 'view',
$gallery['Gallery']['slug'])); ? but the url when hover/clicked over the
link shows view -  gallery/view/fishing.

 

How can I get it so it removes the view from the url? 

 

Thanks

 

Dave

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Route question

2010-08-15 Thread mark_story
The problem is that in your link you don't use the 'gal_slug' key for
the array.  So the router doesn't understand that you mean it to be a
gal_slug route.  The pass key in the options, isn't bidirectional
unfortunately.

-Mark

On Aug 15, 9:02 pm, Dave Maharaj m...@davemaharaj.com wrote:
 I have my gallery controller and each gallery has a slug so the url looks
 like gallery/fishing (if manually typed in)

 Routed like - Router::connect('/gallery/:gal_slug',array('controller' =
 'galleries' , 'action' = 'view'), array( 'gal_slug' =
 '[-_A-Za-z0-9]+','pass' = array('gal_slug' ) ) );

 Then in my gallery index.ctp I have ?php echo $this-Html-link(__('View',
 true), array('controller' = 'galleries' , 'action' = 'view',
 $gallery['Gallery']['slug'])); ? but the url when hover/clicked over the
 link shows view -  gallery/view/fishing.

 How can I get it so it removes the view from the url?

 Thanks

 Dave

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Custom route question

2008-06-26 Thread theChrisWalker

This might be beside the point, and I can't think of a way to do it as
you've described without hard coding, but (and it's a big but),

why do you have hardcoded controllers for each game/team or game/
match? and given that you do why not hard code the route?

It would seem more logical (altough there's probably a good reason you
haven't mentioned) to have separate teams controller and matches
controller, and pass it the game as a param.
Then you could route:

Router::connect('/:game/teams', array('controller'='teams',
'action'='index'),array('game'='[a-z]+'));
Router::connect('/:game/matches', array('controller'='matches',
'action'='index'),array('game'='[a-z]+'));

and your controller could do something like

function index(){
  switch($this-params['game']){
case ping :
  // do ping thing
  break;
case catan:
  // do catan thing
  break;
...
default:
  // no match to game
  $this-redirect($somewhere);
  }
}

On Jun 25, 2:54 pm, benjam [EMAIL PROTECTED] wrote:
 I have a question about a custom route and was wondering if it's
 possible, and if it is, how?

 I have some controllers for a game match site named the following:
 foos_teams
 foos_matches
 chess_matches
 ping_teams
 ping_matches
 catan_matches

 and I would like to be able to access them by going to the following
 (respectively):
 /foos/teams
 /foos/matches
 /chess/matches
 /ping/teams
 /ping/matches
 /catan/matches

 How might I do this?  And I don't want to hard code each of them, I
 could, but I'd like to know if there is a better way that will work
 for new games and pages as soon as they are added without any further
 route building.

 Thanks, I know it's a tricky one.  My not even be possible, but any
 help you could give me is appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Custom route question

2008-06-25 Thread benjam

I have a question about a custom route and was wondering if it's
possible, and if it is, how?

I have some controllers for a game match site named the following:
foos_teams
foos_matches
chess_matches
ping_teams
ping_matches
catan_matches

and I would like to be able to access them by going to the following
(respectively):
/foos/teams
/foos/matches
/chess/matches
/ping/teams
/ping/matches
/catan/matches


How might I do this?  And I don't want to hard code each of them, I
could, but I'd like to know if there is a better way that will work
for new games and pages as soon as they are added without any further
route building.

Thanks, I know it's a tricky one.  My not even be possible, but any
help you could give me is appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Route question

2008-01-31 Thread Feris Thia

Hi,

Is the third parameter in to setup route in routes.php become useless
in CakePHP 1.2 ?

I try to use another ctp file (instead of action method related
template) with this syntax :

=
Router::connect('/', array('controller' = 'users', 'action' =
'index', 'index3'));
=

But it did not try to use index3.ctp and istead cake issue an error :

=
Missing view

You are seeing this error because the view for
UsersController::index(), could not be found.
=

Regards,

Feris

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Route question

2008-01-31 Thread Ron Chaplin
The third parameter is what should be passed to the controller=action.

You might simply try Router::connect('/', array('controller' = 'users',
'action' ='index'));

Also be sure that the view index.thtml (1.2 -- index.ctp) is created
in /app/views/users/

On Thu, 2008-01-31 at 21:54 +0700, Feris Thia wrote:

 Hi,
 
 Is the third parameter in to setup route in routes.php become useless
 in CakePHP 1.2 ?
 
 I try to use another ctp file (instead of action method related
 template) with this syntax :
 
 =
 Router::connect('/', array('controller' = 'users', 'action' =
 'index', 'index3'));
 =
 
 But it did not try to use index3.ctp and istead cake issue an error :
 
 =
 Missing view
 
 You are seeing this error because the view for
 UsersController::index(), could not be found.
 =
 
 Regards,
 
 Feris
 
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Route question

2008-01-31 Thread Feris Thia

Hi Ron,

Yes... the view is already created. I try to experiment with the third
parameter. So I've got wrong concept about it, thought it was the
template to be used by the controller.

Thanks !

Feris

On 1/31/08, Ron Chaplin [EMAIL PROTECTED] wrote:

  The third parameter is what should be passed to the controller=action.

  You might simply try Router::connect('/', array('controller' = 'users',
 'action' ='index'));

  Also be sure that the view index.thtml (1.2 -- index.ctp) is created in
 /app/views/users/


  On Thu, 2008-01-31 at 21:54 +0700, Feris Thia wrote:
  Hi,

 Is the third parameter in to setup route in routes.php become useless
 in CakePHP 1.2 ?

 I try to use another ctp file (instead of action method related
 template) with this syntax :

 =
 Router::connect('/', array('controller' = 'users', 'action' =
 'index', 'index3'));
 =

 But it did not try to use index3.ctp and istead cake issue an error :

 =
 Missing view

 You are seeing this error because the view for
 UsersController::index(), could not be found.
 =

 Regards,

 Feris




  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---