Hi all,
First off, i'm not a programmer and mayby the following thought process may be corrupted but I would like to share the following idea.
I have an opencart website running with custom code to provide extra information.
Following the opencart logic I have a controller and some public functions which I greatly use to seperate code and to be some of a safe guard with regards to what happens. When a function is executed and I need to return to the general view which is coded in the INDEX function, I would use the $this->redirect($this->url->link('controller/function') .
Works perfectly but what happens is that the server tells the client to do a new GET request. And I wondered why.
So what I did was remove the redirect and added $this->index(); which saves me a round trip and haf of the time for the page load. Because it's a GET request the URL will be the same and if you refresh (or an impatient user) the same actiion will be triggered. I do not have a solution for that yet, but am thinking of something of checking the referrer URl as first in the index function. For now I don't forsee large problems with that.
Any comments, tips or additions?
Best regards
You have two different processes. For $this->redirect() you're ending the current OpenCart instance and sending the user to the link. Since the link is another OpenCart page you're starting a brand new instance for that controller/page. With $this->index() you're staying in the same OpenCart instance and letting $this->index() decide the output.
The reason you have your $_GET values in $this->index() is because you never actually left. The reason you don't have $_GET values on $this->redirect() is because you didn't supply them. The easiest solution is to use the latter and let your regular controller logic do its business. So change:
to:
A good place to get examples of this is the different breadcrumbs.
The reason you have your $_GET values in $this->index() is because you never actually left. The reason you don't have $_GET values on $this->redirect() is because you didn't supply them. The easiest solution is to use the latter and let your regular controller logic do its business. So change:
Code: Select all
$this->redirect($this->url->link('controller/function'));
Code: Select all
$this->redirect($this->url->link('controller/function', '¶meter=value'));
-Ryan
Who is online
Users browsing this forum: No registered users and 1 guest