PDA

View Full Version : [How-to] Add more tabs to the vB 3.7 profile pages


calorie
19 Dec 2007, 07:29
If you want to add more tabs to the vB 3.7 profile pages, assuming JavaScript is enabled, or more blocks if JavaScript is off, then this tutorial is for you. If you like to learn in a trial by fire sort of way, create a new template titled memberinfo_block_mymodification with the following content:

<div class="alt1 block_row">
<ul class="list_no_decoration">
$block_data[mymodification]
</ul>
</div>

Add a new plugin to the member_build_blocks_start hook with the following PHP code:

$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'MyModification',
'title' => 'My Modification',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_mymodification';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['mymodification'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['mymodification'] = 'Content to show in the tab.';
}
}

Now visit your profile page to test it out. You should see a 'My Modification' tab that when clicked shows you the following text: Content to show in the tab. Exciting huh? Of course you need to add your own custom code for what to display, but this tutorial isn't about that, but rather to show you how to add tabs to the profile pages.

If you want to learn a bit more of the details, first consider this part:

$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'MyModification',
'title' => 'My Modification',
'hook_location' => 'profile_left_last'
)
));

The $blocklist variable contains the default blocks. You merge to that another array where the key 'mymodification' references an array which sets a class to use, the title of the tab on the profile page, and the hook location. You can set whatever you want for title including the use of $vbphrase but in the example 'My Modification' is used. As for the hook location, you can use profile_left_first or profile_left_last depending on whether you want your new tab to be left or right of the current tabs, respectively.

Next consider the next part:

class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_mymodification';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['mymodification'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['mymodification'] = 'Content to show in the tab.';
}
}

The class needs to be called vB_ProfileBlock_MyModification extends vB_ProfileBlock and note that part of the class name is vB_ProfileBlock_MyModification where MyModification comes from the class value set in your addition to the $blocklist variable. Inside the class, $template_name is set to the template to use, the confirm_empty_wrap function returns false to not create an empty block, the confirm_display function tests whether there is any content to display, and the prepare_output function is where you’d want to add your own custom code to fetch whatever you want to display, setting $this->block_data['mymodification'] to the content you want displayed. Remember variable scope when you add your own code, as you are inside a function that is inside a class.

Now there is the new template itself:

<div class="alt1 block_row">
<ul class="list_no_decoration">
$block_data[mymodification]
</ul>
</div>

Note that $block_data[mymodification] contains whatever $this->block_data['mymodification'] contains in the prepare_output function inside the class, and because a hook location is set in your addition to the $blocklist variable, there are no manual template edits to make. Hooray! You should of course replace 'mymodification', 'MyModification', and 'My Modification' throughout this tutorial with something meaningful for your modification.

Finally there are other things that can be added to modifications such as options, and these can be seen in the vB class_profileblock.php and member.php files, though this tutorial should get you on your way to adding more content to the profile pages via additional tabs, but remember not to go overboard with queries, because even though you need to click the tab to see the content, whatever queries you run get run on page load, not tab click. Enjoy!

Fine print: tutorial based on vB 3.7.0 Beta 2, no redistribution without permission.

Magnumutz
19 Dec 2007, 10:17
VERY nice calorie... this is really helpful.

Triky
19 Dec 2007, 11:21
This will be helpfull. :)
Thank you!

Lynne
24 Dec 2007, 03:44
Thank you so much for this! It was very helpful.

hfr-Neil
26 Dec 2007, 17:43
Thank you for this tuto ;)

eurofunny
01 Jan 2008, 18:07
Hi, nice Tutorial. Thx

Audentio
02 Jan 2008, 04:31
Excellent, very nice. Thanks for making this for us.

Zaiaku
03 Jan 2008, 00:44
Useful and Helpful Thx!

Berker Unluer
03 Jan 2008, 00:52
Thnx! Excelent!

bdude
20 Jan 2008, 06:33
How do I create a block on the right hand side?

ragtek
20 Jan 2008, 21:53
with:
'hook_location' => 'profile_left_first'

possible locations:

'' => $vbphrase['only_in_about_me_tab'],
'profile_left_first' => $vbphrase['main_column_first_tab'],
'profile_left_last' => $vbphrase['main_column_last_tab'],
'profile_right_first' => $vbphrase['blocks_column_first'],
'profile_right_mini' => $vbphrase['blocks_column_after_mini_stats'],
'profile_right_album' => $vbphrase['blocks_column_after_albums'],
'profile_right_last' => $vbphrase['blocks_column_last']
);

eNforce
26 Jan 2008, 19:51
For the contents of the tab how can I pull a custom profile field?

$blocklist = array_merge($blocklist, array(
'custom' => array(
'class' => 'custom',
'title' => 'Custom Tab (Work in Progress)',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_custom extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_custom';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['custom'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['custom'] = '<if condition="$userinfo[field8]"><strong>Stuff:</strong> $userinfo[field8]<br /></if> ';
}
}

It just outputs as "$userinfo[field8]" instead of what was typed in via User CP.

marcossalazar
11 Feb 2008, 21:57
Thanks for the article!

Wayne Luke
23 Feb 2008, 16:16
For the contents of the tab how can I pull a custom profile field?

Do something like this for your prepare_output function

function prepare_output($id = '', $options = array())
{

$this->block_data['custom'] = $this->profile->userinfo['field8'] : "Stuff: $this->profile->userinfo['field8']" ? "Nothing to see here";
}
}

Neutral Singh
25 Feb 2008, 15:09
How can we create similar tab like "About Me" contents of which are user editable on the page itself. This facility should have inbuilt into vbulletin as a default.

Princeton
28 Feb 2008, 13:48
just noticed this tut - outstanding!

msimplay
10 Mar 2008, 00:42
Was wondering how would i get this peice of code into a block

// Champion games in profile
$profilegq = $db->query_read("SELECT u.userid AS userid, g.gameid AS gameid, g.title AS title, g.miniimage AS image FROM " . TABLE_PREFIX . "arcade_games AS g LEFT JOIN " . TABLE_PREFIX . "user AS u ON u.userid = g.highscorerid WHERE u.userid = $userinfo[userid] ORDER BY g.title ASC");
while ($profileg = $db->fetch_array($profilegq)){
$pgrow .= "<a href=\"arcade.php?do=play&gameid=$profileg[gameid]\"><img src=\"./images/arcade/$profileg[image]\" alt=\"\" title=\"Play $profileg[title]!\" border=\"0\" /></a> &nbsp;&nbsp;";
}

$acount = $db->num_rows($profilegq);

Inferno Dragon
11 Mar 2008, 14:08
Very nice tutorial indeed..thanks a lot :) but as MSimplay said above, I am also interested in adding some custom DB queries for displaying items from the DB :) is it possible?

Chris-777
18 Mar 2008, 22:25
Do something like this for your prepare_output function

function prepare_output($id = '', $options = array())
{

$this->block_data['custom'] = $this->profile->userinfo['field8'] : "Stuff: $this->profile->userinfo['field8']" ? "Nothing to see here";
}
}

This doesn't work for me - the tab disappears.

Jase2
22 Mar 2008, 22:19
A great tutorial! Thanks!

One question, to get this to show you have to click the small arrow at the end; is there any way to get it too show all tabs by default, without having to click the arrow? This only happens when the 'Infraction' tab is showing too...any way to get them all show?

Regards Jason :)

rob30UK
26 Mar 2008, 13:47
I can get the tab to show custom profile fields, but i want the same fields to be removed from the about me section - how would this be achieved?

TWTCommish
27 Mar 2008, 06:01
This is quite helpful. Is there any way to add dynamic content to the tab, however? I've tried everything I can think of to achieve this, but the scope of the class won't allow for it. Is this method relegated to static content, or can this be done?

Blackhat
29 Mar 2008, 14:35
Im using this in my plugin, but the tab disappeared


function prepare_output($id = '', $options = array())
{
$this->block_data['custom'] = $this->profile->userinfo['field17'] : "Stuff: $this->profile->userinfo['field17']" ? "Nothing to see here";
}


--------------- Added 1206807291 at 1206807291 ---------------

ok I got it working with this code, but it looks like it wont custom html by my users like this


$blocklist = array_merge($blocklist, array(
'customcode' => array(
'class' => 'CustomCode',
'title' => 'My Media',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_CustomCode extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_customcode';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['customcode'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['customcode'] = $this->profile->userinfo['field17'];
}
}


I want my users to insert the embed code for their playlists generated at youtube

SEOvB
30 Mar 2008, 22:02
How would i add a custom template to be put inside the block?

Peterpan002
05 Apr 2008, 17:55
A very helpful article thank you, just not quite enough help for non coders like me.

I successfully created new tab and with the following code I now get output of "field 12" showing but not "field 11" instead of both showing, am also having difficulty inserting the field title in the output. A little help maybe.

$blocklist = array_merge($blocklist, array(
'checklist' => array(
'class' => 'checklist',
'title' => 'Checklist (Work in Progress)',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_checklist extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_checklist';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['checklist'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['checklist'] = $this->profile->userinfo['field11'];


$this->block_data['checklist'] = $this->profile->userinfo['field12'];
}



}

--------------- Added 1207495466 at 1207495466 ---------------

I would really appreciate a little help with this as its so close to working fully - :o Bump

Makc666
09 Apr 2008, 12:51
I successfully created new tab and with the following code I now get output of "field 12" showing but not "field 11" instead of both showing, am also having difficulty inserting the field title in the output. A little help maybe.

I would really appreciate a little help with this as its so close to working fully - :o Bump

This one:
function prepare_output($id = '', $options = array())
{
$this->block_data['checklist'] = $this->profile->userinfo['field11'];


$this->block_data['checklist'] = $this->profile->userinfo['field12'];
}
}

To this one:
function prepare_output($id = '', $options = array())
{
$this->block_data['checklist'] = $this->profile->userinfo['field11'];
$this->block_data['checklist'] .= $this->profile->userinfo['field12'];
}
}

--------------- Added 1207746300 at 1207746300 ---------------

My question here...

In vBulletin 3.6.* I had such code in product:
<plugin active="1" executionorder=5" product="test">
<title>Test - member complete</title>
<hookname>member_complete</hookname>
<phpcode><![CDATA[if (THIS_SCRIPT == 'member')
{
$test = "Hellow!";
if ($vbulletin->options[test_auto])
{
$footer = $test.$footer;
}
}]]></phpcode>
</plugin>

Question: How to add $test to the new tab?

This one doesn't work:
function prepare_output($id = '', $options = array())
{
$this->block_data['test'] = "$test";
}

Peterpan002
09 Apr 2008, 16:21
Thank you Makc666.

Moving on LOL. New Tab is now outputting what I want.

Next issue and I'm sure others need to know this as well.

On the "About tab" is the option "simple link" - View your "About Me" as seen by everyone else. situated on the left which calls member.php?u=1&tab=aboutme&simple=1

I have reproduced this on my new tab which calls member.php?u=1&tab=newtab&simple=1

exept it doesnt it just reloads the main memberinfo page.

Any pointers???

Makc666
09 Apr 2008, 20:26
Next issue and I'm sure others need to know this as well.

On the "About tab" is the option "simple link" - View your "About Me" as seen by everyone else. situated on the left which calls member.php?u=1&tab=aboutme&simple=1

I have reproduced this on my new tab which calls member.php?u=1&tab=newtab&simple=1

exept it doesnt it just reloads the main memberinfo page.

Any pointers???
Show the code you are speaking about.
The code that you had added.

Peterpan002
09 Apr 2008, 22:10
My Custom template called for the tab

<div class="alt1 block_row" align="right">

<if condition="$show['simple_link']">
<div id="simple_experience"><a class="smallfont" href="member.php?$session[sessionurl]u=$bbuserinfo[userid]&amp;tab=experience&amp;simple=1">$vbphrase[view_your_extra_options]</a></div>
</if>
<if condition="$show['edit_link']">
<div id="simple_experience_link"><a class="smallfont" href="member.php?$session[sessionurl]u=$bbuserinfo[userid]&amp;tab="profile_left_last">$vbphrase[edit_extra_options]</a></div>
</if>



<div class="alt1 block_row" align="left">

<ul class="list_no_decoration">
$block_data[experience]

<!-------------------------Extra option profile fields-------->

<dt class="shade" id="profilefield_title_$profilefield[profilefieldid]">$profilefield[title]</dt>

<br>
<if condition="$userinfo[field11]">Field Title 11 $userinfo[field11]<br /></if>

<br>
<if condition="$userinfo[field12]">Field Title 12 $userinfo[field12]<br /></if>

<br>
<if condition="$userinfo[field14]">Field Title 14 $userinfo[field14]<br /></if>

<br>
<if condition="$userinfo[field13]">Field Title 13 <br> $userinfo[field13]<br /></if>

<br>

<if condition="$userinfo[field15]">Field Title 15 </if>
<if condition="$comma = ''"></if>

<if condition="$userinfo['field15'] & 1">
$comma Option A
<if condition="$comma = ', '"></if>
</if>
<if condition="$userinfo['field15'] & 2">
$comma Option B
<if condition="$comma = ', '"></if>
</if>
<if condition="$userinfo['field15'] & 4">
$comma Option C
<if condition="$comma = ', '"></if>
</if>
<if condition="$userinfo['field15'] & 8">
$comma Option D
<if condition="$comma = ', '"></if>
</if>
<if condition="$userinfo['field15'] & 16">
$comma Option E
<if condition="$comma = ', '"></if>
</if>

<br>
<br>
<if condition="$userinfo[field16]">My Yes/No answer is: $userinfo[field16]<br /></if>

<br>
<if condition="$userinfo[field17]">My Selection Menu Choice is: $userinfo[field17]<br /></if>



</ul>
</div>
</div>

and the "Member_build_blocks_start plug in code to call template


$blocklist = array_merge($blocklist, array(
'checklist' => array(
'class' => 'experience',
'title' => 'My Experience',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_experience extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_experience';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['experience'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['experience'] = 'My Experience:';


}


}

:confused:

Makc666
10 Apr 2008, 14:43
My Custom template called for the tab
Sorry, but I was not able to display your template.
It always show we blank.
You can upload a ready test product for us to try if you want.

zmmmzz
11 Apr 2008, 17:45
this is awesome.

Makc666
12 Apr 2008, 12:13
this is awesome.
Maybe, but...

In vBulletin 3.6.* I had such code in product:
<plugin active="1" executionorder=5" product="test">
<title>Test - member complete</title>
<hookname>member_complete</hookname>
<phpcode><![CDATA[if (THIS_SCRIPT == 'member')
{
$test = "Hellow!";
if ($vbulletin->options[test_auto])
{
$footer = $test.$footer;
}
}]]></phpcode>
</plugin>

Question: How to add $test to the new tab?

This one doesn't work:
function prepare_output($id = '', $options = array())
{
$this->block_data['test'] = "$test";
}

TECK
15 Apr 2008, 12:37
Nice info Miss Morgan, thank you. :)

Kicks
17 Apr 2008, 11:55
how to add some profilefields now in this tab ?

--------------- Added 1208516534 at 1208516534 ---------------

no one an idea ?

M-Tuning
20 Apr 2008, 09:16
How to display tabs only for certain usergroups?

I have been trying some stuff out but I get an error whatever I do:

Parse error: syntax error, unexpected '<' in .....

King Kovifor
27 Apr 2008, 20:37
How to display tabs only for certain usergroups?

I have been trying some stuff out but I get an error whatever I do:

Parse error: syntax error, unexpected '<' in .....
It appears there is < within your PHP code. Please post in the programming discussions for help.

WhaLberg
01 May 2008, 02:13
Maybe, but...

In vBulletin 3.6.* I had such code in product:
<plugin active="1" executionorder=5" product="test">
<title>Test - member complete</title>
<hookname>member_complete</hookname>
<phpcode><![CDATA[if (THIS_SCRIPT == 'member')
{
$test = "Hellow!";
if ($vbulletin->options[test_auto])
{
$footer = $test.$footer;
}
}]]></phpcode>
</plugin>

Question: How to add $test to the new tab?

This one doesn't work:
function prepare_output($id = '', $options = array())
{
$this->block_data['test'] = "$test";
}

This won't work. Why? Because there is no variable named as $test in the function prepare_output. You need to have it there.

Example:

function prepare_output($id = '', $options = array())
{
$visitedcountries = "Turkiye, Kazakistan, Kirgizistan, Turkmenistan, Uzbekistan";
$this->block_data['visitedcountries'] = $visitedcountries;
}


How do I know that? Thought on this about half an hour and noticed after that. :D

Code Monkey
02 May 2008, 16:00
Thanks for this Calorie. Saved me a lot of leg work.

skhms
02 May 2008, 19:53
This was usefull, thanks!

/SK

Blackhat
03 May 2008, 17:15
Ok, finaly I got it to show my users flash players from youtube


$blocklist = array_merge($blocklist, array(
'mediabox' => array(
'class' => 'MediaBox',
'title' => 'Mediabox',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_MediaBox extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_mediabox';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['mediabox'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['mediabox'] = '

<object width="676" height="386">
<param name="movie" value="http://www.youtube.com/cp/'.$this->profile->userinfo['field17'].'"></param>
<param name="wmode" value="transparent"></param>

<embed src="http://www.youtube.com/cp/'.$this->profile->userinfo['field17'].'" type="application/x-shockwave-flash" wmode="transparent" width="676" height="386"></embed>
</object>

';
}
}

Wired1
12 May 2008, 03:10
Anyone gotten the Edit stuff to work on new tabs? Only messed with it for a couple of min myself while working on updating my mods.

kinggori
13 May 2008, 21:14
Thanks for the awesome article :) Gave it 5/5 :)

Quick question... how can I have a link that goes (displays) directly to the new tab I created instead of the contents of the first tab on the list?

tafreeh
15 May 2008, 19:24
OMG this is soo confusing, is there any easier way to do it ?

Wired1
15 May 2008, 19:52
It's pretty easy actually. Pop in the 2 quotes in the article, and that's it.

If you just want a tab for a profile category, that's built in.

soulface
19 May 2008, 07:42
Nice article, works fine. But can anyone tell me how I can call a custom templates for data into that tab ?

craiovaforum
19 May 2008, 19:12
thanks ;)

Code Monkey
20 May 2008, 20:57
So what's the deal with phrases? It seems only GLOBAL phrases work in blocks no matter what you put in the new class. Even if the phrasegroup shows as available for the page. So there must be some issue with scope here that isn't cured by a mere addition of "global $vbphrase;".

DieselTruck
23 May 2008, 01:02
How can I disable the new tab for all usergroups but one?

XTF
28 May 2008, 12:20
I've simplified the following code fragment a bit.

$blocklist['mymodification'] = array
(
'class' => 'MyModification',
'title' => 'My Modification',
'hook_location' => 'profile_left_last'
);


How do I access for example $userinfo inside prepare_output()? I've used global $userinfo, but that doesn't seem to do the trick.

intrigue
28 May 2008, 17:11
Awesome thanks very much this has answered one question at least
Matt

Code Monkey
28 May 2008, 17:54
I've simplified the following code fragment a bit.

$blocklist['mymodification'] = array
(
'class' => 'MyModification',
'title' => 'My Modification',
'hook_location' => 'profile_left_last'
);
How do I access for example $userinfo inside prepare_output()? I've used global $userinfo, but that doesn't seem to do the trick.

Presuming you are referring to the user info of the profile and not the viewer.

$this->profile->userinfo

XTF
31 May 2008, 13:10
Thanks. Do I have to use $block_data to pass variables to the template or can I use arbitrary variable names?
This code seems to be more complex than needed.

Code Monkey
02 Jun 2008, 06:43
Thanks. Do I have to use $block_data to pass variables to the template or can I use arbitrary variable names?
This code seems to be more complex than needed.

I'm still working all that out. It appears that you can use variables when you eval your own templates but you need to use the $this->block_data array for passing things to the main template.

Wired1
09 Jun 2008, 06:37
Has anyone using a custom tab stumbled upon the bit of code that allows you to link directly to a tab, like so:

http://www.domain.com/member.php?u=1&tab=contactinfo

I'm thinking there's some java code somewhere doing it (I believe the tabs are AJAX), but haven't found the right bit just yet.

intrigue
09 Jun 2008, 10:04
Has anyone using a custom tab stumbled upon the bit of code that allows you to link directly to a tab, like so:

http://www.domain.com/member.php?u=1&tab=contactinfo

I'm thinking there's some java code somewhere doing it (I believe the tabs are AJAX), but haven't found the right bit just yet.

funnily enough i need to do the same thing.

Matt

ruhrpottforum
10 Jul 2008, 19:00
For some hours I try to get photopost pro latest addition (http://www.photopost.com/forum/photopost-pro-mods/121321-photopost-recent-images-profile-page.html) to members gallery into a new tab but for some reason (a hook?) it didn't work - it will only work if I place the code in that MEMBERINFO template ...

MissKalunji
06 Aug 2008, 11:20
how would that work if i want to add a varibable like for ishop?

$ishop example? that's the code below

<!-- show inventory -->
<fieldset><legend><a href="ishop.php?do=ViewMember&id=$userinfo[userid]" title="$userinfo[username]'s Inventory">$userinfo[username]'s Inventory</a></legend>
<div>
$userinfo[invrow]
<br>
</div>
</fieldset>
<!-- /show inventory -->

yingzhou
06 Aug 2008, 12:04
how would that work if i want to add a varibable like for ishop?

$ishop example? that's the code below

can't do this! :mad:

MissKalunji
06 Aug 2008, 22:12
i can't?

MissKalunji
10 Aug 2008, 17:15
Got it working! thanks

milla da killa
01 Sep 2008, 22:39
$blocklist = array_merge($blocklist, array(
'playlist' => array(
'class' => 'Playlist',
'title' => 'Playlist',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_playlist extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_playlist';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['playlist'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['playlist'] = '<div style="text-align: center; margin-left: auto; visibility:visible; margin-right: auto; width:450px;"><embed style="width:435px; visibility:visible; height:270px;" allowScriptAccess="never" src="http://www.greatprofilemusic.com/mc/mp3player-othersite.swf?config=http://www.greatprofilemusic.com/mc/config/config_black_shuffle.xml&mywidth=435&myheight=270&playlist_url=http://www.greatprofilemusic.com/loadplaylist.php?playlist='$this->profile->userinfo[field7]'" menu="false" quality="high" width="435" height="270" name="mp3player" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" border="0"/> </div>';
}
}

I've tried everything, anyone got any suggestions?

Darkwaltz4
10 Sep 2008, 07:05
heh, what would be stellar is a tutorial on creating your own fancy tab thing on other pages :p

jgeorge123
22 Sep 2008, 22:31
Hi there and i am trying to, i am not that good at describing the code but what i am trying acheive is that - i need to get some data from a the database and show in one of the block. Have a look at my code

$blocklist = array_merge($blocklist, array(
'games' => array(
'class' => 'games',
'title' => 'gamess',
'hook_location' => 'profile_left_last'
)
));

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
global $vbulletin;
class vB_ProfileBlock_games extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_games';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['games'] != '');
}

function prepare_output($id = '', $options = array())
{
function sql_most_downloaded ($limit)
{
global $vbulletin, $vbphrase;
$sql = $db->query
(
'SELECT * FROM xxx Where xxx = 'xxx'
GROUP BY xxx
ORDER BY xxx DESC
LIMIT x,x'
);
while ($games = $db->fetch_array($sql))
{
$out.= '<li><a href=\"../games/gamess/show/' . $games[ID] . '\" title=\"' . $games[file_title] . '\">' . $games[file_title] . ' [ ' . $games[total_downloads] . ' ]</a></li>';
}
}

$this->block_data['games'] = $out;
}
}

This selection of data is not based on the vbulletin so i think i can't use this->something->something

Has anyone have any suggestion

CypherSTL
29 Sep 2008, 22:15
Is anyone else having the problem of custom profile tabs not parsing BB Code?

It displays normal HTML correctly, but not BBCode.

jerx
27 Oct 2008, 04:26
I am trying to output pictures from coppermine gallery in a tab. There is a script for coppermine gallery called cpmfetch, which allows to display any picture of your coppermine gallery on external pages. All you need to do is put this into your php page:

<?php
require_once "./coppermine_gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./coppermine_gallery/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_viewLastAddedMedia(1,1,$options);
$objCpm->cpm_close();
?>

This will add the following code to that page location, which represents the last picture added to your coppermine gallery:

<table >

<tr>

<td><a href='http://your_domain.com/coppermine_gallery/thumbnails.php?album=14' ><img src="http://your_domain.com/coppermine_gallery/albums_directory/categoryname/picture_name.jpg" /></a></td>

</tr>


</table>

When I add the following code for my profile tab, that picture will be shown at the very beginning of the profile page - even before doctype, header and body tags.

$blocklist = array_merge($blocklist, array(
'copperminegallery' => array(
'class' => 'CoppermineGallery',
'title' => 'Last Added Pic',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_CoppermineGallery extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_copperminegallery';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['copperminegallery'] != '');
}

function prepare_output($id = '', $options = array())
{
include "./coppermine_gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./coppermine_gallery/cpmfetch/cpmfetch_config.php");
$this->block_data['copperminegallery'] = $objCpm->cpm_viewLastAddedMedia(1,1,$options);
}
}

When I add the resulting html code manually into the block it works fine:

$blocklist = array_merge($blocklist, array(
'copperminegallery' => array(
'class' => 'CoppermineGallery',
'title' => 'My Favs',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_CoppermineGallery extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_copperminegallery';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['copperminegallery'] != '');
}

function prepare_output($id = '', $options = array())
{
include "./gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
$this->block_data['copperminegallery'] = '<table >

<tr>

<td><a href=\'http://your_domain.com/coppermine_gallery/thumbnails.php?album=14\' ><img src="http://your_domain.com/coppermine_gallery/albums_directory/categoryname/picture_name.jpg" /></a></td>

</tr>


</table>
';
}
}

I had to put a backslash in front of ' to avoid the following error. But I don' t think that this is the problem, because there is no error with the real code.

Parse error: syntax error, unexpected T_STRING in /path/to/your/web/root/member.php(454) : eval()'d code on line 250

Does anyone know how to correct the display problem?

Thank you!

Wordplay
17 Nov 2008, 10:16
great! thanks a lot!

is there a way to have a preview of the latest threads and posts made by a user the way they have it on ipb in those tabs:
http://forums.invisionpower.com/index.php?showuser=75430

i actually requested that as a mod:
http://www.vbulletin.org/forum/showthread.php?t=196487

Bilderback
18 Nov 2008, 22:02
Great Article.
'hook_location' => 'profile_left_last'
Does anyone know how to provide the hook location when defined by the admincp?
My product has setting options like seen below:

<setting varname="custom_hook_location" displayorder="20">
<datatype>free</datatype>
<optioncode><![CDATA[select:piped
0|None
1|$template_hook[profile_left_first]
2|$template_hook[profile_left_last]
]]></optioncode>
<defaultvalue>0</defaultvalue>
</setting>


I am trying to display the block from whichever is chosen in admincp.
Have tried the following with no luck-
custom_hook_location
$vbulletin->options['custom_hook_location']

Thanks

fabs_pim
22 Nov 2008, 12:22
How do I display a list which i want to get out of an mysql database in such a profile tab?

Lynne
22 Nov 2008, 16:45
How do I display a list which i want to get out of an mysql database in such a profile tab?
You'll need to add your query into the plugin and then spit the results out into "$this->block_data['mymodification']"

DragonBlade
25 Jan 2009, 07:37
Hey, I'm trying to test this out and see if I can make something cool for my members, but I've noticed something a bit weird...

For the template, I've got the following code:<if condition="$vbulletin->userinfo['userid'] == 15010">
<div class="alt1 block_row">
<ul class="list_no_decoration">
$block_data[animelist]
</ul>
</div>
</if>
The conditional is there because, as I said, I'm testing it out and don't want all my members to see it yet, just me. However, after not getting it to display and a bit of tinkering around, I've found out that the $vbulletin object does not exist as far as the template is concerned. I've tried these variations to be sure:<if condition="$vbulletin->userinfo['userid'] == 15010">
<if condition="$vbulletin->userinfo['userid']">
<if condition="$vbulletin->userinfo">
<if condition="$vbulletin">
<if condition="1">The last one DID work, of course.

How would I make it so that the $vbulletin object IS recognized?




EDIT: BTW, I did "solve" it simply by putting the plugin itself in some "IF" brackets, but still for curiosity's sake, let's say for some reason I wanted to use the $vbulletin object in the tab (maybe I wanted to make a Tab with the User's name or something equally silly).

Lynne
25 Jan 2009, 17:19
Make $vbulletin global in the plugin.

Cledus James
03 Feb 2009, 14:53
Ok, this might have been answered before, but it seems I'm doing something wrong. I'm trying to add a new tab and display a custom profile field (field24) in it. Here's my plugin code:

$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'MyModification',
'title' => 'My Modification',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_mymodification';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['mymodification'] != '');
}

function prepare_output($id = '', $options = array())
{

$this->block_data['mymodification'] = $this->profile->userinfo['field24'] : "Stuff: $this->profile->userinfo['field24']" ? "Nothing to see here";
}
}
}

But when I add this I get an error on the website page:

Parse error: parse error, unexpected ':' in /home/url/forums/member.php(464) : eval()'d code on line 26

Fatal error: Cannot instantiate non-existent class: vb_profileblock_myawards in /home/url/forums/includes/class_profileblock.php on line 64

When I ad just the original plugin code I don't get the error, but as soon as I try and replace the $this code it gives me the error. Wondering if anyone could be of any help. I'm a vBulletin newb. What am I doing wrong? Thanks.

Dinatius
05 Feb 2009, 20:32
Cledus: The ?: is in the wrong order. It should be:

$this->block_data['mymodification'] = $this->profile->userinfo['field24'] ? "Stuff: $this->profile->userinfo['field24']" : "Nothing to see here";



On another topic, for anyone interested, and to get some feedback on whether this is done properly:

I wanted to get mysql data on my new tab, and $db and $vbulletin->db didn't work - they aren't around when this code gets called. In the class_profileblock.php file, when it's building the static blocks such as user statistics and buddy list, it uses this:
$this->registry->db
It gets me the info, so it works, but is there a preferable way to do it?

Edit: $this->registry seems to be the same as $vbulletin elsewhere...

Cledus James
06 Feb 2009, 14:21
Cledus: The ?: is in the wrong order. It should be:

$this->block_data['mymodification'] = $this->profile->userinfo['field24'] ? "Stuff: $this->profile->userinfo['field24']" : "Nothing to see here";




Ok, I updated it and it did fix the error, but it still didn't display the field. It displayed:

Stuff: Object->userinfo['field24']

in the profile tab. What should I do to display the content of the my custom profile field 24.

So here's my plugin right now:

$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'MyModification',
'title' => 'My Modification',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_mymodification';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['mymodification'] != '');
}

function prepare_output($id = '', $options = array())
{

$this->block_data['mymodification'] = $this->profile->userinfo['field24'] ? "Stuff: $this->profile->userinfo['field24']" : "Nothing to see here";
}
}

By the way, thanks for the reply.

Lynne
06 Feb 2009, 15:01
Have you tried to see if your plugin is even working by doing something simple like:

$this->block_data['mymodification'] = 'This is a test';

OR, see if the profile field is even available there:
$this->block_data['mymodification'] = '$this->profile->userinfo['field24']';

Dinatius
06 Feb 2009, 17:19
Oops, wasn't looking at the rest of the code. Array values need to be appended, can't be parsed inside quotes like a normal $variable:
$this->block_data['mymodification'] = $this->profile->userinfo['field24'] ? "Stuff: ".$this->profile->userinfo['field24'] : "Nothing to see here";

Alternately, you can put that array value in a variable and put that in quotes, although I'm not sure what that would do to the ?: selector. If it works, it makes things easier to read... Example:
$field24=$this->profile->userinfo['field24'];
$this->block_data['mymodification'] = $field24 ? "Stuff: $field24" : "Nothing to see here";
I'm only intermediate at PHP, too, so I'm not sure how that would affect performance (also depends how heavily the page is used)

(p.s. If people prefer I don't answer questions here, I'll move to PM)

Cledus James
09 Feb 2009, 17:13
Sent you a PM. :)

Cledus James
14 Feb 2009, 05:57
Ok, can someone help me just a bit more. Probably just an easy fix.

Now I added the last code posted to my plugin and it worked. It displayed the data from my custom profile field 18. In my above thread I said it was userfield24 but I had it wrong, it's userfield18. Now here's my plugin code:


$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'MyModification',
'title' => 'My Modification',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_mymodification';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['mymodification'] != '');
}

function prepare_output($id = '', $options = array())
{

$this->block_data['mymodification'] = $this->profile->userinfo['field18'] ? "Stuff: ".$this->profile->userinfo['field18'] : "Nothing to see here";
}
}

Like I said works fine with one small problem. Now the data I have stored in userfield18 is a list of information, like:

1. List Item 1
2. List Item 2
3. List Item 3
4. List Item 4
etc.

Now when its displayed in the new tab it all comes out on the same line like:

1. List Item 1 2. List Item 2 3. List Item 3 4. List Item 4

My question is, is there any way I can get it to be displayed in a list format? Like creating a new line for every list object? I tried adding a BR command in the field input itself without any luck. Anyone know how I can get it displayed like the way I input it into the field?

Thank you for any help anyone may offer.

--------------- Added 1234633359 at 1234633359 ---------------

Can anyone help?

Lynne
14 Feb 2009, 17:21
I'm not sure, but I would take a look at exactly what is in that field and see what separates the items and perhaps do a search/replace on the separator with a <br />

Cledus James
15 Feb 2009, 02:10
I'm not sure, but I would take a look at exactly what is in that field and see what separates the items and perhaps do a search/replace on the separator with a <br />

Basically its just a list of info that is manually entered by admins into a custom field via admin cp. We have a ranking system of 1-22 on the website. The list just basically lets the users know how that got to what rank and what they've gotten credit for towards rank.

Anyway here's the url of my site profiles:

My Profile (http://www.sik-clan.net/forums/member.php?u=1) - Now what I'm trying to do is display that information in the Rank Information module on the right side under the Mini Stats into a new profile tab. I made the plugin active again so you can see the output under the My Modification tab. Basically want the rank info from the module inside the new tab in a list format. I'll rename the new tab and remove the info from th emodule when I get it working properly.

If for some reason you can not see the info I'm talking about on my site here's an example of some information (as listed in the custom field in the admin cp) thats in my custom field that I want displayed in list format.

1. Website Owner
2. 6 month Member
3. 1 year Member
4. 100 Website Posts
5. 250 Website Posts
6. 500 Website Posts
7. 1000 Website Posts
8. Website staff
9. Clan Recruiting
10. Gears of War Roster
11. Rainbow Six Vegas Roster
12. Battlefield: Bad Company Roster
13. Call of Duty 4 Roster
14. Ghost Recon 2 Roster
15. Grand Theft Auto 4 Roster
16. Rainbow Six Vegas 2 Roster
17. Rock Band 2 Roster
18. Gears of War 2 Roster
19. Call of Duty 5 Roster
20. 3 Month Member
21. 50 Website Posts
22. 750 Website Posts

Again it comes out as:

Stuff: 1. Website Owner 2. 6 month Member 3. 1 year Member 4. 100 Website Posts 5. 250 Website Posts 6. 500 Website Posts 7. 1000 Website Posts 8. Website staff 9. Clan Recruiting 10. Gears of War Roster 11. Rainbow Six Vegas Roster 12. Battlefield: Bad Company Roster 13. Call of Duty 4 Roster 14. Ghost Recon 2 Roster 15. Grand Theft Auto 4 Roster 16. Rainbow Six Vegas 2 Roster 17. Rock Band 2 Roster 18. Gears of War 2 Roster 19. Call of Duty 5 Roster 20. 3 Month Member 21. 50 Website Posts 22. 750 Website Posts

in the new profile tab.


Hope this helps you help me, lol. Thanks for your time.

Cledus James
16 Feb 2009, 16:59
Thought I would give this a bump in hopes of finding a solution. Thanks.

Lynne
16 Feb 2009, 17:22
Your spitting it out into an unordered list, <ul>. You will need to explode the ranks and then put an <li> in front of each one. What exactly are you doing with the rank list? Are you exploding it after you get it? Post the code you use to deal with it and spit it out.

Cledus James
16 Feb 2009, 18:00
lol, Im not that good. Basically Im just manually entering that list of items info into a custom field created in the admin cp under each user and then just calling that field to the tab. Honestly, I have no idea what you're talking about with the "exploding and spit out". There is no code I'm dealing with besides the code in the new template and the pluggin.

Oddly, Right now I also have the custom field in a profile module on the right and it displays as it was typed in the admin cp > users, in a list format.

Here's a link (http://www.sik-clan.net/forums/member.php?u=1&styleid=41)to my profile on the site. That <br /> was entered in the admin cp > user > custom field blank.

Could there be something I could do in the memberinfo_block_mymodification template code:

<div class="alt1 block_row">
<ul class="list_no_decoration">
$block_data[mymodification]
</ul>
</div>

And like I said before, thank you for all the help, I know it can be frustrating dealing with someone that doesn't know as much. Be nice to get this finally completed, it's really the last thing I got left to do.

Lynne
16 Feb 2009, 19:04
The thing is, all you have is a bunch of text. If you want it to display a certain way, then you need to have some html in there. You can't just write:
1. Website Owner 2. 6 month Member 3. 1 year Member
and have it show up as:
1. Website Owner
2. 6 month Member
3. 1 year Member

You need to write:
</li>1. Website Owner <li>2. 6 month Member <li>3. 1 year Member

and acutally, more correctly, change the <ul>s in the template to <ol>s for an ordered list instead of an unordered list and then change the list to:
</li>Website Owner <li>6 month Member <li>1 year Member

PaulSonny
02 Mar 2009, 10:35
Hello,

Is there a way to link to the profile and load a particular tab?

Regards, Paul.

ragtek
02 Mar 2009, 10:56
yes add &tab=tabid to the url

example: http://vbulletin-germany.org/member.php?u=12&tab=releases

PaulSonny
05 Mar 2009, 08:22
Thanks very much tagtek.

Kind Regards, Paul.

EagleNick
13 Apr 2009, 02:38
Great article!

I'm not sure how to display the tab for only certain usergroups though. Do I use regular template conditionals? Or a PHP conditional? And where do I put it?

Thanks.

Merriweather
16 Apr 2009, 04:30
If I set up a tab to show some custom profile fields, is there a way to let each user define who can see the information on that tab (i.e. Everyone, Registered Users, Contacts, Friends)?

Wired1
23 Apr 2009, 16:49
If I set up a tab to show some custom profile fields, is there a way to let each user define who can see the information on that tab (i.e. Everyone, Registered Users, Contacts, Friends)?

The "profile.php?do=privacy" page uses the modifyprofileprivacy template. Within it the actual list of items is contained within the $profileprivacybits variable.

A hook needs to be within a particular function to enable privacy settings for custom tabs. Looks like it was already requested in January:
http://www.vbulletin.com/forum/showthread.php?p=1673419&highlight=privacy#post1673419

A Hook in profile.php at the end of combined action privacy/doprivacy is needed to handle privacy for custom blocks.

http://www.vbulletin.com/forum/showthread.php?t=302214

Looks like privacy settings for categories worked in 3.8.0, but was broken in 3.8.1, and fixed in 3.8.2. Here's hoping they did a similar fix for custom blocks in total in 3.8.2 (gotta remember to download it lol).

Chadi
24 Apr 2009, 03:47
NOTE: I'm creating a new mode for Shelfari called "My Shelfari Bookshelf". I reserve this idea, so please don't steal my idea ;)

Having a hard time applying this for a new tab called "Shelfari" (shelfari.com)

The template is:

memberinfo_block_shelfari

<div class="alt1 block_row">
<ul class="list_no_decoration">
$block_data[shelfari]
</ul>
</div>The plugin is:

$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'Shelfari',
'title' => 'My Shelfari Bookshelf',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_Shelfari extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_shelfari';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['shelfari'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['shelfari'] = '<embed width="500" height="500" src="http://www.shelfari.com/ws/shelf.swf" wmode="transparent" FlashVars="UserName=chadi&ShelfType=list&verE=s1.5&ListType=isowned&booksize=large&Alpha=0&BGColor=FFFFFF"></embed>';
}
}Note, "chadi" in that Shelfari embed code I pasted at the end of the plugin is my actual Shelfari username. However, I created a user profile field called "My Shelfari Bookshelf", which is field44.

I tried replacing chadi with $userinfo[field44] and it did not pull correctly.

What is the actual proper replacement code to pull whatever content from the user's field44 profile field to replace my actual username?

Can some also please explain how to properly create a plugin file for this, so I can share it as a mod?

Lynne
24 Apr 2009, 03:55
What is the actual proper replacement code to pull whatever content from the user's field44 profile field to replace my actual username?
Try $this->profile->userinfo['field44']

Chadi
24 Apr 2009, 04:02
Thanks, but the tab doesn't show up now.

$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'Shelfari',
'title' => 'My Shelfari Bookshelf',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_Shelfari extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_shelfari';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['shelfari'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['shelfari'] = '<embed width="700" height="700" src="http://www.shelfari.com/ws/shelf.swf" wmode="transparent" FlashVars="UserName=$this->profile->userinfo['field44']&ShelfType=list&verE=s1.5&ListType=isowned&booksize=large&AmazonAssociate=taljes-20&Alpha=0&BGColor=FFFFFF"></embed>';
}
}

Lynne
24 Apr 2009, 04:08
Try assigning it to a variable and then use the variable in that line of code:

$var = $this->profile->userinfo['field44'];
$this->block_data['shelfari'] = '..... UserName=' . $var . '&Shel....';

Something like that. You'll probably have to play with it a bit.

Chadi
24 Apr 2009, 04:15
Sorry, but I really don't know what you're telling me here. I'm not a coder :)

Can you give me a hint by pasting what the entire plugin code should look like? It'll be easier for me to dissect it carefully from there.

--------------- Added 1240546636 at 1240546636 ---------------

Ok, I tried this:

$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'Shelfari',
'title' => 'My Shelfari Bookshelf',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_Shelfari extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_shelfari';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['shelfari'] != '');
}

function prepare_output($id = '', $options = array())
{
$var = $this->profile->userinfo['field44'];
$this->block_data['shelfari'] = '<embed width="700" height="700" src="http://www.shelfari.com/ws/shelf.swf" wmode="transparent" FlashVars="UserName' . $var . '&ShelfType=list&verE=s1.5&ListType=isowned&booksize=large&AmazonAssociate=taljes-20&Alpha=0&BGColor=FFFFFF"></embed>';
}
}

now, the output works except one more problem:

The actual widget is giving an error stating that a username was not provided and must be provided.

--------------- Added 1240547063 at 1240547063 ---------------

Fixed. I had to had the = after UserName.

Thanks Lynne.

One quick question, I'd like to make an xml plugin file so people can install this as a product. Could I trouble you to explain how this can be done?

Lynne
24 Apr 2009, 15:16
One quick question, I'd like to make an xml plugin file so people can install this as a product. Could I trouble you to explain how this can be done?
Looks like you already figured that out since I saw you released your mod. :)

Chadi
24 Apr 2009, 15:33
Yes, and gave you and Wired1 credit for the help.

Thank you Lynne, appreciate it.

PS: would you like me to make you co-author of the mod? I'm honestly not sure how these things work on the forums. I've only started releasing mods a couple days ago. I'm not even a programmer.

Lynne
24 Apr 2009, 16:41
PS: would you like me to make you co-author of the mod? I'm honestly not sure how these things work on the forums. I've only started releasing mods a couple days ago. I'm not even a programmer.
No, no. I am here just to help out. I really don't know what the co-author thing is for, but just giving you a couple pointers doesn't make me a co-author. You did all the hard work.

H3C x Nevz
29 Apr 2009, 22:52
Okay, I've installed this properly, and I need a somewhat specific request:

-- Search for all threads started by user, in forumID 12 and all child boards -- [USERNAME]'s Posted Content -- End Link --

Sorry, I really don't know a lot about using variables...

harmor19
07 May 2009, 08:42
If you want to know how to pull HTML from a template rather than writing the HTML in the plugin take a look at what I've wrote.
function prepare_output($id = '', $options = array())
{
global $vbulletin, $db;

$query = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "mkwtracktimes WHERE userid = '".$vbulletin->userinfo['userid']."'");
while($mkw = $db->fetch_array($query))
{
eval('$data .= "' . fetch_template('mkw_profilebit') . '";');
}

$this->block_data['mkwttrecords'] = $data;
}

harmor19
08 May 2009, 14:35
I'm not sure as I haven't tried but the code below might work if you don't want to loop data.

eval($this->block_data['mkwttrecords'] .' .= "' . fetch_template('mkw_profilebit') . '";');

edytwinky
01 Jul 2009, 04:20
I'm trying to get this information to show but for some reason it keeps bringing errors. Any ideas?

Currently my plugin is the default:

$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'MyModification',
'title' => 'My Teams',
'hook_location' => 'profile_right_last'
)
));

class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_mymodification';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['mymodification'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['mymodification'] ='Coming Soon';

}


}

And i'm trying to get the following code in:

<if condition="!empty($post[nbateam])">
<div>
$vbphrase[my_nbateam]: <img src="$vboptions[bburl]/images/nba/$post[nbateam].gif" border="0" />
</div>
</if>



I put the new code in the 'coming soon' section and all it showed in the new tab was the text $vbphrase[my_nbateam]:
It did not show the image whatsoever.

--------------- Added 1246493739 at 1246493739 ---------------

I've been toying around with every single combination of codes and it keeps only bringing up the text of the coding or error message.

Any assistance would be greatly appreciated.

euantor
19 Aug 2009, 09:03
Does this work with VBulletin 3.8.4? I've tried it, but I can't get the tab I'm trying to add to display.

ragtek
19 Aug 2009, 15:19
Yes it should work, nothing changed here.

What's the code you're using?

euantor
20 Aug 2009, 08:25
The code in the first two boxes. I believe I've done it all correctly, but it doesn't work.

KW802
26 Aug 2009, 23:38
With the hook locations we can specify relative positions (eg: first on the left, last on the right, etc.) but is it possible to specify a specific location, as in the second position from the left?

Thanks :)

Lynne
26 Aug 2009, 23:47
No, not with default vbulletin. You may modify the template and add another template_hook to use in the location you want. (I think there is even an article on how to do this.)

krike
08 Sep 2009, 09:20
just thought I would share with the people who are looking for help.

my vB version is 3.8.1

I needed to query a table I created myself to display all the tutorials of that specific user.
here is the code I used and it works like a charm


function prepare_output($id = '', $options = array())
{
$sql = mysql_query("SELECT * FROM tutorials WHERE approved = 1 AND user_id=".$this->profile->userinfo[userid]."");
$test = "<ul>";
while($result = mysql_fetch_array($sql))
{
$test .= "<li> <img src='http://cmstutorials.org/".$result['tutorial_thumb']."' width='50' height='50' alt='' />
<a href='http://cmstutorials.org/tutorial/".$result['tutorial_id']."' target='_blank'>".$result['title']."</a></li>
";
}
$test .= "</ul>";
$this->block_data['mymodification'] = $test;
}


--------------- Added 1252407273 at 1252407273 ---------------

how do you call a specific tab with a url?

http://cmstutorials.org/forums/member.php?u=1#tabname ????

--------------- Added 1252407322 at 1252407322 ---------------

ok I found it http://cmstutorials.org/forums/member.php?u=1&tab=favorite

For About Me: ?tab=aboutme
For Contacts: ?tab=contact
For Friends: ?tab=friends
For Statistics: ?tab=stats

KW802
08 Sep 2009, 15:31
No, not with default vbulletin. You may modify the template and add another template_hook to use in the location you want. (I think there is even an article on how to do this.)Lynne, I missed your response earlier, just saw it now after the newest post. :o

Thanks for the info. :) For now I'll go with the relative positions since one of our goals with the project is to make it as template edit free as possible for the site admin'.

reddyink
11 Nov 2009, 16:16
I am trying tocreate a Tab where it can list specific user Threads in different forums like the profile page on vb.org where it pulls users threads from MODs forum, Templates, Styles forum.

example: I want this users threads from forum ids 2, 4, 6 etc

towards the bottom of
http://www.vbulletin.org/forum/member.php?u=925

Appreciate your help! I am new to programming.

ageurtse
26 Dec 2009, 05:20
this works also in vb4.0

ragtek
26 Dec 2009, 07:34
Not true;)

Plugin=> yes
Template not, have to be changed to the vB4 Syntax;)

ageurtse
27 Dec 2009, 12:08
what is wrong with the template.
on my test site it run's almost oke.

only when i call te tab by itself http://xxx/forums/member.php?3-Peter&tab=mymodification&page=10 my custom code is way below everything what is wrong.
When i hit the mymodification tab al is displayed normal.

--------------- Added 1261950936 at 1261950936 ---------------

is there also a way to call a php page that should display his content in this newly created tab ?

Warlord
04 Jan 2010, 18:37
just thought I would share with the people who are looking for help.

my vB version is 3.8.1

I needed to query a table I created myself to display all the tutorials of that specific user.
here is the code I used and it works like a charm


function prepare_output($id = '', $options = array())
{
$sql = mysql_query("SELECT * FROM tutorials WHERE approved = 1 AND user_id=".$this->profile->userinfo[userid]."");
$test = "<ul>";
while($result = mysql_fetch_array($sql))
{
$test .= "<li> <img src='http://cmstutorials.org/".$result['tutorial_thumb']."' width='50' height='50' alt='' />
<a href='http://cmstutorials.org/tutorial/".$result['tutorial_id']."' target='_blank'>".$result['title']."</a></li>
";
}
$test .= "</ul>";
$this->block_data['mymodification'] = $test;
}


--------------- Added 1252407273 at 1252407273 ---------------

how do you call a specific tab with a url?

http://cmstutorials.org/forums/member.php?u=1#tabname ????

--------------- Added 1252407322 at 1252407322 ---------------

ok I found it http://cmstutorials.org/forums/member.php?u=1&tab=favorite

Is tutorial_thumb a column in one of you sql tables? I'm trying to do something similar but it's really kicking my butt.

I have a form users submit their resume's on. It saves it to the database in the table formresults. The information I want to display on the profile is located in a column labeled output in the formresults table.

Below is the code I'm using in the member_build_blocks_start hook location.


$blocklist = array_merge($blocklist, array(
'resume' => array(
'class' => 'Resume',
'title' => 'Resume',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_resume extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_resume';
function confirm_empty_wrap()
{
return false;
}
function confirm_display()
{
return ($this->block_data['resume'] != '');
}
function prepare_output($id = '', $options = array())
{
global $db;
$sql= $db->query_read("SELECT output FROM " . TABLE_PREFIX . "formresults WHERE userid = '.$this->profile->userinfo[userid].' AND title = 'Resume' ");
$test = "<div>";
while($result = mysql_fetch_array($sql))
{
$test .= "'.$result['output'].'"
";
}
$test .= "</div>";


$this->block_data['resume'] = $test;
}
}

I think the code in bolded red is the part I'm getting lost on?

I get this error when displaying the memberinfo profile page.


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/righscom/public_html/addons/projectfanboy/vb/member.php(463) : eval()'d code on line 249

Warlord
05 Jan 2010, 20:57
Anyone?

Lynne
05 Jan 2010, 21:45
Anyone?
Too many quotes in this 'line':
$test .= "'.$result['output'].'"
";

Warlord
06 Jan 2010, 00:51
Too many quotes in this 'line':
$test .= "'.$result['output'].'"
";



I see what you're talking about, thanks for that. While there was some syntax error there, unfortunately it didn't solve my problem. I changed it to this:

$test .= " .$result['output']. ";

I'm still getting the same error though:


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/righscom/public_html/addons/projectfanboy/vb/member.php(463) : eval()'d code on line 249

I thought maybe I was just calling the column in the table contained in the array incorrectly, which gave me the error, but you didn't mention that, so can I assume that if the column in the table is called output that this would be the correct way to retrieve that data?

$result['output']

dartho
06 Jan 2010, 00:58
shouldn;'t it just be :
$test .= $result['output'];
?

of if you wanted a space after each result

$test .= $result['output'] . " ";

Warlord
06 Jan 2010, 01:11
shouldn;'t it just be :
$test .= $result['output'];


Thank you, that got rid of the annoying error. I really could've sworn I had tried that before but apparently not. :confused:

The Resume tab shows up now, unfortunately there is still no data in it. Could it be the type of data that's in there (a mixture of html and php variables) causing it to not show up?

--------------- Added 1262744048 at 1262744048 ---------------

Hmmm... I guess not. I changed the data in there to be just the string "This is only a test" and still nothing shows up. :confused:

--------------- Added 1262744441 at 1262744441 ---------------

HOLY CRAP! I'm almost there! I've been working on this for like a week and I was almost ready to give up but now I'm ALMOST THERE! :D :D :D

The problem was the SQL query was returning no results because apparently this line of code doesn't work the way I thought it did.

.$this->profile->userinfo[userid].

I changed that to my userid and it worked! Now I just need to figure out the right way to call for the user profile id! :D Thanks everyone!

--------------- Added 1262745188 at 1262745188 ---------------

HOLY CRAP! I'm almost there! I've been working on this for like a week and I was almost ready to give up but now I'm ALMOST THERE! :D :D :D

The problem was the SQL query was returning no results because apparently this line of code doesn't work the way I thought it did.

.$this->profile->userinfo[userid].

I changed that to my userid and it worked! Now I just need to figure out the right way to call for the user profile id! :D Thanks everyone!

Okay, apparently it does work the way I thought it did, I just had removed the extra " because I thought it was wrong. I still don't quite understand why it should be there but it seems to work now! Woohoo! :D:D:D

For anyone who's interested in what the code looked like that finally ended up working, here it is. :D

$blocklist = array_merge($blocklist, array(
'resume' => array(
'class' => 'Resume',
'title' => 'Resume',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_resume extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_resume';
function confirm_empty_wrap()
{
return false;
}
function confirm_display()
{
return ($this->block_data['resume'] != '');
}
function prepare_output($id = '', $options = array())
{
global $db;
$sql= $db->query_read("SELECT * FROM " . TABLE_PREFIX . "formresults WHERE title = 'Resume' AND userid=".$this->profile->userinfo[userid]."");

$test = "<div>";
while($result = mysql_fetch_array($sql))
{
$test .= $result['output'];
}
$test .= "</div>";


$this->block_data['resume'] = $test;
}
}

Warlord
14 Jan 2010, 00:40
Is there something else you have to do to add more pages? When I repeat the steps I did to create the first tab the new tab I create replaces the first tab I created instead of appearing next to it. :confused:

ragtek
14 Jan 2010, 04:32
They must have unique names/classnames.

Maybe you took the same?

gonedigital
18 Feb 2010, 04:25
this the same for VB 3.8.4???

because I don't see

member_build_blocks_start in the templates in my Style Manager where it says to

"Add a new plugin to the member_build_blocks_start hook with the following PHP code:"

muratcan25
16 Dec 2010, 08:20
3.8.6 Pl 1 woww :)
Thank You man !

Bobred
06 Feb 2011, 16:48
So I've (mostly) got this working for vB 4.1.1, but there's a few problems:

1: The tab's styling is a little messed up (see picture)

2: The contents of the block appear at the bottom of the screen upon loading the member's profile page.

Other than changing the hook_location value, it's pretty much a copy of this how-to. I've seen a how-to for adding tabs in 4.0.8, but it looks really messy compared to this, so I'd really rather get this working. Anyone have any ideas?


[edit]

So I've got the answer to part 2:
There is a function called wrap() that you have can override. This function takes the html and wraps it in a div, but the class of this div is wrong.
So we need to fix this.
Put this code inside the class declaration for vB_ProfileBlock_MyModification (or whatever you're calling it):

function wrap($title, $id='', $html=''){
$wrap = "<div id=\"view-".$id."\" class=\"view_section\">".$html."</div>";
return $wrap;
}

JohorBahru
30 Aug 2011, 16:26
how can i adjust the width of the tabs so user can see all tab in one glance.

132480

eg, make a proper adjustment to the profile tabs so the last 2 tabs can be display without a drop down bar needed

thank you!

Lynne
30 Aug 2011, 17:16
how can i adjust the width of the tabs so user can see all tab in one glance.

132480

eg, make a proper adjustment to the profile tabs so the last 2 tabs can be display without a drop down bar needed

thank you!
I believe you would need to manually edit the css file /clientscript/vbulletin_tabctrl.css And don't forget that even if you get it to fit on *your* browser, your users will not necessarily have their browser width the same and so the tabs may still be displayed in the dropdown.

Revenga
09 Jul 2013, 16:45
How do I make the new tab and it's contents only viewable by Administrators of the forum?

Sorry to bump a 2 year old thread.

- Revenga

Lynne
10 Jul 2013, 03:17
Try a Search This Article for "is_member_of" because that has probably already been covered.

devil78
28 Jul 2018, 13:22
Username Management Addon - History in Profile

https://www.vbulletin.org/forum/showthread.php?t=101411

Addon working, but

<div class="alt1 block_row">
<ul class="list_no_decoration">
$block_data[usernamehistory]
</ul>
</div>


member_build_blocks_start


$blocklist = array_merge($blocklist, array(
'usernamehistory' => array(
'class' => 'usernamehistory',
'title' => 'Username History',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_usernamehistory extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_usernamehistory';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['usernamehistory'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['usernamehistory'] = '$mh_unm_uph_history';
}
}


https://www.vbulletin.org/forum/external/2018/07/2.jpg

Profile tabs does not show plugin help me:(