Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

content of the question on the main page

+3 votes
asked Aug 15, 2016 in Q2A Core by emax9393

I read this topic : http://www.question2answer.org/qa/50582/show-question-content-on-the-main-page but I can not figure out what I need to insert into the qa-theme.php file

Q2A version: 1.7.4

3 Answers

+1 vote
answered Aug 15, 2016 by arjunsuresh

If you want to populate the question lists with question content (in addition to question title) you can use this plugin.


commented Aug 25, 2017 by esqeudero
the plugin needs some modifications. First, DESC appear in the same class (<div class="qa-q-item-title">). The content should be shown in its own class (<div class="q-content">)
+2 votes
answered Aug 25, 2017 by eserc

to separate TITLE and CONTENT div classes. Replace entire foreach code with below modified one in @arjunsuresh's plugin layer.php.

foreach ($q_list['qs'] as $index => $question) {

if (isset($postinfo[$question['raw']['postid']])) {

$thispost = $postinfo[$question['raw']['postid']];

$text = qa_viewer_text($thispost['content'], $thispost['format']);

$text = htmlspecialchars(preg_replace('/\s+/', ' ', $text));  // Remove duplicated blanks, new line characters, tabs, etc

//$text = qa_shorten_string_line($text, $maxlength);

if($this->template =='blogs')

$title =  $thispost['title'];

else $title = isset($question['title']) ? $question['title'] : '';

if(strlen($title) < $minlength){

$text = '<div class="q-content">'. qa_substr($text,0,$maxlength).'...</div>';

$q_list['qs'][$index]['title'] = $title;

$q_list['qs'][$index]['content'] = $text;





commented Mar 1 by Emre
Çok teşekkür ederim, çok işime yaradı :)
+1 vote
answered Jan 1 by Abhi Nahi
see my page http://sawalzawab.com/questions/math

changes require in qa-plugind/mouse-hover/qa-mouseover-layer.php

replace all code with this

    Question2Answer by Gideon Greenspan and contributors

    File: qa-plugin/mouseover-layer/qa-mouseover-layer.php
    Description: Theme layer class for mouseover layer plugin

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    More about this license: http://www.question2answer.org/license.php

class qa_html_theme_layer extends qa_html_theme_base
    public function q_list($q_list)
        if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on

            // Collect the question ids of all items in the question list (so we can do this in one DB query)

            $postids = array();
            foreach ($q_list['qs'] as $question) {
                if (isset($question['raw']['postid']))
                    $postids[] = $question['raw']['postid'];

            if (!empty($postids)) {

                // Retrieve the content for these questions from the database

                $maxlength = qa_opt('mouseover_content_max_len');
                $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
                $postinfo = qa_db_read_all_assoc($result, 'postid');

                // Get the regular expression fragment to use for blocked words and the maximum length of content to show

                $blockwordspreg = qa_get_block_words_preg();

                // Now add the popup to the title for each question

                foreach ($q_list['qs'] as $index => $question) {
                    if (isset($postinfo[$question['raw']['postid']])) {
                        $thispost = $postinfo[$question['raw']['postid']];
                        $text = $thispost['content'];//qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
                        //$text = preg_replace('/\s+/', ' ', $text);  // Remove duplicated blanks, new line characters, tabs, etc
                        //$text = qa_shorten_string_line($text, $maxlength);
                        $title = isset($question['title']) ? $question['title'] : '';
                        $q_preview = $text;//qa_html($text); // for full question content use: $thispost['content']
                        $q_list['qs'][$index]['content'] = $this->getHtmlTitle($q_preview, $title);

        parent::q_list($q_list); // call back through to the default function

     * Returns the needed HTML to display the tip. Depending on the theme in use, this might need to be
     * tuned in order for the tip to be displayed properly
     * @access private
     * @param string $mouseOverText Text of the tip
     * @param string $questionTitle Question title
     * @return string HTML needed to display the tip and the question title
    private function getHtmlTitle($mouseOverText, $questionTitle)
        return sprintf($mouseOverText);

Then in Embed plugin by NoahY add below function

function q_item_content($q_item)
            if (isset($q_item['content'])){
                $q_item['content'] = $this->embed_replace($q_item['content']);