vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Converting vBulletin widget to WordPress (https://vborg.vbsupport.ru/showthread.php?t=282514)

ExoticAgenda 05-06-2012 12:10 PM

Converting vBulletin widget to WordPress
 
Hi, I have a snippet of code that I found and use as a widget to display the next 5 upcoming events in my calendar. I am looking to port this over to WordPress as that is now my homepage. The code is below. Any assistance would be greatly appreciated. Thanks


PHP Code:

ob_start(); 


//  %d 
$show_count 5

$query sprintf("SELECT * FROM ".TABLE_PREFIX."event WHERE visible = 1 AND (dateline_from > '%d' || (  dateline_from > '%d' AND dateline_to < '%d' )) ORDER BY dateline_from ASC LIMIT %d",TIMENOW,TIMENOW,TIMENOW,$show_count);

$event_get vB::$db->query_read($query); 

$output_bits ''
while(
$event vB::$db->fetch_array($event_get)) { 

     if(
$event['dateline_to'] == 
     { 
         
$format sprintf("On %s",date('jS M Y',$event['dateline_from'])); 
     } else { 
         
$format sprintf("From %s to %s",date('jS M Y',$event['dateline_from']),date('jS M Y',$event['dateline_to']));
     } 
      
     
$output_bits .= sprintf(
        <div class = "cms_widget_post_bit"><h4 class="cms_widget_post_header"><a href="calendar.php?do=getinfo&e=%d"><p style="color:red">%s</p></a></h4> 
            <p class="cms_widget_post_content">%s</p> 
        </div> 
        '
,$event['eventid'],$event['title'],$format); 


$output $output_bits

ob_end_clean(); 


LifesGreatestGift 05-06-2012 01:19 PM

why convert it? just install a php code widget on wordpress, chdir to the forum directory require global.php, change back and bam.

ExoticAgenda 05-07-2012 06:29 PM

How would I do that? WordPress and vBulletin are both installed on the root of my website. When i chdir i get this error:
Fatal error: Access to undeclared static property: VB::$db

thanks

kh99 05-07-2012 07:54 PM

If vb's global.php is in the same directory as the script that's running your code, then you don't need to chdir. If you still get that error, try removing the VB:: from in front of $db.

ExoticAgenda 05-08-2012 12:11 AM

I did that, I removed the VB:: and now nothing shows up (atleast no errors), but now I am not sure what to check next. thanks

kh99 05-08-2012 12:52 AM

A vb widget only sets $output to the widget html. I don't know how a WordPress widget works, but unless it works exactly the same way then you're probably not going to get any output.

ExoticAgenda 05-08-2012 02:20 PM

hm, ok. is there any way to figure out how to display the text? Or am I going to need to have a widget made from scratch that queries the table. thanks

kh99 05-08-2012 02:58 PM

I think what you need is some info on how to write a WordPress widget (which may be quite different than a vb widget even though they're both called widgets). Of course this is a vb forum and not WP, but someone here probably knows. Or you could try a wordpress forum.

ExoticAgenda 05-11-2012 11:07 AM

yeah ill need to look into that, thanks for the help though

ExoticAgenda 06-10-2012 08:11 PM

To follow up on this, I got it working. I needed to echo out the output and remove the vB:: and other small things. But it works now.

PHP Code:

<?php

global $db;

require(
'global.php');

//  %d  
$show_count 5;  

$query sprintf("SELECT * FROM ".TABLE_PREFIX."event WHERE visible = 1 AND (dateline_from > '%d' || (  dateline_from > '%d' AND dateline_to < '%d' )) ORDER BY dateline_from ASC LIMIT %d",TIMENOW,TIMENOW,TIMENOW,$show_count);

$event_get $db->query_read($query);  

$output_bits '';  
while(
$event $db->fetch_array($event_get)) {  

     if(
$event['dateline_to'] == )  
     {  
         
$format sprintf("On %s",date('jS M Y',$event['dateline_from']));  
     } else {  
         
$format sprintf("From %s to %s",date('jS M Y',$event['dateline_from']),date('jS M Y',$event['dateline_to']));
     }  
       
     
$output_bits .= sprintf('  
        <div style="text-align: left; margin-left: 25px;"><b><a href="calendar.php?do=getinfo&e=%d">%s</a></b>   
            %s</div><br />          
        '
,$event['eventid'],$event['title'],$format);  

}  
 
echo 
"$output_bits";
echo 
"<a style='margin-right: auto;' href='http://www.exoticagenda.com/calendar.php'>See more events</a>";
?>



All times are GMT. The time now is 04:14 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.01300 seconds
  • Memory Usage 1,750KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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