To theme quiz take page, I create page--node--take.tpl.php
Question body, I get from
$question_node = node_load($question_nid);
$question_node->body[und][0][value];
Alternative choice, I get from
$formmultichoice_elements = drupal_get_form("quiz_question_answering_form", $question_node, $_SESSION['quiz'][$node_quiz->nid]['result_id']);
foreach ($formmultichoice_elements[question][$question_nid][question][body]['#object']->alternatives as $choice):
endforeach
This is working for the one page per one question.
But when I try on QUIZ page (which contain multiple questions in one page), it show error
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7930
Could you please advise how to solve this?
Are there any better way to theme Quiz take page?
Thank you
Comments
Comment #2
Supakorn commentedComment #3
djdevinYou'll have to paste your whole code to get help.
Remember that Quiz pages contain an array of questions so you'll have to handle that otherwise you will likely get errors.
Comment #4
Supakorn commentedHello djdevin,
This is my code.
I have updated my code which (I think) it is more properly.
Now, the error message has changed to below.... ( but single question quiz page still works)
Fatal error: Call to a member function getLayout() on boolean in ......\sites\all\modules\quiz\question_types\quiz_question\quiz_question.module on line 150
Comment #5
Supakorn commentedHi djdevin,
I have solved it. But I am not sure this is the best solution or not??
this is my whole code.
Comment #6
djdevinI'm not a themer but that is likely the wrong approach.
You are overriding the entire form which means it likely won't survive updates to the module, and might be insecure as you're also overriding all the input HTML that Drupal generates. That might break a lot of Form API stuff to.
Comment #7
Supakorn commentedSo, what is the best way to theme page node take. Or which function should be use in the page?
could you please advise.
Comment #8
steinmb commentedI see nothing in there that is specific to this module. In general the tpl. files should not contain logic and large chunk of PHP -code.
https://www.drupal.org/docs/7/theming as a starting point or any drupal front en book. Use template_preprocess or a hook alter that allow you to only change the bits you need.