Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8527143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:28:22+00:00 2026-06-11T08:28:22+00:00

I have one route that looks like this: Router::connect(‘/Album/:slug/:id’,array(‘controller’ => ‘albums’, ‘action’ => ‘photo’),array(‘pass’

  • 0

I have one route that looks like this:

Router::connect('/Album/:slug/:id',array('controller' => 'albums', 'action' =>    'photo'),array('pass' => array('slug','id'),'id' => '[0-9]+'));

and another like this:

Router::connect('/Album/:slug/*',array('controller' => 'albums','action' => 'contents'),array('pass' => array('slug')));

for what doesn’t match the first. In the ‘contents’ action of the ‘albums’ controller, I take care of pagination myself – meaning I retrieve the named parameter ‘page’.
A URL for the second route would look like this:
http://somesite.com/Album/foo-bar/page:2

The Above URL indeed works, but when I try to use the HTML Helper (url,link) to output a url like this, it appends the controller and action to the beginning, like this:
http://somesite.com/albums/contents/Album/foo-bar/page:2

Which i don’t like.
The code that uses the HtmlHelper is as such:

$html->url(array('/Album/' . $album['Album']['slug'] . '/page:' . $next))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:28:24+00:00Added an answer on June 11, 2026 at 8:28 am

    See below url it is very help full to you

    http://book.cakephp.org/2.0/en/development/routing.html

    Or read it

    Passing parameters to action

    When connecting routes using Route elements you may want to have routed elements be passed arguments instead. By using the 3rd argument of Router::connect() you can define which route elements should also be made available as passed arguments:

    <?php
    // SomeController.php
    public function view($articleId = null, $slug = null) {
        // some code here...
    }
    
    // routes.php
    Router::connect(
        '/blog/:id-:slug', // E.g. /blog/3-CakePHP_Rocks
        array('controller' => 'blog', 'action' => 'view'),
        array(
            // order matters since this will simply map ":id" to $articleId in your action
            'pass' => array('id', 'slug'),
            'id' => '[0-9]+'
        )
    );
    

    And now, thanks to the reverse routing capabilities, you can pass in the url array like below and Cake will know how to form the URL as defined in the routes:

    // view.ctp
    // this will return a link to /blog/3-CakePHP_Rocks
    <?php
    echo $this->Html->link('CakePHP Rocks', array(
        'controller' => 'blog',
        'action' => 'view',
        'id' => 3,
        'slug' => 'CakePHP_Rocks'
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a route that looks like the following: map.newsletter '/newsletter', :controller => newsletter
I have a route that currently looks like this: map.resources :regions, :collection => {:select_for_payroll
have one time consuming step that flattens a bunch of files. basically i'd like
can I have a route like... routes.MapRoute( Boundaries-Show, Boundaries, new { controller = Boundaries,
Let's say I have a PHP Model-View-Controller framework that maps an address like http://example.com/admin/posts/edit/5
Would like to set up a backbone route that matches a url that looks
As the title says... I have a route (the first one listed) which looks
I have a query whose code looks like this: SELECT DocumentID, ComplexSubquery1 ... ComplexSubquery5
I have an intent filter that looks like so: <activity android:name=com.test.Call android:label=@string/makeCall > <intent-filter>
I have this route: {controller}/{id}/{action} Because I think it makes more sense from RESTful

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.