PDA

View Full Version : Stack Username markup from usergroups?


DragonBlade
10-24-2008, 06:13 PM
In order to "stack" the HTML markups for User Groups, you need to do the following:


Create a new TINYINT(1) field on your usergroup table
Add the following plugin for the "fetch_musername" hook:$gids = explode(',', $user['membergroupids']);
foreach ($gids AS $gid)
{
$info = $vbulletin->db->query_first(sprintf("SELECT stack_markup FROM " . TABLE_PREFIX . "usergroup WHERE usergroupid='%s'", $vbulletin->db->escape_string($gid)));
if ($info['stack_markup'] == '1')
{
$user['musername'] = $vbulletin->usergroupcache["$gid"]['opentag'] . $user['musername'] . $vbulletin->usergroupcache["$gid"]['closetag'];
}
}
For the "admin_usergroup_edit" hook, add the following plugin (so you can change the value via AdminCP and not have to do it manually in your SQL)print_table_header('Stack HTML Markup?');
print_yes_no_row('Would you like to stack the Usergroup markup for this group?', 'usergroup[stack_markup]', $usergroup['stack_markup']);
print_table_break();NOTE: Change stack_markup to whatever you named the table field in Step 1.







Hey, all. I'm programming a "shop" system, and I was wondering, is there a way to "stack" the username markup from usergroups?

For example, if a user was part of the "Items -- Bold", "Items -- Italic", and "Items -- Color: red" usergroups, can I combine those markups?

Lynne
10-24-2008, 07:27 PM
Not with the default vbulletin system. That would take some interesting coding to do.

DragonBlade
10-24-2008, 08:00 PM
Ah! I think I finally understand this hook system!

All I have to do is write the XML stuff like described here (https://vborg.vbsupport.ru/showthread.php?t=82625).

Then all I have to do is write the code in the CDATA tag?

Like my code could be something like this:


$gids = explode(',', $user['membergroupids']);
foreach ($gids AS $gid)
{
if is_stacked_display_usergroup($gid)
{
$user['musername'] = $vbulletin->usergroupcache["$gid"]['opentag'] . $user['musername'] . $vbulletin->usergroupcache["$gid"]['closetag'];
}
}

Then all I have to do is write the "is_stacked_usergroup()" function and maybe add a field to the membergroups table or something?

Is that really just how simple it is? :O

--------------- Added 1224887791 at 1224887791 ---------------

One more question, though.

How would I go about modding the AdminCP so that I can have a Yes/No radio button or a checkbox or something when adding/altering usergroups?

I've been looking at this thread (https://vborg.vbsupport.ru/showthread.php?t=82844), but I'm not sure if that's what I'm looking for. O.o

--------------- Added 1224895257 at 1224895257 ---------------

Oh, I see now! I can just make a plugin for the admin_usergroup_edit hook! :D

I understand now. :3 Yes yes yes...

* DragonBlade goes back to coding.

--------------- Added 1224902957 at 1224902957 ---------------

Yay! Completion!