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

How to add html or php content in index page using "qa-theme.php" i'm using                 function main() but i'm can display simple text

$this->page_title(@$this->content['title']);
                        $this->output('IN THIS AREA I WANT HTML CODE ,BUT I GET ERROR IF I DO SO');

by
What kind of html code do You want to use ?
Are You using an editor which allows to save the file as utf8 ?
Did You try to copy and paste the  $this->output(' .... function from the original file ?

Does this example work :
$this->output('<h2>');
echo "Test Test Test";
$this->output('</h2>', '');
by
It work but i'm trying to put question form (../ask) in index page.
by
I also am trying to do the same ............ functions are in qa-include/qa-page-ask.php ?????

if you have something let me know, we had to put that function or table
qa-form-tall-table


if you have something let me know!!
by
linux, the functions are in qa-theme-base.php

but You need at first to build an advanced theme please see here:

http://www.question2answer.org/advanced.php

CHAPTER:

Creating an advanced theme for Question2Answer

There You include all the functions from the base file or only the one You need here:

function main()
...
...
...

Then You can add the code as posted in the answer below.

2 Answers

+2 votes
by
 
Best answer

If You want a questionform like mine on http://www.questions.com.mx You can use this code:

You just have to change the classes as You like. Question Box will appear on homepage only. Was build thanks to gidgreen and R .

 

Code goes after :

 

function main()
{
$content=$this->content;
 
$this->output('<DIV CLASS="qa-main'.(@$this->content['hidden'] ? ' qa-main-hidden' : '').'">');
 
HERE GOES THE CODE

 

// Questionbox on home START
 
 
if ($this->template=='') {                
 
$this->output('<DIV CLASS="qa-main-fragebox">');
$this->output(
 
'<FORM METHOD="POST" ACTION="/ask/">
<table class="qa-form-tall-table">
<tbody>
<tr><td class="qa-form-tall-label" colspan="2">Just ask - no need to register !</td>
</tr>
<tr>
<td class="qa-form-tall-data" colspan="2">
<textarea id="title" NAME="title" rows="3" cols="60" class="qa-form-tall-text" onfocus="this.value=\'\'; this.style.color=\'#000000\'; this.onfocus=null;" >Enter Your question here...</textarea>
</td>
</tr>
<tr>
<td>
<div class="qa-form-tall-note">Provide more detailed information on the next page.</div>
</td>
<td><INPUT NAME="doask1" title="" VALUE="ASK" onmouseout="this.className=\'qa-form-tall-button qa-form-tall-button-ask\';" onmouseover="this.className=\'qa-form-tall-hover qa-form-tall-hover-ask\';" class="qa-form-tall-button qa-form-tall-button-ask" TYPE="submit"></td>
</tr>
</tbody>
</table>
</FORM>'
);
$this->output('</DIV>');
}
 
else{
}       
 
// Question Box on home END
by
Is it my mistake or this code doesn't work in Q2A version 1.3.1 ?
by
Yeah, for some reason doesn;t work in 1.3.1 version ;/
by
$this->template=='' not working for home page with siteurl/qa/
where it is not showing anything but only root of qa/ so how to define main index page in template?
by
Found the solution
+1 vote
by

Do you get any PHP errors? It's possible you're putting apostrophes inside the string. This for example would not work:

$this->output('What's the matter?');

It should be:

$this->output('What\'s the matter?');

Note the backslash before the '

It would be useful to update your question with the exact code you are using.

by
I need to put "Your question in one sentence: ..." in index page and i'm trying to put "function question_main()" in "qa-theme.php" from "qa-theme-base.php" bellow "            $this->page_title(@$this->content['title']);" line, but it seems complicated...
...