Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-14-2009, 10:08 PM
acanuck acanuck is offline
 
Join Date: Feb 2009
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 12-14-2009, 10:21 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 12-14-2009, 10:58 PM
acanuck acanuck is offline
 
Join Date: Feb 2009
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
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:
Reply With Quote
  #4  
Old 12-15-2009, 01:43 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.)
Reply With Quote
  #5  
Old 12-21-2009, 12:39 PM
derfelix derfelix is offline
 
Join Date: Nov 2001
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 12-21-2009, 02:08 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!'
Reply With Quote
  #7  
Old 12-21-2009, 02:29 PM
derfelix derfelix is offline
 
Join Date: Nov 2001
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

F.
Reply With Quote
  #8  
Old 12-21-2009, 02:45 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 12-21-2009, 03:37 PM
derfelix derfelix is offline
 
Join Date: Nov 2001
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
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
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:11 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.07152 seconds
  • Memory Usage 2,243KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_html
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete