I am trying to submit a form to Joomla. My action URL is
index.php?option=com_hello&controller=createTask
it works fine.
But when i use action=index.php and contorller and option are my POST variable then this statement
$viewName = $app->input->getWord('view', 'createTask');
outputs view='featured' though view is none of my POST variable.
Where is that view coming from?
Related
For example, when i'm fill the form that i want to submit, and then i want to go back to previous page. This is the code that i'm using to get previous page
$this->agent->referrer()
How exactly i get back to second page before since when i'm using the code above, i get back to the form that i have already submit.
I have tried another way like $_SERVER['HTTP_REFERER'] but i'm still get back to the form page.
Here is the code that I'm currently using :
$this->Model->updateDataProducts($id, $data);
$redirect = ($this->agent->referrer());
redirect($redirect);
Any solutions?
Set the redirection url in the controller :
In your redirect call, the second parameter is the "method" of redirection, so that's why your redirect is not working. what you want is something like this:
$this->Model->updateDataProducts($id, $data);
redirect('search/my+search+term'); // if you need redirect any methods
That's why we do the string concatenation, instead of passing the search term to the second parameter
I have a view mypage.blade.php and a route.
The url is like : https://example.com/mypage/param1/param2. The route use param1 and param2 and generate the page.
Question 1
In that page, I try to get its HTML code. Is there a way to do it?. I tried render() but I don't get what I want.
Question 2
In the view, can I get the HTML code of an other view by specifying a path ?
You had the right idea. Not sure why it wouldn't work for you.
In the controller, set the view into a variable:
$view = view('myBaseView', compact('people', 'places', 'things'));
Now, if you dump the rendered view variable, you have the page's HTML:
dd($view->render());
To get the html of another view by specifying the path and using the internal controller, you would need to set up some kind of a wrapper or catch so that the view variable is not returned as a view, but rendered out to html as above. Your method would need to trap whatever the original controller was sending before it pushed out the view.
Of course, old school php can get the other page's rendered html too possibly if your server is set to allow this:
$html = file_get_contents('http://mypage.com/');
Something else you might find handy is the Laravel sections method. If you just want to render part of the page you can do so by calling whatever section you want from a partial view:
$sections = $view->renderSections(); // returns an associative array of 'content', 'pageHeading' etc
dd($sections['modalContent']); // this will only dump whats in the content section
I don't know what you want to do with this html, but if you wish to display it on a page, once you send it (you'd possibly want to return the view along with a compact of the variable $view... as a normal variable if so), remember to use this format:
{!! $view !!}
HTH
Currently my users must get the visit form given by Route::get then fill it in to get back a result view given by Route::post. I need to create a shareable link such as /account/search/vrm/{vrm} where {vrm} is the VRM that is usually filled in on the form page. This VRM then needs to redirected to Route::post as post data. This needs to be done by my controller. How can I do this in my controller?
Routes:
// Shows form view
Route::get('/account/search', 'User\AccountController#getSearch')->name('account.search');
// Shows result view
Route::post('/account/search', 'User\AccountController#runSearch');
// Redirect to /account/search as POST
Route::get('/account/search/vrm/{vrm}', function($vrm) { ???????? });
POSTs cannot be redirected.
Your best bet is to have them land on a page that contains a form with <input type="hidden"> fields and some JavaScript that immediately re-submits it to the desired destination.
You can redirect to a controller action or call the controller directly, see the answer here:
In summary, setting the request method in the controller, or calling a controller's action.
Ps: I don't want to repeat the same thing.
For those who comes later:
If you are using blade templating engine for the views, you can add '#csrf' blade directive after the form starting tag to prevent this. This is done by laravel to prevent cross site reference attacks. By adding this directive, you can get around this.
return redirect()->route('YOUR_ROUTE',['PARAM'=>'VARIABLE'])
I have the following problems.
I am using the following template for my application:
<?php $this->load->view('backOffice/bo_header_in');?>
<?php $this->load->view($bo_main_content);?>
<?php $this->load->view('backOffice/bo_footer_in');?>
When I send data from the controller, to edit a record, I have the following code:
$data['userid'] = $this->back_office_users->getOneUser($userid);
$data['bo_main_content'] = "backOffice/edituser_view";
$this->load->view('backOffice/bo_template_in', $data);
Now, in my view, where I want to edit the record, I am getting it all right, my form is filled with the user name and password but.... on the top of the page, I get displayed the userid, username, userpassword, which is not what I want. Can anyone help me how can I send the data from my controller to my view, so I can have only my form filled, and not have the userid,username and password diplayed on the top of the page?
What you have shown looks ok. Search your models/controllers for a var_dump and re-look at the code in your view for a print_r. I typically do this during development to see the variable contents.
HI I have a codeigniter controller called CIcontroller and I have a method say redirectmethod
in the redirectmethod i have some code and then i do this
$data['redirect_page'] = 'page_name';
$this->load->view('template_view',$data);
the template view basically loads header footer and the corresponding view as specified by the data parameter
Now everything works fine but my url has value http:\\blabla\CIcontroller\redirectmethod instead of http:\\blabla\page_name
could anyone help me fix this thing
You need to emit a Location header to tell the browser to load a different page. See redirect in the url helper.