Created
October 12, 2014 17:09
-
-
Save pupi1985/ebeb18fae2d8cc9cf31f to your computer and use it in GitHub Desktop.
Answer to question http://www.question2answer.org/qa/39385/how-can-i-override-qa_post_html_fields-in-qa-app-format-php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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