Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
447 views
in Q2A Core by
edited by

I have some special instructions that I display when the user is asking a question. This is simple, just using the `$this->template` variable. But when a user edits the question, `$this->template` is 'question' instead of 'ask'.

Is there another way to detect if the user is on the edit form?

UPDATE: see my answer. Is there a better way in v1.4??  qa_get('state') and $_GET['state'] are both blank.

3 Answers

+1 vote
by
Yes, you can check as follows:

if (isset($this->$content['q_edit_form'])) {
 ...
}
by
What was your decision to take away the 'state' get (see my comment at Scott's answer). Thanks for letting us know.
0 votes
by

Just to update, this now appears to be 'form_q_edit' and not 'q_edit_form'.

Although I wonder if there is a better way to detect this in v1.4 since we request ?state=edit-1234. I've tried qa_get('state') function and $_GET['state'] but both come back blank.

by
moved by

Is there a better way now? The form_q_edit check feels really not-future proof...

by
@Scott "I've tried qa_get('state') function and $_GET['state'] but both come back blank."

This is probably due to qa-page.php, function qa_load_state() which unsets the get(state) like that:

        global $qa_state;
        $qa_state=qa_get('state');
        unset($_GET['state']); // to prevent being passed through on forms
+1 vote
by
From v1.7 and up:

$editmode = isset($content['form_q_edit']);

Still hope we get the 'state' back...

@Scott "I've tried qa_get('state') function and $_GET['state'] but both come back blank."

This is probably due to qa-page.php, function qa_load_state() which unsets the get(state) like that:

        global $qa_state;
        $qa_state=qa_get('state');
        unset($_GET['state']); // to prevent being passed through on forms
...