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

Can you provide a basic example of how to override standard Q2A forms in an advanced theme? Or is there a file to look at that explains this? Do you simply copy the $qa_content form array into qa-theme.php and modify it or do you need to use different variables?

In certain qa-page files the qa_content is created over several different functions. How does one "intercept" the particular part of the form or the specific form that needs to be modified, since presumably you cannot copy the function(s) from the qa-page file into qa-theme.php?

Here is an example, and I'm wondering why this doesn't work?

In my qa-theme.php I can access the following form array from the qa-user page:

$this->content['['form_profile']']['level']['type']

Why then can't I simply reset this array value of type by doing something like this:

$this->content['['form_profile']']['level']['type'] = 'blank'

When I try this I get an undefined error.

Thanks.

1 Answer

0 votes
by

There's a problem in your PHP code. It should be:

$this->content['form_profile']['level']['type']=...

by
edited by
Thank you for the comment. Yes, I have used print_r many times already and have seen all the different arrays that are being used to create the content. But there is seemingly no possible way to assign a new value to an existing array that is passed to qa-theme.php from any other template. In theory, just assigning the new value to the array with an = should work, for example, $this->content['form_profile']['level']['type'] = 'blank'; , but it doesn't.

I understand one needs to loop thru the array with foreach, but even looping doesn't work. Can you just provide a code example of how one could loop thru a sample array that is passed to qa-theme.php and how one resets the value of the particular array in the loop in qa-theme.php?

Apparently, there are certain variables that qa-theme.php is using that I can't find.
by
By the way my code is something like this:

$sample = $this->content['form_profile']['level']['type'];
foreach ($sample as $key=>$value) {
//do something to change value - nothing seems to work here though in qa-them.php
}
by
Again, this is an issue with your PHP code. $sample is a copy of the information you want to modify, so it won't affect the content of the theme itself. Also, it's not an array, you can't use it in a foreach. Finally, there's a ['fields'] index you need in there. So you want to make a direct assignment like:

$this->content['form_profile']['fields']['level']['type'] = 'blank';
... or ...
unset($this->content['form_profile']['fields']['level']['type']);
by
thanks. Got it now.

Welcome to the Q&A site for Question2Answer.

If you have a question about Q2A, please ask here, in English.

To report a bug, please create a new issue on Github or ask a question here with the bug tag.

If you just want to try Q2A, please use the demo site.

Categories

...