pogidude Posted July 29, 2013 Posted July 29, 2013 In ProcessPageEdit::init() method, there is this line of code at the bottom which loads JqueryWireTabs module: if(!$this->isPost) $this->modules->get('JqueryWireTabs'); my question is, what does $this->isPost mean? when is this value true? or false?
Wanze Posted July 29, 2013 Posted July 29, 2013 // determine if we're going to be dealing with a save/post request $this->isPost = ($this->input->post->id > 0 && (((int) $this->input->post->id) === $this->page->id)) || $this->config->ajax && (count($_POST) || isset($_SERVER['HTTP_X_FIELDNAME'])); True when there's a request to save the page.
pogidude Posted July 29, 2013 Author Posted July 29, 2013 thanks for the answer wanze. though I still don't get why you need this check in ProcessPageEdit::init(). I mean, what if you're just loading a page for editing? you know, not yet clicked on the "save" buttons.
Wanze Posted July 29, 2013 Posted July 29, 2013 thanks for the answer wanze. though I still don't get why you need this check in ProcessPageEdit::init(). I mean, what if you're just loading a page for editing? you know, not yet clicked on the "save" buttons. You're welcome! If you just load the page for editing, then isPost is false. This means that the JqueryWireTabs get loaded. I belive the reason behind the check is that if we're dealing with a save-request, there's no need to load UI stuff like JquerWireTabs, because Pw does a redirect after the save. $this->isPost is used multiple times in the module, so it makes sense to save this long boolean expression in a variable which is easier to read. 2
pogidude Posted July 29, 2013 Author Posted July 29, 2013 (slap head) I totally forgot it was a NOT (!) conditional.. now I get it.. thanks!
ryan Posted July 30, 2013 Posted July 30, 2013 I belive the reason behind the check is that if we're dealing with a save-request, there's no need to load UI stuff like JquerWireTabs, because Pw does a redirect after the save. That's correct, it's just an optimization to prevent loading resources that won't be applicable for the request. When ProcessPageEdit performs a save, it doesn't generate any output–it finishes by redirecting back to itself, so there's no need to load things like tabs.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now