Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
931 views
in Q2A Core by
At SE questions can be closed with a [closed] prefix that not only is visually helpful but help new members get familiar with them. How can it be highlighted in q2a?

1 Answer

+5 votes
by
selected by
 
Best answer

I have done this myself. In an advanced theme, try these two functions:

 

function page_title_error()
{
  if ( isset($this->content['q_view']['url']) )
  {
    $this->content['title'] = '<a href="' . $this->content['q_view']['url'] . '">' . @$this->content['title'] . '</a>';
    if ( @$this->content['q_view']['raw']['closedbyid'] !== null )
      $this->content['title'] .= ' [closed]';
  }
 
  parent::page_title_error();
}
 
function q_item_title($q_item)
{
  // display "closed" message in question list
  $closed = @$q_item['raw']['closedbyid'] !== null;
 
  $this->output(
    '<DIV CLASS="qa-q-item-title">',
    '<A HREF="'.$q_item['url'].'">'.$q_item['title'].'</A>',
    ($closed ? ' [closed] ' : ''),
    '</DIV>'
  );
}
 
by
It worked like a charm. Thank you!
by
How can I have this affect the title on the question's page itself? For example, if this question was closed, I'd like the title at the top of the screen here (in <h1>) to read "How can closed questions be highlighted? [CLOSED]" I've used your code above to adjust the question's title in the question list, but it doesn't affect the page title. I'm new to php, so I'm not sure how to set this up correctly, but I believe it needs to be under function title() in my advanced theme.
by
why it doesn't work for me? My theme is snow. I should create an advanced theme?
...