vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Add username to widget title (https://vborg.vbsupport.ru/showthread.php?t=288204)

AcheronAI 09-23-2012 12:09 PM

Add username to widget title
 
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 09-23-2012 12:35 PM

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 09-23-2012 12:43 PM

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 09-23-2012 12:47 PM

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 09-23-2012 01:42 PM

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 09-23-2012 01:45 PM

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 09-23-2012 02:07 PM

Well this is not pretty , fair warning lol

First I made a new PHP Direct Execution widget and for the title put
PHP Code:

{vartitle

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

Create a new plugin with the hook location
PHP Code:

vbcms_process_widget_complete 

Use the following php code
PHP Code:

global $vbulletin;
$newtitle "Your new title";
$widget_views[$widgetid] = str_replace("{vartitle}"$newtitle ,$widget_views[$widgetid]); 

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 09-23-2012 02:28 PM

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 09-23-2012 02:35 PM

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 02:36 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00972 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete