I am using following query "/search/queryText=at%26t/results" to redirect to a page.
The location url auto decodes it to "/search/queryText=at&t/results". I need the value to be pristine, so that I can make use of $location.search to create an object of parameters.
The $location.search treats & as delimiter and creates two parameters (queryText=at and t=true)rather than one for the above example. Is there a way to handle this?
Related
I have an URI as a string which I get out of a Json in my Logic App.
How can I access any of the query items of the uri?
Inside the For Each which loops through the uri string list, i tried the following expression to get the query parameter filename, but it did not work:
items('For_each_2')['queries']['filename']
This returns 'The template language expression 'items('For_each_2')['queries']['filename']' cannot be evaluated because property 'queries' cannot be selected'.
There is a URI parsing functions in logic app to query property from URI, suppose you want is uriQuery, however it returns the whole after ?. It will be like below.
And if you want to query a specific property, you should pass them with the logic app trigger URL. It provides triggerOutputs()['queries'] property to get the queries, and this will return a json object, it will allow you to query specific parameter.
This is a sample:
https://xyz.logic.azure.com:443/workflows/id/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=code&test=123&test2=345
Then should be able to use triggerOutputs()['queries']['test'] to query.
Very new to coldfusion. So I have a a form outputs values from DB into checkboxes.
<cfoutput query="Offices">
<label><input type="checkbox" value="#offices#" name="Offices">#offices#</label>
</cfoutput>
and when a user selects more than one checkbox it passes multiple parameters into URL which looks like this:
offices.cfm?Offices=A&Offices=B&Offices=C
I am trying to prevent multiple of the same parameters being passed so I want it to return like:
offices.cfm?Offices=A,B,C&...
I am really struggling to figure this out. Help is appreciated.
(Summary from comments, just to close out this thread ...)
True, but that is just how the parameters are transmitted in the url. Per the html specs, when using method GET, the browser builds a builds a big string of name/value pairs for all (successful) form fields. Then appends them to the url as the query string:
Submit the encoded form data set
If the method is "get" and the action is an HTTP URI, the user agent takes the value of action, appends a ? to it,
then appends the form data set, encoded using the "application/x-www-form-urlencoded" content type.
form data set
A form data set is a sequence of control-name/current-value pairs constructed from successful controls
However, it does not matter that the field name appears multiple times in the URL. If you dump the #URL# scope, you will see that CF has already parsed those values into a single CSV list for you. That list can be accessed using the variable name URL.Offices.
I have a problem when reading an associative array that's inside a cookie.
)
When I set it like this in the controller:
$this->set('info', $this->Cookie->read('info'));
I can read data this way in the view:
$info[0]['records'];
[ 'person_id' => 2, ...]
)
When I do this (because I read the cookie from a view cell):
$this->set('info', $this->request->cookie('info'));
I get the associative array as an string. (?) The whole array is an string:
'.''[{"person_id":2, ... "}]''.'
So, how can I 'avoid' this? Why does it become, via 'request', a String?
Edit:
In CakePHP, when you try to retrieve a cookie via 'request' (2.), you will normally get the hashed value of the cookie. When creating the cookie, I disabled the hashing. Maybe I didn't do that correctly.
Is it also possible to unhash it in a view cell?
What you have there is a JSON string.
The Cookie component by default stores all data JSON encoded, and also encrypted (AES by default). Consequently it also decrypts and decodes the data when reading cookies.
When the cookie isn't encrypted, you could easily JSON decode it.
$decoded = json_decode($encoded, true);
If you were using encryption too, and/or you were unsure whether the value is JSON encoded or not, you could either use the Cookie component to decrypt/decode the cookies at controller level, like
$this->request->coookies['info'] = $this->Cookie->read('info');
or set it as a view variable that you can pass to your cell as an argument.
See also Cookbook > Views > View Cells > Passing Arguments to a Cell
As of CakePHP 3.1.7 you can also use the \Cake\Utility\CookieCryptTrait trait, which is used by the cookie component too. Just add it to your class, implement the CookieCryptTrait::_getCookieEncryptionKey() method to return the proper encryption key (by default the security salt), and use CookieCryptTrait::_decrypt() to unscramble the cookie data.
See also API > \Cake\Utility\CookieCryptTrait
While this would work in a cell, the "problem" is that that the cell needs to know stuff from the outside world in order for this to work, it needs to know about the encryption key, and the encryption mode. Personally I'd probably use the former method, and if it would need to be the latter, pass the key and the mode to the cell as arguments.
I have a table view with a form above it for doing advanced search (text fields, date ranges, drop down lists etc.)
I am trying to store this state in the URL using `$location.search('filters', angular.toJson($scope.filters)); but was wondering if there is a better way.
The reason I want to make use of the URL is so people can share links to filtered data.
This is a perfectly valid use case for $location.search, but you don't need to do an angular.toJson. $location.search accepts an object as its parameter and will automatically convert it into an encoded query string before applying it to the URL.
I'm trying to build a sort of Wordpress-esque CMS system to a project I'm building. I want the user to be able to create pages on the fly, and for them to appear in certain areas of the website.
I have made something similar in Symfony2, where the controller grabs a specific variable from the URL (as definded in the route.yml file, usually $id etc) and I then use the variable in the controller to display whatever content it relates to in the database.
However, I'm not used to CakePHP 2.0, and struggling to find what I need. I know it's possible, but I don't know the best way to achieve it. Especially as CakePHP uses a different routes file than Symfony.
How would I grab a variable from the URL and pass it for use inside a controller?
By variable do you mean GET query string parameters, like in /foo?key=value? You can access them in the controller through the request object: $this->request->query['key'].
If you are looking for something more integrated you can use CakePHP's default routes or make your own.
The default routes work with URLs like /controller/action/param1/param2 and pass the parameters to the action by position. For instance /posts/view/521 maps to a call to view(521) in PostsController, and /posts/byMonth/2012/02 maps to a call to byMonth("2012","02").
You can also use named parameters and the URLs look like /controller/action/key1:value1/key2:value2. In controller actions you would read them with $this->params['named']['key1'].
With custom routes you can make your URLs anything you want. You're not forced to the /controller/action pattern; you can make /archives/2012-02 map to PostsController::byMonth(2012,2), or have /512-post-title map to PostsController::view(512).
Typically you would start out with the default routes and add custom routes when you decide you need them. You can read all about the default and custom routes in http://book.cakephp.org/2.0/en/development/routing.html
Short answer: it depends.
If you're looking to pass parameters to a function, you don't need to mess with routes at all; every non-named URL path segment is processed in order and handed to the action as method parameters (so /controller/action/1234 passes "1234" as the first parameter to the action method in the controller controller class).
Named parameters allow you to pass parameters anywhere in the URL string, and to make them optional. The form is just key:value and they're accessed via $this->params['named'] in the controller.
The last option is prefix routing. The best place to get to speed on that is naturally the CakePHP Cookbook, but the general gist is that in a route definition, you can name a path component in the URL by prefixing it with a colon, identically to how the default routes show :controller, :plugin and :action. You can define any name you like, even optionally applying regex pattern requirements and then access it through $this->params['variablename'] in the controller.