vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Using the new PHP Block (https://vborg.vbsupport.ru/showthread.php?t=230222)

acanuck 12-14-2009 10:08 PM

Using the new PHP Block
 
I'm trying to use the new vb4 sidebar php block.

I enter something very simple like
PHP Code:

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

Quote:

Originally Posted by Lynne (Post 1930821)
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.
PHP Code:

$output .= 'Hello World!'

- If using the php block on the forumhome page, you need to use return for your output.
PHP Code:

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

Quote:

Originally Posted by Lynne (Post 1934598)
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:
HTML Code:

<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.


All times are GMT. The time now is 10:03 AM.

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.01044 seconds
  • Memory Usage 1,733KB
  • 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
  • (1)bbcode_html_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_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