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 02-24-2012, 07:39 AM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Can I Output A PHP Widget In a HTML Widget or Allign PHP Output

Hi guys, I've got an existing PHP Direct Exec widget using the following code :-

PHP Code:
ob_start();
include(
"radio_stats_martin.php");
echo 
"<br />\n";
$output .= ob_get_contents();
ob_end_clean(); 
This is working fine.

How would I display the output of that same radio_stats_martin.php in a Static HTML widget ?

Thanks
B16MCC.
Reply With Quote
  #2  
Old 02-24-2012, 02:00 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't think you can. You can't run php as part of a static html widget. If the output never changes you could copy the output and paste it in an html widget. But if it's working the way it is, why would you want to change the widget type?
Reply With Quote
  #3  
Old 02-24-2012, 02:32 PM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK Thanks. The reason was to do with formatting the output. I'll expand on what I'm trying to do and perhaps approach it from a different angle.

I have this code in a PHP widget.

PHP Code:
ob_start();
include(
"radio_stats_martin.php");
echo 
"<br />\n";
$output .= ob_get_contents();
ob_end_clean();

ob_start();
include(
"radio_stats_alex.php");
echo 
"<br />\n";
$output .= ob_get_contents();
ob_end_clean(); 
As you can see, this is duplicate code but referring to 2 different php files.
The output is shown below.


The php files are checking the status of 2 different shoutcast servers and outputting to my widget based on wether the server is broadcasting or not, so this output is dynamic.

Basically I want to arrange the 2 outputs side by side rather than one below the other. The reason I asked about a HTML widget is because I could put the outputs into tables, or so I thought. As you've now confirmed I can't do that.

Any help is greatly appreciated.

Thanks for reading.
B
Attached Images
File Type: png screengrab.png (14.1 KB, 0 views)
Reply With Quote
  #4  
Old 02-24-2012, 02:45 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, OK. You can do that in a php widget. You can just do something like:

PHP Code:
ob_start(); 
include(
"radio_stats_martin.php"); 
$martin ob_get_contents(); 
ob_end_clean(); 

ob_start(); 
include(
"radio_stats_alex.php"); 
$alex ob_get_contents(); 
ob_end_clean();  

$output "<table><tr><td>$martin</td><td>$alex</td></tr></table>"

If you wanted you could use a template, maybe like this:

PHP Code:
ob_start(); 
include(
"radio_stats_martin.php"); 
$stats['martin'] = ob_get_contents(); 
ob_end_clean(); 

ob_start(); 
include(
"radio_stats_alex.php"); 
$stats['alex'] = ob_get_contents(); 
ob_end_clean();  

$templater vB_Template::create('radio_stats');
$templater->register('stats'$stats);
$output $templater->render(); 

Then create a radio_stats template with whatever html you want and put {vb:raw stats.martin} or {vb:raw stats.alex} wherever you want them.

BTW, I don't know why I used $martin and $alex in the first one but a $stats array in the second one - you could do it either way in either example).
Reply With Quote
  #5  
Old 02-24-2012, 02:55 PM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks a lot. Those options are really useful.. I'll work something out from your example.

--------------- Added [DATE]1330099902[/DATE] at [TIME]1330099902[/TIME] ---------------

Sorry to be a pain, I've looked at the template method but I'm a little confused.
Could you give a little more detail on how I create this please ?
I'm confused about wether the code goes in a php file or in the template ?

--------------- Added [DATE]1330102316[/DATE] at [TIME]1330102316[/TIME] ---------------

Nah, struggling coming up with the template method. I'm just posting again in hope that the thread will be highlighted again. Thanks.
Reply With Quote
  #6  
Old 02-24-2012, 05:42 PM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well eventually I got it looking how I want it. I've attached my code and a screen shot for anyone else it may help.

PHP Code:
ob_start();  
include(
"radio_stats_martin.php");  
$martin ob_get_contents();  
ob_end_clean();  

ob_start();  
include(
"radio_stats_alex.php");  
$alex ob_get_contents();  
ob_end_clean();   

$output "<center><table width='96%'><tr><td width='45%'><div class='cms_widget'>$martin</div></td><td width='10%'></td><td width='45%'><div class='cms_widget'>$alex</div></td></tr></table></center>"


Don't worry about the 'Current Song' text, that's actually a moving marquee. So that's why it looks a little odd on a screen grab.

Thanks so much for your help. I'm learning a lot here, Cheers.
Attached Images
File Type: png screengrab.png (19.8 KB, 0 views)
Reply With Quote
  #7  
Old 02-24-2012, 06:06 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for posting your result.

Yeah, unfortunately I usually miss it when the auto-merge kicks in so I missed your previous questions. But to answer, the template method should have worked by putting all the code I posted in a php widget and creating the template using the Style Manager.
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 05:39 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.04115 seconds
  • Memory Usage 2,258KB
  • Queries Executed 12 (?)
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
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (2)postbit_attachment
  • (7)postbit_onlinestatus
  • (7)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
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete