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

How to automatically capitalize URLs like this ? =>

2 Answers

+1 vote
by
edited by

ok, here is quick core hack:

in 'qa-base.php' find 'qa_q_request' function. at the end of it replace

        return (int)$questionid.'/'.$title;

with

        return (int)$questionid.'/'.strtoupper($title);
 


OK, I made a quick guide to create a plugin for this(nothing fancy), you can check it here:

http://qa-themes.com/forums/topic/capitalizing-urls-of-questions

I don't think that many people will like to use it since lower case URL's look cleaner, but if I'm wrong and there is more request I can add it to repository.

by
edited by
Hi Qa-Themes, your hack "uppercase" all letters..., I just want the first letter of each word to "capitalize". And it's not working with tag.
by
well, I guess this will do:
    return  str_replace(' ', '?', ucwords(str_replace('?', ' ',  str_replace(' ', '/', ucwords(str_replace('/', ' ', str_replace(' ', '-', ucwords( str_replace('-', ' ', strtolower($url)) )) )) ))));
too many brackets? :D
by
edited by
well some errors, thanks anyway, I will use full uppercase,and how to change the same function for Tags?
by
are you sure you didn't add last line? it's just this line of code and it works on all six permalinks types:

     return  str_replace(' ', '?', ucwords(str_replace('?', ' ',  str_replace(' ', '/', ucwords(str_replace('/', ' ', str_replace(' ', '-', ucwords( str_replace('-', ' ', strtolower($url)) )) )) ))));
by
I add this =>
     return (int)$questionid.'/'.strtoupper($title);
        return  str_replace(' ', '?', ucwords(str_replace('?', ' ',  str_replace(' ', '/', ucwords(str_replace('/', ' ', str_replace(' ', '-', ucwords( str_replace('-', ' ', strtolower($url)) )) )) ))));

And users and tags urls are still lowers. And question pages are full uppercase.
by
you must remove the fist line, because when a 'return' command is executed nothing after that will be called.
by
edited by
I add only this =>  return  str_replace(' ', '?', ucwords(str_replace('?', ' ',  str_replace(' ', '/', ucwords(str_replace('/', ' ', str_replace(' ', '-', ucwords( str_replace('-', ' ', strtolower($url)) )) )) ))));

and I have these error => <b>Notice</b>:  Undefined variable: url in <b>/home/numeroco/public_html/odlg.org/qa-include/qa-base.php</b> on line <b>1255</b><br />
by
create a plugin according to this guide: http://qa-themes.com/forums/topic/capitalizing-urls-of-questions
in case you want to do the core hack, replace
     return (int)$questionid.'/'.$title;
with
     return  str_replace(' ', '?', ucwords(str_replace('?', ' ',  str_replace(' ', '/', ucwords(str_replace('/', ' ', str_replace(' ', '-', ucwords( str_replace('-', ' ', strtolower((int)$questionid.'/'.$title)) )) )) ))));
asked Feb 14, 2014 in Q2A Core by
edited Feb 28, 2014 by
NEED HELP => How To Uppercase TAGS Urls ?
0 votes
by
this feature is added as a part of a new plugin I developed. check it out here:

http://www.question2answer.org/qa/33567/new-plugin-url-customizer
...