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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:07:26+00:00 2026-05-26T01:07:26+00:00

CakePHP URL query parameters are not done in a standard fashion e.g. the params

  • 0

CakePHP URL query parameters are not done in a standard fashion e.g. the params are /param1:value1/param2:value2 instead of ?param1=value1&param2=value2

This means that the javascript location.search does not return a value.

There is a getQueryParams JQuery plugin that does what I want using location.search

I have had to modify this to use

var pairs = location.pathname.split('/');

instead of

var pairs = location.search.substring(1).split('&');

However this now includes everything except the host in the variable pairs. So I have to check for a ‘:’ to see if it is a parameter.

This works – but is there a better (more Cake like) way of doing it? I don’t want to improve on the JQuery plugin (e.g. Regex), I want to find a better way to integrate the plugin with CakePHP.

Upddate: I’ve removed the rest of the JQuery code as I’m happy with the jquery code, my issue is with fitting it more with cake

Is there some ‘Cake like’ way of removing the path to your app, the model and the controller from location.pathname so that you end up what you would normally get from location.search?

  • 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-26T01:07:26+00:00Added an answer on May 26, 2026 at 1:07 am

    So it appears there isn’t a better way of doing it. Here is the javascript for reference:

    // jQuery getQueryParam Plugin 1.0.1 (20100429)
    // By John Terenzio | http://plugins.jquery.com/project/getqueryparam | MIT License
    // Modified by ICC to work with cakephp
    (function ($) {
        // jQuery method, this will work like PHP's $_GET[]
        $.getQueryParam = function (param) {
            // get the pairs of params fist
            // we can't use the javascript 'location.search' because the cakephp URL doesn't use standard URL params
            // e.g. the params are /param1:value1/param2:value2 instead of ?param1=value1&param2=value2
            var pairs = location.pathname.split('/');
            // now iterate each pair
            for (var i = 0; i < pairs.length; i++) {
                // cakephp query params all contain ':'
                if (pairs[i].indexOf(':') > 0) {
                    var params = pairs[i].split(':');
                    if (params[0] == param) {
                        // if the param doesn't have a value, like ?photos&videos, then return an empty srting
                        return params[1] || '';
                    }
                }
            }
            //otherwise return undefined to signify that the param does not exist
            return undefined;
        };
    })(jQuery);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using CakePHP 1.3 there are named parameters in the URL like .../name:value/... These are
i'm developing cakephp application. i need some specific characters in url, like & (ampersand),
I was explaining to our SEO specialist that cakephp url structure is domain/controller/view/params so
Is it possible in CakePHP to have URL aliases in routes.php? Or by what
I am using CakePHP 1.26 and CDN JQuery in this URL: http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js In a
Problem is about CakePhp. If I give permission to required directories CSS does not
I have created a temporary table using cakephp $this->Model->query() and inserted some records using
I want following type of URL using cakephp. http://localhost/project1/controller1/action1/[{user_id:1,udid:,msg:,nick_n:Danis,post_t:2011-10-21 12:15:00,source:A}]/50 where [{user_id:1,udid:,msg:,nick_n:Danis,post_t:2011-10-21 12:15:00,source:A}] and
What's the cleanest way to add a prefix to every URL in CakePHP, like
I'm using cakePHP 1.2, and wondering how I can handle a URL that dynamically

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.