PDA

View Full Version : Using the new PHP Block


acanuck
12-14-2009, 10:08 PM
I'm trying to use the new vb4 sidebar php block.

I enter something very simple like
print 'test';'

but it prints at the very top left of the page instead of inside the block. Any idea what I'm doing wrong?

Also can I access vb variables and bbcode in the block?

Lynne
12-14-2009, 10:21 PM
Take a look at the template that is used to output the php block and you'll see exactly what it expects - it expects you to create a variable $output and it will output it in the block.

acanuck
12-14-2009, 10:58 PM
Take a look at the template that is used to output the php block and you'll see exactly what it expects - it expects you to create a variable $output and it will output it in the block.

Thanks for the reply Lynne :)

Stupid question... but which template do I need to look for? I'm not sure how to find the template :erm: :o :D

Lynne
12-15-2009, 01:43 AM
To find the template, do this - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around your part of the code. (Sometimes the template is the one mentioned at the very top of the page source.)

derfelix
12-21-2009, 12:39 PM
Well, maybe I am a little slow..
tried the same thing...
custom html/php block
template name: block_html

it expects the variable content
so i did a
$content='test';
and...
the block is there but empty... populated with the blocktitle only..
(its the default block title)
I even added a: global $content; :(

Any ideas?

thx in advance...

F.

Lynne
12-21-2009, 02:08 PM
I wish vb has called these different blocks something completely different.

- If using the php block on the CMS page, you need to set your output to the variable $output.
$output .= 'Hello World!';
- If using the php block on the forumhome page, you need to use return for your output.
return 'Hello World!';

derfelix
12-21-2009, 02:29 PM
Thank you lynne,
works perfectly as always...

To bad you cant use the template vars $content and $blockinfo["title"]
or return an array.

The advantage would have been to be able to phrase the title of the block for multilanguage purposes..

Example:
blocktitle: the newest 5 images.. (where 5 would be the amount of new images calculated in the php block..)
OR blocktitle depending on language...(for us multilanguage users)
As i run a chinese, german and english board, the titles are very important...

But anyway i hope i'll find a way...
I'm allready happy to see any content :p

F.

Lynne
12-21-2009, 02:45 PM
Put it as a Suggestion over on vb.com and then put it in the Bug Tracker with a link to the thread about it.

derfelix
12-21-2009, 03:37 PM
Put it as a Suggestion over on vb.com and then put it in the Bug Tracker with a link to the thread about it.
I asked about that... sometime in november..
answer: not planned for the moment...
BUT I think I found a way of doing it :cool:
In theory... but I'll run some tests tomorrow...

Simply.. As you can use your own template...
make a new one.. containing only:
<li>
{vb:raw content}
</li>
and then.. generate your own title and content.. and.. and.. in the sub template you use...

I guess they didnt plan it that way.. but it should be possible...

as I said.. i'm off now.. but i'll test tomorow..
F.