Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-06-2012, 12:10 PM
ExoticAgenda ExoticAgenda is offline
 
Join Date: Nov 2011
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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(); 
Reply With Quote
  #2  
Old 05-06-2012, 01:19 PM
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Location: Louisville, KY USA
Posts: 885
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

why convert it? just install a php code widget on wordpress, chdir to the forum directory require global.php, change back and bam.
Reply With Quote
  #3  
Old 05-07-2012, 06:29 PM
ExoticAgenda ExoticAgenda is offline
 
Join Date: Nov 2011
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 05-07-2012, 07:54 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 05-08-2012, 12:11 AM
ExoticAgenda ExoticAgenda is offline
 
Join Date: Nov 2011
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 05-08-2012, 12:52 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 05-08-2012, 02:20 PM
ExoticAgenda ExoticAgenda is offline
 
Join Date: Nov 2011
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 05-08-2012, 02:58 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 05-11-2012, 11:07 AM
ExoticAgenda ExoticAgenda is offline
 
Join Date: Nov 2011
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yeah ill need to look into that, thanks for the help though
Reply With Quote
  #10  
Old 06-10-2012, 08:11 PM
ExoticAgenda ExoticAgenda is offline
 
Join Date: Nov 2011
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>";
?>
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:57 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04804 seconds
  • Memory Usage 2,269KB
  • Queries Executed 13 (?)
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
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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