vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=288204

Add username to widget title
by AcheronAI
23 Sep 2012 14:09

I am trying to get a widget to where the title changes per user, I have yet to find the right place to do this.

Any help would be very much appreciated.

kh99 23 Sep 2012 14:35

You could find the template associated with the widget and put a variable in for the title (the CMS templates are in the vBulletin CMS templates group). If you can't guess the template name, you can temporarily turn on "Add Template Name in HTML Comments" (in the General Settings section) and view the html source of the page, then find the widget title html and look for the comment telling you which template it in.

AcheronAI 23 Sep 2012 14:43

I tried putting welcome $vbulletin->userinfo[username] and it just shows exactly what I typed as a title.

I am using a php output widget, and yet to find a way to get this done how I wish lol

kh99 23 Sep 2012 14:47

If you're putting it in the template, then you'd need to use {vb:raw bbuserinfo.username}. Also, if it's a php custom widget then you can set which template you want to use as a "wrapper", and if you use the default template and make changes to it, it will change all php custom widgets (assuming you have more than one).

AcheronAI 23 Sep 2012 15:42

Actually I was just trying to add to the title to be displayed by the widget to fit who is viewing. I figured it out with a bit of work.

Thanks for the help though :)

kh99 23 Sep 2012 15:45

Oh, I see (I think) - you managed to change the title variable in the php code? You should post what you did in case someone else wants to know.

AcheronAI 23 Sep 2012 16:07

Well this is not pretty , fair warning lol

First I made a new PHP Direct Execution widget and for the title put
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

or what ever you wish, it just has to match up in this next part.

Create a new plugin with the hook location

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Use the following php code

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It is so simple once I finally pinned it down, but finding it was not fun :)
But now you can add any code you wish before hand and have $newtitle reflect what you wish to show in the php widget title area.

kh99 23 Sep 2012 16:28

That looks good to me. When you're modding stuff, anything goes as long as it works, IMHO. And that solution saves having to mess with the templates.

AcheronAI 23 Sep 2012 16:35

Ya the only thing I did with templates was get rid of the ugly php icon. I tested this with putting an image in the title, and it looked nice.


All times are GMT. The time now is 10:49.

Powered by vBulletin® Version 3.8.14
Copyright © 2021, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.