Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
4.3k views
in Q2A Core by
Q2A version: 1.6 beta

2 Answers

+4 votes
by
selected by
 
Best answer

By refering mouse hover plugin I have used the code directly into the theme.. :) just to make sure I have added in q_item_title($q_item) function.. However you can use this code in any function which gives you post id..

Code:

$pid = $q_item['raw']['postid']; //question id
 
$query = qa_db_query_sub("SELECT postid, content, format FROM ^posts WHERE postid = $pid");
$cont = qa_db_read_one_assoc($query);
 
$blockwordspreg = qa_get_block_words_preg();
 
$text=qa_viewer_text($cont['content'], $cont['format'], array('blockwordspreg' => $blockwordspreg));
$text=qa_shorten_string_line(qa_html($text), 200); //200 is the length
 
$this->output('<p class="your-class-for-text">',$text,'</p>'); //you can remove 'p' if you don't want
 
Or get code from here...

https://gist.github.com/q2amarket/5816586

 

by
how to show extra field on index page?
by
Hello,

in which file i can find the function q_item_title($q_item) ? I cant find the function to add the source.
Thanks
by
You can find this function in qa-theme-base.php but you have to override in your theme file or plugin.
by
edited by
Hello jatin.soni,

thank you for your fast reply. I found in qa-them-base.php the function
       
function q_item_title($q_item)
        {
            $this->output(
                '<div class="qa-q-item-title">',
                '<a href="'.$q_item['url'].'">'.$q_item['title'].'</a>',
                '</div>'
            );
        }

how i have to override now? Im not a programmer, would be happy if you coul show me how to override, i mean how must look the code above after overriding. Thank you a lot.
by
Yes. So select this code in qa-them-base.php:
function q_item_title($q_item)
        {
            $this->output(
                '<div class="qa-q-item-title">',
                '<a href="'.$q_item['url'].'">'.$q_item['title'].'</a>',
                '</div>'
            );
        }

replace to:

function q_item_title($q_item)
        {
         $pid = $q_item['raw']['postid']; //question id
 
$query = qa_db_query_sub("SELECT postid, content, format FROM ^posts WHERE postid = $pid");
$cont = qa_db_read_one_assoc($query);
 
$blockwordspreg = qa_get_block_words_preg();
 
$text=qa_viewer_text($cont['content'], $cont['format'], array('blockwordspreg' => $blockwordspreg));
$text=qa_shorten_string_line(qa_html($text), 200); //200 is the length
       
       
            $this->output(
                '<div class="qa-q-item-title">',
                '<a href="'.$q_item['url'].'">'.$q_item['title'].'</a>','<p class="your-class-for-text">',$text,'</p>',
                '</div>'
            );
        }

But this is not perfect, because there isn't wrap in text. Example this example
Aaaaa
bbbb
ccccc  ddd
will be this:
Aaaaa bbbb cccc ddd.
The webpage design is ok.
+1 vote
by
If you mean showing the main question text, there is a plugin included in Q2A (I think it's the mouseover-layer one) that shows the question text in a tooltip. You can modify that quite easily to put the text inline.
...