Auto truncate titles of discussions created by embedded comments in WordPress
Hi,
I'm trying to set up Vanilla 2.1a33 to replace WordPress' commenting system. Basically it works just fine, but I have a problem with very long titles of discussions created automatically in Vanilla. In my case titles of WordPress posts are scrapped in following format:Post title | Full site name
. Since blog's name is some good 50 characters, titles are getting ridiculously long.
I was wondering if anybody got around this problem. As a lousy workaround, I have added the following to the class.postcontroller.php (thanks, stackoverflow):
function nsubstr($needle, $haystack, $n_occurrence) { $arr = explode($needle,$haystack,$n_occurrence); $last = count($arr) - 1; $pos_in_last = strpos($arr[$last],$needle); if ($pos_in_last !== false) $arr[$last] = substr($arr[$last],0,$pos_in_last); return implode($needle,$arr); } $Title = nsubstr('|',$Title,1);
As long as I'm not refetching, I'm fine (or at least I think I am). It would be nice if there was a proper solution.
Cheers,
Best Answer
-
peregrine MVP
@PolishKaragiozis said:
Thanks for the suggestion, but your function only truncates titles in discussions list, not in the discussion itself. Plus, I really want to keep all text before first pipe, so I need something like the function I have posted.no problem, whatever works for you.
It was just to show you how to do something without modifying a core file,
class.postcontroller.php and doing it via themehooks with appropriate function and whatever events you want to trigger on.I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
5
Answers
you could write a plugin to replace the title either via php or js, if you don't want to modify core.
or you might possibly do something in a themehooks file.
another alternative, equally messy
http://vanillaforums.org/discussion/comment/164019/#Comment_164019
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
you could put something like in your themehooks file
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Thanks for the suggestion, but your function only truncates titles in discussions list, not in the discussion itself. Plus, I really want to keep all text before first pipe, so I need something like the function I have posted.
no problem, whatever works for you.
It was just to show you how to do something without modifying a core file,
class.postcontroller.php and doing it via themehooks with appropriate function and whatever events you want to trigger on.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I've the same problem but the workaround of PolishKaragionis doesn't work! How I can remove all "Full site name" and "|"?