PDA

View Full Version : Side Blocks


Mastar
01-21-2011, 12:27 AM
How can I get in the sideblock using something like:

{vb:raw post.username}

Actually I would like to get the forum leaders avatar, username and a profile field to appear in the sideblock!

Lynne
01-21-2011, 01:09 AM
You would need to write a php block and put in the code to output what you want.

Mastar
01-21-2011, 02:42 AM
Do you know where can I find a sample or something I can reference from?

Lynne
01-21-2011, 02:46 AM
There are a few blocks modifications in the mods forums. So, go download a couple of those and check out the code.

Mastar
01-21-2011, 07:07 AM
I've searched but didn't locate any, can you point me to one plz!

Lynne
01-21-2011, 02:35 PM
There are several.
https://vborg.vbsupport.ru/forumdisplay.php?f=246&page=1&pp=25&threadprefix=vBulletin+Forum+Sideblocks&sort=lastpost&order=desc&daysprune=-1
https://vborg.vbsupport.ru/forumdisplay.php?f=245&page=1&pp=25&threadprefix=vBulletin+Forum+Sideblocks&sort=lastpost&order=desc&daysprune=-1

Mastar
01-21-2011, 04:51 PM
I know how to add the content in the sideblocks but I don't know how to get the vbulletin var to get the content there, if I just put {vb:raw post.username} to show the person's username it show just {vb:raw post.username} it doesn't render the actual username.

Lynne
01-21-2011, 05:38 PM
First off, you need to define the variable $post to use it in the block.

But, besides that, variables are not html. You would need to create a PHP block to output a variable and there is an example there on how to do output in a php block:
$my_output = 'Hello, world.';
return $my_output;

An example using a variable:
$my_output = '<p>Hello '. vB::$vbulletin->userinfo[username].'</p>';
return $my_output;

Mastar
01-21-2011, 05:49 PM
Do I need to put anything for the template used?

I tried that code and even the sample code that is there in the ACP, nothing in the template used area and the block didn't appear!

Thanks!

Lynne
01-21-2011, 06:50 PM
You need a template for it to use. Just leave that as default block_html

http://www.vbulletin.com/forum/showthread.php/371709-Creating-an-HTML-or-PHP-Block?p=2105310#post2105310

Mastar
01-21-2011, 09:34 PM
I've copy and paste what you did there leaving the template block.html there set the type to php and nothing is coming up on the side. I'm thinking its vb 4.1.1 issues?

Lynne
01-21-2011, 09:59 PM
No, it isn't a vb 4.1.1 issue because I tried that exact code I posted in a php block.

Please post your *exact* code and all the exact settings on the block page that you are creating.

Also, do you have blocks on in the first place? vboptions > forum sidebar > set those to what you want

Mastar
01-22-2011, 12:27 AM
Title: TEST PHP
Content Type: PHP
Content:
$my_output = "Hello ". vB::$vbulletin->userinfo['username'];
$my_output .= "<br />Your last post was in this thread:";
$myquery = vB::$db->query_first("
SELECT
post.threadid, thread.title
FROM " . TABLE_PREFIX . "post AS post
INNER JOIN " . TABLE_PREFIX . "thread AS thread ON (thread.threadid = post.threadid)
WHERE post.userid = ".vB::$vbulletin->userinfo['userid']. "
ORDER BY post.dateline DESC
");
$threadurl = '<a href="' . fetch_seo_url(thread, $myquery) . '" title="'. $myquery[title] .'">'. $myquery[title] .'</a>';
$my_output .= "<br />" . $threadurl;
return $my_output;


Template to Use: block.html

Lynne
01-22-2011, 12:51 AM
The template is not called block.html. It is block_html (as I said a few posts above and in the article I linked you to).

It works just fine for me if I have the correct template in that field.

Mastar
01-22-2011, 07:03 AM
Thanks that was it!!!!

Appreciate it!

Special Pages
01-22-2011, 12:28 PM
Haha thanks so much Lynne. I really appreciate your hard work! Please DO NOT delete this thread! I need it. :) lol thanks!