View Full Version : Change Tag Separators
JabirA
05-29-2012, 01:03 PM
Tags are separated by comma by default. How can I change this to a other character?
EDIT: Solved!!
1. in includes/class_taggablecontent.php there's a function split_tag_list(), and around line 295 there's this:
Change ',' to '\\\\'
$delimiters = array(',');
2. public function fetch_rendered_tag_list()
{
$taglist = $this->fetch_existing_tag_list();
return fetch_tagbits(implode(", ", $taglist));
}
3. and then in includes/functions_bigthree.php around line 435
function fetch_tagbits($tags)
{
global $vbulletin, $vbphrase, $show, $template_hook;
$tagcount = 0;
$tag_list = array();
if ($tags)
{
$tag_array = explode(',', $tags);
foreach ($tag_array AS $tag)
{
$row = array();
$tag = trim($tag);
if ($tag === '')
{
continue;
}
$tagcount++;
$row['tag'] = fetch_word_wrapped_string($tag);
$row['url'] = urlencode(unhtmlspecialchars($tag));
$row['comma'] = '$vbphrase['comma_space']';
In Settings > Options > Tagging Options, there's a "Tag Separators" setting where you can enter additional separators, but for some reason you can't remove comma as a separator (you'd have to find the code that looks for commas and change it).
JabirA
05-30-2012, 07:24 AM
Yes I know that kh99. And I need help with that. I can't do that on my own. :(
Well, in includes/class_taggablecontent.php there's a function split_tag_list(), and around line 295 there's this:
$delimiters = array(',');
which seems to be where comma is defined as a delimiter. You could try changing or deleting the comma from that line, but I haven't tried it and I don't know if it's the only place where you'd need to make a change.
JabirA
05-30-2012, 11:54 AM
Already tried that one. Didn't help
Well, that's one place, and changing it to a semicolon allowed me to enter tags separated by semicolons, but some of the display code still uses commas. In that same file around line 894 there's this:
public function fetch_rendered_tag_list()
{
$taglist = $this->fetch_existing_tag_list();
return fetch_tagbits(implode(", ", $taglist));
}
and then in includes/functions_bigthree.php around line 435 there's function fetch_tagbits($tags) which expects a comma-separated list of tags. That function formats the list using a phrase $vbphrase['comma_space'] (and you probably don't want to change the text of that phrase because it's used in other places).
JabirA
05-30-2012, 01:20 PM
Well, that's one place, and changing it to a semicolon allowed me to enter tags separated by semicolons, but some of the display code still uses commas. In that same file around line 894 there's this:
public function fetch_rendered_tag_list()
{
$taglist = $this->fetch_existing_tag_list();
return fetch_tagbits(implode(", ", $taglist));
}
and then in includes/functions_bigthree.php around line 435 there's function fetch_tagbits($tags) which expects a comma-separated list of tags. That function formats the list using a phrase $vbphrase['comma_space'] (and you probably don't want to change the text of that phrase because it's used in other places).
I dont understand. Do you want me to change something there?
Yeah, you would have to change this (the comma in red):
public function fetch_rendered_tag_list()
{
$taglist = $this->fetch_existing_tag_list();
return fetch_tagbits(implode(", ", $taglist));
}
and then in includes/functions_bigthree.php around line 435, another comma in red (in the explode call), and the $vbphrase['comma_space'] you can replace a string:
function fetch_tagbits($tags)
{
global $vbulletin, $vbphrase, $show, $template_hook;
$tagcount = 0;
$tag_list = array();
if ($tags)
{
$tag_array = explode(',', $tags);
foreach ($tag_array AS $tag)
{
$row = array();
$tag = trim($tag);
if ($tag === '')
{
continue;
}
$tagcount++;
$row['tag'] = fetch_word_wrapped_string($tag);
$row['url'] = urlencode(unhtmlspecialchars($tag));
$row['comma'] = $vbphrase['comma_space'];
there may be other places as well, but try this.
JabirA
05-30-2012, 01:37 PM
Yeah, you would have to change this (the comma in red):
public function fetch_rendered_tag_list()
{
$taglist = $this->fetch_existing_tag_list();
return fetch_tagbits(implode(", ", $taglist));
}
and then in includes/functions_bigthree.php around line 435, another comma in red (in the explode call), and the $vbphrase['comma_space'] you can replace a string:
function fetch_tagbits($tags)
{
global $vbulletin, $vbphrase, $show, $template_hook;
$tagcount = 0;
$tag_list = array();
if ($tags)
{
$tag_array = explode(',', $tags);
foreach ($tag_array AS $tag)
{
$row = array();
$tag = trim($tag);
if ($tag === '')
{
continue;
}
$tagcount++;
$row['tag'] = fetch_word_wrapped_string($tag);
$row['url'] = urlencode(unhtmlspecialchars($tag));
$row['comma'] = $vbphrase['comma_space'];
there may be other places as well, but try this.
If I want tags to be seperated with "\" , do I have to adjust this: $row['comma'] = $vbphrase['comma_space']; to : $row['comma'] = $vbphrase['\'];
If I want tags to be seperated with "\" , do I have to adjust this: $row['comma'] = $vbphrase['comma_space']; to : $row['comma'] = $vbphrase['\'];
No, I would just make it $row['comma'] = '\\ '; (the backslash needs to be escaped, so there's three chars in there - two backslashes and a space).
JabirA
05-30-2012, 01:53 PM
I did this. When I add a tag with a comma in it it gives me this error:
Parse error: syntax error, unexpected '{', expecting ')' in C:\domains\*****.nl\wwwroot\includes\class_taggabl econtent.php on line 302
I'm guessing you made a mistake when editing line 295. (The $delimiters = array(',') line). If you changed that to a backslash, you need to escape it, like:
$delimiters = array('\\');
JabirA
05-30-2012, 02:03 PM
Indeed I did! Great thank you!! :D
This works perfectly.
Great. And you can probably figure this out, but if you're using a backslash, maybe you want to remove the space from the $row['comma'] = '\\ '; line.
JabirA
05-30-2012, 02:09 PM
Removed it. Thank you :)
You are a lifesaver!
--------------- Added 1338391462 at 1338391462 ---------------
I have one problem though. When I opened a topic and inserted the tag. When I click on it, it gives me this error:
Warning: preg_split() [function.preg-split]: Compilation failed: missing ) at offset 3 in C:\domains\******.nl\wwwroot\includes\class_taggab lecontent.php on line 320
Warning: array_map() [function.array-map]: Argument #2 should be an array in C:\domains\******.nl\wwwroot\includes\class_taggab lecontent.php on line 322
Warning: Invalid argument supplied for foreach() in C:\domains\*****.nl\wwwroot\vb\search\criteria.php on line 370
Try changing $delimiters = array('\\'); (around line 295) to $delimiters = array('\\\\');
JabirA
05-30-2012, 02:42 PM
Yes, that seems to do the trick.
Tags are instant right? If add a tag I should be able to search for it directly or not?
Tags are instant right? If add a tag I should be able to search for it directly or not?
As far as I know. I'm not really sure. I guess you're going to say that you're not able to search for the tags you're adding?
JabirA
05-30-2012, 02:45 PM
Yes that was my next question.
Also if I click on the tag it says: Invalid Tag Specified
Edit: When I click on a tag the topic appears. But when I search for the tag it wont work.
Yeah, I was kind of afraid there would be more places that need to be changed. But unfortunately I don't have time to look into it right now. I'll have to check later.
JabirA
05-30-2012, 02:55 PM
Yeah, I was kind of afraid there would be more places that need to be changed. But unfortunately I don't have time to look into it right now. I'll have to check later.
I thought so to.
Well thank you for your help so far!
I am looking forward to your help. :)
Well, bad news I'm afraid - the tags are saved in the thread table in the database as a comma-separated list, and that field seems to be used in a number of places. It may not be practical to find and change every place needed to make this work. (In any case, I'm afraid I don't have the time to do it).
JabirA
05-31-2012, 02:17 PM
Thanks again for your time kh99! You helped alot so far. :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.