I want to have a following condition in my view.ctp. I want to get the parameters like "/?parameters=name&data=1" from a url and have it in my view. I want to set a $_GET. Where can I set it? Controller,Element,lor View? I read multiple tutorials but I still dont get how the $_GET works in Cakephp2. It would be great if you can give me sample or hints for dummies like me.
if(!empty($_GET['parameter'])){
}
$_GET['parameter'] should be $_GET['parameters'] in your code. For your /?parameters=name&data=1
Related
Calling $_GET['ip'] worked up until a recent wordpress update and now it's broken.
I don't know how Wordpress expects me to get the variable but the code I've been messing with and put together doesn't seem to work at all.
I'm clearly doing something wrong but I can't seem to wrap my head around making this work.
The code I'm trying to work with is here: https://pastebin.com/4iipisjU
UPDATE: The code works, the WPSupercache configuration file for nginx is what seems to have broken it.
You should be able to use get_query_var
<?php
$value = get_query_var( "paramA", "default value" );
?>
Also, $_GET['ip'] will refer to the query parameter IP that was passed as part of the request.
Is this actually what you are looking for? Or are you trying to see the IP of the client making the request? If the latter, this is incorrect.
Try change $get_ip_addr to:
$get_ip_addr = get_query_var('ip', $_GET['ip']);
I got a form, that send post request and show paginated results. There are problems, when i want to see pages number 2 and more, because there sended get request and controller doesn't see form to create query. Anyone know how to solve this problem?
I'm using symfony(1.4) and I dont know if there's a big difference between 2.x
so let me discuss about it...
creating url's you should use
<?php url_for('page/view?num='.$page_num) ?>
something like that, then you can now use the request of your module
#app/{apps_name}/module/page/{actions.class.php} or {pageActions.class.php}
to your view method
public function executeView(sfWebRequest $request)
{
$page_num = $request->getParameter('num');
echo $page_num;
}
you should get what the page number now.
one more thing, this only works in $_GET requests.
You should know how to use Routing, to configure atleast 3 parameters. It will help you to use $_POST requests.
I think easiest way would be to make the search a get request so that is in the url. Then the paginated links will have the search value too.
I came from Codeigniter. In CI I had this:
$route['([a-z]+)tab'] = "$1/tab";
When I go to index.php/sometab/ I'll get some/tab/ action executed. But it doesn't redirect, instead I just tell CI that when I type this address I want to use another address instead, though there is no redirect.
Basically I want to achieve next goal: when I go to /someTab/ I want to execute some#tab action.
I only found Redirect::to_action in laravel, but I dont want the URL to be changed. I tried something like:
Route::any('([a-z]+)tab', function($controllerName) {
return Redirect::to_action("{$controllerName}/tab"); // here I want to tell to use $controllerName#tab action
});
How can I get this?
http://laravel.com/api/class-Laravel.Routing.Controller.html
There are some interesting methods here to. Route::cal, Route::forward, Route::execute...
I've got a URL parameter I need to get to pass to a PHP MySQL Variable.
Lets say for instance my URL is:
www.facebook.com/?ref=logo
Normally it'd $_GET to get the value of ref. How would I go about doing this in a CodeIgniter model? From what I understand, $_GET doesn't work with CI?
Its in the input class.
$ref = $this->input->get('ref');
Source : http://ellislab.com/codeigniter/user_guide/libraries/input.html
Get works just fine in CodeIgniter. You would access it in a similar way to POST values:
$ref = $this->input->get('ref', true);
I have a url like this
http://example.com/folder/component/mycom/?insid=7&test=685286640293e700bc9440cafb587290
I need to get value of test. When I echo $_GET['test'] it returns 685286640293e700bc9440cafb587290?url=component/mycom/ . It is happening for last variable of url.I dont know why is this so?
Thanks
Test isn't being sent in the $_GET that you displayed?
You have : insid=7 and token=685286640293e700bc9440cafb587290 with a malformed & between them that is the HTML code for & rather than the & itself.
Your URL at the moment is this:
http://example.com/folder/component/mycom/?insid=7&test=685286640293e700bc9440cafb587290
If you change it to
http://example.com/folder/component/mycom/?insid=7&test=685286640293e700bc9440cafb587290
I would be willing to bet you will get your code working :)