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 8824901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:44:49+00:00 2026-06-14T06:44:49+00:00

i have a router test/view and i would like to pass some params like

  • 0

i have a router test/view and i would like to pass some params like test/view/id/123.

Im not sure how to add those params in the zf2 router.

'router' => array(
        'routes' => array(
            'test' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'    => '/test',
                    'defaults' => array(
                        '__NAMESPACE__' => 'test\Controller',
                        'controller'    => 'Index',
                        'action'        => 'index',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'view' => array(
                        'type' => 'Literal',
                        'options' => array(
                            'route' => '/view',
                            'defaults' => array(
                                'controller' => 'Index',
                                'action'     => 'view',
                            ),
                        ),
                    ),
                ),
            ),
        ),
),

i setup view as a child route but not sure where to add those params.

i’ve tried 'route' => '/view/:id/:value' and

'defaults' => array(
    'controller' => 'Index',
    'action'     => 'view',
    'id'         => 'value',
)

but they don’t seem to work

i am trying to understand how all this works.

any ideas? thanks

  • 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-14T06:44:50+00:00Added an answer on June 14, 2026 at 6:44 am
    'router' => array(
        'routes' => array(
            'test-view' => array(
                'type'    => 'segment',
                'options' => array(
                    'route'    => '/test/view/:testId[/]',
                    'constraints' => array(
                        'testId'     => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'Test\Controller\Index',
                        'action' => 'view'
                    ),
                ),
            ),
    

    In your ControllerAction you can then get the parameter “testId” by using:

    $this->params('testId');
    

    Btw: The above route gives you an url like this: /test/view/123 – I thought you may get rid of the “id” param.

    If you want to create a link to one kind of this pages, you can use $this->url('test-view', array('testId' => 123)) in one of your views.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a router like this, as main entry point: window.AppRouter = Backbone.Router.extend({ routes:
I have a Base Router where i define some functions that need to be
I have defined: a view at views/pages/about.html.rb , a test in spec/controllers/pages_controller_spec.rb : describe
Say my view pages have route helpers like: root_url user_edit_path Now if I change
I have the following routes object : routes: { *defaults: home, '#test': 'test' }
Is it possible to have the router return an error code (or an entire
I have a Backbone Router: class X.Routers.Main extends Backbone.Router routes: '/': 'home' 'pageb': 'actionb'
Using Restlet I have created a router for my Java application. From using curl,
I have a Thomson ST585V6 router and 2 TRENDnet TEW-636APB Wireless Access Points. And
I have a custom MVC PHP framework that has a router class, which calls

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.