Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.4k views
in Plugins by
Is there any plugin that can make a short preview of the question's description on the front page like this theme do?

http://demo.qa-themes.com/ideabox/
Q2A version: 1.6.3

2 Answers

+4 votes
by
selected by
 
Best answer
How is the hack below?
 
1) qa-plugin/mouseover-layer/qa-mouseover-layer.php (arround line 60))
//$q_list['qs'][$index]['title']='<span title="'.qa_html($text).'">'.@$question['title'].'</span>';
$q_list['qs'][$index]['short_content']=qa_html($text);
Admin > Plugins > Mouseover layer > Check (Enable plugin) "Show content preview on mouseover in question lists"
 
2) qa-theme/Your-theme-folder/qa-theme.php
function q_item_title($q_item) {
  qa_html_theme_base::q_item_title($q_item);
  $short_content = @$q_item['short_content'];
  if(isset($short_content) && strlen($short_content))
    $this->output('<p class="qa-q-item-short-content">'.$short_content.'</p>');
}

3) qa-theme/Your-theme-folder/qa-style.css

.qa-q-item-short-content {
  /* Your favorite style */
}
by
AWESOME! It did the work! Thank you sooo much man, your're the man!
by
Just one more question... How do I go from this:
"This is some random rescription...this is the end text of description."
to this:
"This is some random rescription..."
by
Override with plugin OR hack qa-include/qa-util-string.php::qa_shorten_string_line()

Override example:
http://www.question2answer.org/plugins.php
http://www.question2answer.org/plugins-tutorial.php
http://www.question2answer.org/overrides.php

function qa_shorten_string_line($string, $length, $suffix=true) {
  $string = qa_shorten_string_line_base($string, $length);
  if (!$suffix) {
    $delimiter = ' ... ';
    $pos = strpos($string, $delimiter);
    if ($pos !== false)
      $string = substr($string, 0, $pos+strlen($delimiter));
  }
  return $string;
}

Hack example: (around line 530)

//$string=$prefix.' ... '.$suffix;
$string=$prefix.' ... ';

Restriction:
Because I do not test this code, it may need correction. And, as for the simple change mentioned above, length option of "Mouseover layer" plugin may not be handled definitely.
by
Hi  sama55,

I want to show an image of question to Short Preview. How can I do it ?

Thank sama55.
+1 vote
by
That theme is free to download. You only have to pay if you want access to their support. Your best bet is to download that theme and find the associated code in the theme files. It's not a plugin, but a theme customization which you could apply to whichever theme you already use.
by
Oh yeah, didn't see that. Although I've downloaded the theme and looked into the qa-theme.php file, but I don't see any relevant code that could be related with this... :\
...