Skip to content

Instantly share code, notes, and snippets.

@pupi1985
Created October 12, 2014 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pupi1985/ebeb18fae2d8cc9cf31f to your computer and use it in GitHub Desktop.
Save pupi1985/ebeb18fae2d8cc9cf31f to your computer and use it in GitHub Desktop.
function doctype(){
if ($this->template === 'question' && isset($this->content['q_view'])) {
$this->addCategoryPrefixToTitleInList($this->content['q_view'], isset($this->content['title']));
}
qa_html_theme_base::doctype();
}
function addCategoryPrefixToTitleInList(&$q_item, $shouldChangeTitle) {
if (isset($q_item['raw']['categoryid'], $q_item['raw']['categoryname'], $q_item['title'])) {
$categoryId = $q_item['raw']['categoryid'];
if (!empty($categoryId)) {
$html = sprintf(
'<span class="qa-q-item-title-cat-%d">%s</span>',
$q_item['raw']['categoryid'],
$q_item['raw']['categoryname']
);
$q_item['title'] = $html . $q_item['title'];
if ($shouldChangeTitle) {
$this->content['title'] = $html . $this->content['title'];
}
}
}
}
function q_item_title($q_item) {
$this->addCategoryPrefixToTitleInList($q_item, false);
qa_html_theme_base::q_item_title($q_item);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment