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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:59:54+00:00 2026-05-27T23:59:54+00:00

I’ve been tasked with rewriting an existing website with large pre-existing link catalog. For

  • 0

I’ve been tasked with rewriting an existing website with large pre-existing link catalog. For argument’s sake, let’s assume we can’t do anything that would change the link catalog. Here’s a few examples of the link structure we’re working with:

  1. An item page would be:

    www.domain.com/widgets/some-totally-awesome-large-purple-widget
    
  2. A category sub page page would be:

    www.domain.com/widgets/purple-widgets
    
  3. A category parent page page would be:

    www.domain.com/widgets/
    
  4. A custom page may be:

    www.domain.com/some-random-page
    

The various page types are too numerous to write individual Routers for.

Using Router::connect I can easily account for the first and second scenarios using something like:

Router::connect('/{:pageroot}/{:pagekey}', 'Pages::index');

In turn, the Pages::index method looks for entries in our database with the “key” of ‘/widgets/purple-widgets’.

However, the framework defaults to the ‘/{:controller}/{:action}/{:args}’ route for pages like the third and fourth. I know that this is the correct behavior for the framework. Also, best practice would state that I should write the site to match this behavior. But, that isn’t an option here.

What I need is a Router that would allow the third and fourth examples to function the same as the first. All examples should be sent to the Pages::index controller, which in turn queries a database using the URL path as a key.

  • 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-05-27T23:59:55+00:00Added an answer on May 27, 2026 at 11:59 pm

    If you don’t have any convention in the URL for what is what, between page, item and category. I’d go with a very generic router.

    Router::connect('/{:category}/{:page}/{:item}', 'Pages::any');
    Router::connect('/{:category}/{:page}', array('Pages::any', 'item' => null));
    Router::connect('/{:category}', array('Pages::any', 'page' => null, 'item' => null));
    

    And in Pages::any() to search for the correct stuff. Is that category a page after all (example 4)? Is that page an item (example 1)?

    or

    You store the URL somewhere (e.g. a mapping table in the database) and use the pattern version of a lithium Route.

    Router::connect(new Route(array(
        'pattern' => '@^/(?<path>.+)$@',
        'params' => array('controller' => 'pages', 'action' => 'any'),
        'keys' => array('path' => 'path'),
        // extra stuff, if the path is `tata`, it skips this route and uses
        // any of the following ones that matches.
        'handler' => function($request) {
            if ($request->params['path'] == 'tata') {
                return false;
            } else {
                return $request;
            }
        }
    )));
    

    From that point, you’ll get the full URL.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.