View Full Version : User Tags per Row for PMs
CoffeeLovesYou
04-06-2013, 05:48 PM
Hi,
Thanks to kh99, I currently have a certain number of user tags per row for Posts.
Here is the code I am using for Posts:
Hooked to postbit_display_start
$rowlen = $this->registry->userinfo['field50'];
if ($rowlen <= 0)
$rowlen = 5; // default columns
$ranklist = explode('<br />', $this->post[rank]);
$this->post[rank] = '';
$col = 0;
foreach($ranklist as $r)
{
if ($col >= $rowlen)
{
if ($this->post[rank] != '')
$this->post[rank] .= '<br />';
$col = 0;
}
$this->post[rank] .= $r;
$col++;
}
$this->post[rank] .= "<!-- field50 ='" . $this->registry->userinfo['field50'] . "' -->\r\n";
unset($col, $rowlen, $ranklist);
Now, how can I have the amount of user tags per row for PMs?
Can someone help me alter the code to work in private messages, please, and where to hook the plugin?
Thank you greatly
CoffeeLovesYou
04-07-2013, 11:34 PM
Bump. Looking for this
CoffeeLovesYou
04-09-2013, 06:48 AM
Bump
Lynne
04-09-2013, 03:47 PM
User tags in PMs? I have no idea what tags you are talking about in PMs.
CoffeeLovesYou
04-10-2013, 01:31 AM
User tags in PMs? I have no idea what tags you are talking about in PMs.
Hi Lynne, thanks for the reply.
You know how you can stack user ranks? Well, our ranks are stacked, however, they are stacked in rows. Right now, it is set 4 ranks per row.
See this pic below:
https://vborg.vbsupport.ru/external/2013/04/45.png
Anyway, kh99 helped me by providing the code to set the user ranks per row to '2' ranks per row for profiles, as well as '4' ranks per row or user choice for posts.
However, the code I am using for 4 ranks per row for posts does not work for PMs, too.
In PMs, the ranks are stacking all vertically, which looks horrid.
Look here:
https://vborg.vbsupport.ru/external/2013/04/46.png
So, yeah. $this->post[rank] must not work in Private Msgs. Or I am hooking it to the wrong location. Not sure. Can you help?
Lynne
04-10-2013, 01:46 AM
Have you tried that on a totally default style? The default style uses the same template for PMs and posts (assuming you are using the postbit_legacy template).
CoffeeLovesYou
04-11-2013, 12:34 AM
Have you tried that on a totally default style? The default style uses the same template for PMs and posts (assuming you are using the postbit_legacy template).
I am using the postbit template, actually, lol. It is just how I took the picture.
None of this code is in a template. This is all done through the plugin system.
Every rank added is set to 'Stack Rank'. This code stacks them in rows. So, if a user has 14 ranks, there will be two rows of 5, and then one row of 4 ranks. I need it to do this for PMs, too. Not sure where to hook my plugin or if anything needs to be changed in the plugin from posts to PMs (look at first PHP code posted)
Lynne
04-11-2013, 01:58 AM
I'm surprised you need a plugin to show the ranks. But anyway.... if you want to change the code just for the PM page, you may use this condition:
if (THIS_SCRIPT == 'private') {
rank code without <br /> between all ranks
}
However, if that code is being used in posts and it is fine, then my guess is this is a CSS issue. The only way to check that out is to be able to view the actual page using a tool like firebug. Are you familiar with that? You may view the CSS and perhaps make a div wider.
I see that you put in code to put the value of field50 into an html comment - what are you getting as the value? It looks like maybe the userfields aren't set when it's a pm, but that's kind of surprising because I've seen a lot of people do things in the postbit based on a custom profile field, but I don't remember anyone complaining about it not working in a PM.
Edit: Try changing the hook location to postbit_display_complete.
CoffeeLovesYou
04-13-2013, 12:06 PM
Thanks kh99, that worked (changing the hook to postbit_display_complete)
however, I am trying to use part of Lynne's suggestion so I can make it so in PMs, there are 3 ranks per row, whereas in posts, there are 5 ranks per row;
see here:
$rowlen = $this->registry->userinfo['field50'];
if ($rowlen <= 0)
if (THIS_SCRIPT == 'private') {
$rowlen = 3; // default columns } else {
$rowlen = 5; // default columns
$ranklist = explode('<br />', $this->post[rank]);
$this->post[rank] = '';
$col = 0;
foreach($ranklist as $r)
{
if ($col >= $rowlen)
{
if ($this->post[rank] != '')
$this->post[rank] .= '<br />';
$col = 0;
}
$this->post[rank] .= $r;
$col++;
}
$this->post[rank] .= "<!-- field50 ='" . $this->registry->userinfo['field50'] . "' -->\r\n";
unset($col, $rowlen, $ranklist);
}
and I tried this:
if (THIS_SCRIPT == 'private')
$rowlen = $this->registry->userinfo['field50'];
if ($rowlen <= 0)
$rowlen = 3; // default columns
$ranklist = explode('<br />', $this->post[rank]);
$this->post[rank] = '';
$col = 0;
foreach($ranklist as $r)
{
if ($col >= $rowlen)
{
if ($this->post[rank] != '')
$this->post[rank] .= '<br />';
$col = 0;
}
$this->post[rank] .= $r;
$col++;
}
$this->post[rank] .= "<!-- field50 ='" . $this->registry->userinfo['field50'] . "' -->\r\n";
unset($col, $rowlen, $ranklist);
} else {
$rowlen = $this->registry->userinfo['field4111'];
if ($rowlen <= 0)
$rowlen = 5; // default columns
$ranklist = explode('<br />', $this->post[rank]);
$this->post[rank] = '';
$col = 0;
foreach($ranklist as $r)
{
if ($col >= $rowlen)
{
if ($this->post[rank] != '')
$this->post[rank] .= '<br />';
$col = 0;
}
$this->post[rank] .= $r;
$col++;
}
$this->post[rank] .= "<!-- field50 ='" . $this->registry->userinfo['field50'] . "' -->\r\n";
unset($col, $rowlen, $ranklist);
}
that way, if they are on private, ranks show up 3 per row. if they are on a post/thread, it shows up with 5.
i can't have 5 in PMs as it is stretching the pm display. 3 or maybe 4 will be just enough per row in PMs
EDIT: NVM! I did it! Yay!
Thank you both for the help! Here is the code in postbit_display_complete
if (THIS_SCRIPT == 'private') {
$rowlen = $this->registry->userinfo['field50'];
if ($rowlen <= 0)
$rowlen = 4; // default columns
$ranklist = explode('<br />', $this->post[rank]);
$this->post[rank] = '';
$col = 0;
foreach($ranklist as $r)
{
if ($col >= $rowlen)
{
if ($this->post[rank] != '')
$this->post[rank] .= '<br />';
$col = 0;
}
$this->post[rank] .= $r;
$col++;
}
$this->post[rank] .= "<!-- field50 ='" . $this->registry->userinfo['field50'] . "' -->\r\n";
unset($col, $rowlen, $ranklist);
} else {
$rowlen = $this->registry->userinfo['field50'];
if ($rowlen <= 0)
$rowlen = 5; // default columns
$ranklist = explode('<br />', $this->post[rank]);
$this->post[rank] = '';
$col = 0;
foreach($ranklist as $r)
{
if ($col >= $rowlen)
{
if ($this->post[rank] != '')
$this->post[rank] .= '<br />';
$col = 0;
}
$this->post[rank] .= $r;
$col++;
}
$this->post[rank] .= "<!-- field50 ='" . $this->registry->userinfo['field50'] . "' -->\r\n";
unset($col, $rowlen, $ranklist);
}
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.