Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+8 votes
932 views
in Q2A Core by
edited by

Hi there

I would like to change TAGS Urls mywebsite/tags/tag => in full UPPERCASE like that : mywebsite/tags/TAG

Any idea? Thanks it's really important for me!

Gidgreen gave an answer here, but it's not enough explicit => http://www.question2answer.org/qa/15084/how-to-make-tag-letters-uppercase

Q2A version: Last one
by
+1 why is there no answer for this?!!

1 Answer

0 votes
by
So you just want to uppercase the URL but not the text you see in the tag, right?
 
If that is the case, then locate this piece of code from the qa-app-format.php file:
 
function qa_tag_html($tag, $microformats=false, $favorited=false)
/*
Convert textual $tag to HTML representation, with microformats if $microformats is true. Set $favorited to true to show the tag as favorited.
*/
{
    if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
 
    return '<a href="'.qa_path_html('tag/'.strtoupper($tag)).'"'.($microformats ? ' rel="tag"' : '').' class="qa-tag-link'.
    ($favorited ? ' qa-tag-favorited' : '').'">'.qa_html(mb_strtoupper($tag, 'utf-8')).'</a>';
}
 
In that piece of code, you should turn this qa_path_html('tag/' . $tag) into this qa_path_html('tag/' . strtoupper($tag))

This change would make tags look like this:

If you also want to uppercase the content of the link (not just the link) you will have to wrap the second $tag in an strtoupper function too.

IMPORTANT: It is not clear to the time being if tags should contain accented letters (EG: á, ü, etc) or not. It seems gideon said they should not in this comment: https://github.com/q2a/question2answer/issues/47#issuecomment-42739538 However, I can see them so they seem to be allowed.

So, if you are expecting tags with accented letters AND your server has multibyte string support then then I'd recommend using mb_strtoupper($tag, 'utf-8') instead of strtoupper($tag).

If you don't know how to test if your server has multibyte string support then just use the mb_strtoupper function and see if it works :)

...