vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   vBulletin Forum Sideblocks - UpComing Events SideBlock/Bar With/Without Image (https://vborg.vbsupport.ru/showthread.php?t=253239)

zapiy 01-11-2013 07:29 PM

Can i use this on VBadvanced as a module is some way please?

CptBogo 02-05-2013 05:56 PM

i have modified this a little bit for my forum and i thought i would share.

instead of
PHP Code:

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'])); 
     } 

i used
PHP Code:

$format sprintf("On %s at %s"vbdate('jS M, Y',$event['dateline_from']), vbdate('g:i A'$event['dateline_from'])); 

this does a couple things different.

first i changed the format to look like 'On 5th Feb, 2013 at 8:00 PM'. the end date wasnt as important to us as the time the event started so i added the time and removed the end date.

second it uses the vbulletin 'vbdate' function instead of the PHP 'date' function. this will automatically change the date to the users timezone instead of using the servers timezone. remember to set 'Cache Time' to 0 in the forum block settings or else it will cache someone elses timezone and be incorrect for every other user.

hope this helps someone else trying to do something similar.

and a screenshot of how it looks on my forum.
https://vborg.vbsupport.ru/external/2013/02/43.png

Filip 02-06-2013 03:02 AM

Is there a simple way to have the date being displayed in a other language than english?

rhody401 02-06-2013 01:20 PM

I like the changes you made a couple posts before this one(VBDATE), but it still seems to show one day earlier than the scheduled date. (for all events on my calendar)

I have the cache set to 0, etc.

Any ideas why? Are you having the same issue?

CptBogo 02-06-2013 06:36 PM

Quote:

Originally Posted by Filip (Post 2402305)
Is there a simple way to have the date being displayed in a other language than english?

if the user logged into vbulletin has another language set in their profile the vbdate function should adjust it for their language. you might want to change the format the date is displayed in though vbdate("format here", time())
if you are familiar with PHP you might want to have a look at these functions:
http://www.php.net/manual/en/function.setlocale.php
http://www.php.net/manual/en/function.strftime.php
they work together, you use the first function to set the language you want to use and the second function creates the date string based on the language you defined in the first function. note that the vbdate function includes those 2 functions in it.


Quote:

Originally Posted by rhody401 (Post 2402365)
I like the changes you made a couple posts before this one(VBDATE), but it still seems to show one day earlier than the scheduled date. (for all events on my calendar)

I have the cache set to 0, etc.

Any ideas why? Are you having the same issue?

i did not have this issue. however it looks like others have been experiencing it. there are a couple solutions in this thread. but the easiest is probably:
PHP Code:

$format sprintf("On %s at %s"vbdate('jS M, Y',$event['dateline_from']+86400), vbdate('g:i A'$event['dateline_from'])); 

this simply adds 1 day(in seconds) to the events timestamp so when it gets the formatted date string its +1 day


also for those interested i have updated my own code to show 'Today', 'Tomorrow', etc instead of the day, month and year. if the date is more then a week in the future it will display the full day, month, year format(February 6th, 2013).

PHP Code:

if(vbdate("dmY"$event['dateline_from']) == vbdate("dmY")) //it is today.
    
{
        
$format sprintf("Today at %s"vbdate('g:i A'$event['dateline_from']));
    }
    elseif(
vbdate("dmY"$event['dateline_from']) == vbdate("dmY"time() + 86400)) //it is tomorrow
    
{
        
$format sprintf("Tomorrow at %s"vbdate('g:i A'$event['dateline_from']));
    }
    elseif(
$event['dateline_from'] < (time() + 604800)) //1 week = 604800 //it is this week
    
{
        
$format sprintf("%s at %s"vbdate('l',$event['dateline_from']), vbdate('g:i A'$event['dateline_from']));
    }
    else
    {
        
$format sprintf("%s at %s"vbdate('l, F jS',$event['dateline_from']), vbdate('g:i A'$event['dateline_from']));
    } 

https://vborg.vbsupport.ru/external/2013/02/38.png



Edit: I have discovered an issue where full day events that do not have a start time specified dont display correctly. for example the last event in my screenshot, "Starcraft II Risk", should start at 12AM on Saturday and not on Friday. i do not currently have a way to fix this but when i do i will post an update.

ITMerc 02-22-2013 10:59 PM

Hi folks! How/where would you modify the code to insert a page break so you'd have an empty line between the date of the first event and the description/title of the NEXT event... I want to visually separate them.

Hawkinz 03-04-2013 10:01 AM

My block doesn't show up when PHP is selected. Any ideas? cheers

rhody401 03-21-2013 03:27 PM

I have modified this a bit to make it in a format for USA Month Day Year, and some other small changes. (my modified code below)

It would be REALLY nice if I could find a way to have it exclude some calendar items that have a specific string of text in the title. I just don't know where to put the hook to make this happen. Any suggestions appreciated! :) THANK YOU

example: If a calendar event has "BOARD MEETING" anywhere in the TITLE, it gets overlooked/ignored by this code. It displays everything else, but these events.

Here is my (current/modified from above) code:
PHP Code:

ob_start(); 

//  %d 
$show_count 9

$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(" "); 

//changed code 2/6/13  adds a day  to fix issue, and reformat for USA m/d/y
$format sprintf("On %s"vbdate('M jS, Y',$event['dateline_from']+86400), vbdate('g:i A'$event['dateline_from'])); 

     } else { 
         
$format sprintf("From %s to %s",vbdate('M jS',$event['dateline_from']),vbdate('M jS Y',$event['dateline_to'])); 
     } 
      
     
$output_bits .= sprintf(
      <div class = "cms_widget_post_bit"><center><a href="calendar.php?do=getinfo&e=%d"><h4 class="cms_widget_post_header"><font size="2">%s</font></a></h4> 
            <p class="cms_widget_post_content"><font size="1">%s </font></p><p><font size="1">&nbsp;</font></p></center> 
        </div> 
        '
,$event['eventid'],$event['title'],$format); 


$output $output_bits

ob_end_clean(); 
return 
$output

Thanks in advance if anyone has the time to look at this and give some advice.

Much appreciated! :up:
Rhody

CptBogo 04-01-2013 12:00 PM

Quote:

Originally Posted by rhody401 (Post 2411407)
I have modified this a bit to make it in a format for USA Month Day Year, and some other small changes. (my modified code below)

It would be REALLY nice if I could find a way to have it exclude some calendar items that have a specific string of text in the title. I just don't know where to put the hook to make this happen. Any suggestions appreciated! :) THANK YOU

example: If a calendar event has "BOARD MEETING" anywhere in the TITLE, it gets overlooked/ignored by this code. It displays everything else, but these events.

Here is my (current/modified from above) code:


Thanks in advance if anyone has the time to look at this and give some advice.

Much appreciated! :up:
Rhody

PHP Code:

ob_start();  

//  %d  
$show_count 9;  

$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(!
strpos($event['title'], "BOARD MEETING")) // do not show event
    
{
    
        if(
$event['dateline_to'] == )  
        {  
            
$format sprintf(" ");  
    
            
//changed code 2/6/13  adds a day  to fix issue, and reformat for USA m/d/y 
            
$format sprintf("On %s"vbdate('M jS, Y',$event['dateline_from']+86400), vbdate('g:i A'$event['dateline_from'])); 
        
        }
        else
        {  
            
$format sprintf("From %s to %s",vbdate('M jS',$event['dateline_from']),vbdate('M jS Y',$event['dateline_to'])); 
        }  
           
        
$output_bits .= sprintf('  
          <div class = "cms_widget_post_bit"><center><a href="calendar.php?do=getinfo&e=%d"><h4 class="cms_widget_post_header"><font size="2">%s</font></a></h4>  
                <p class="cms_widget_post_content"><font size="1">%s </font></p><p><font size="1">&nbsp;</font></p></center>  
            </div>  
            '
,$event['eventid'],$event['title'],$format);  
            
    }

}
 
$output $output_bits;  

ob_end_clean();  
return 
$output

i have added a simple check if(!strpos($event['title'], "BOARD MEETING")) which says if the title does not contain BOARD MEETING. if it does have BOARD MEETING it skips the event and moves to the next one.

i havnt tested it but it should work.

rhody401 04-01-2013 01:45 PM

Thank you thank you thank you! :)

I had to take out the first few characters on top, and it is case sensitive, but very workable for what i'm trying to fix. I will fix the calendar entries to be the correct case, so they get ignored.

It does work!

Rhody


All times are GMT. The time now is 02:51 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.01321 seconds
  • Memory Usage 1,809KB
  • 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
  • (6)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete