Separate Date and Time in events-advanced-list-load-widget-display.php File

Home Forums Calendar Products Events Calendar PRO Separate Date and Time in events-advanced-list-load-widget-display.php File

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #18324
    Jim
    Participant

    In the events-advanced-list-load-widget-display.php file is there a way to separate the date and time into separate HTML elements, rather than displaying as one element? I figured out how to remove the time by using $displayTime = false in the tribe_get_start_date(); function, but can’t figure out how to remove the date so that each element can be echoed into it’s own element. Am I thinking about this the wrong way? Any help would be greatly appreciated.

    #18343
    Rob
    Member

    Hi there Jim. Thanks for reaching out. Are you saying you want these to be displayed separate from one another within the widget, or that you just want to remove the date but keep the time? If you can provide a bit more elaboration (my apologies for having to ask) on what you want to do, I can bring in a dev on our end to take a look.

    #18345
    Henry
    Member

    You can echo the time and date separately easily enough. To echo the start time for example you could use this:

    echo tribe_get_start_date(null, false, ‘g:iA’);

    Then to echo the start date you could use this:
    echo tribe_get_start_date(null, false, ‘l j F Y’);

    #18347
    Jim
    Participant

    @Rob La Gatta: Thanks for the quick response! Yes, I’d like to be able to display these items separately for styling purposes (I don’t know if I can type HTML in this forum but I’d like to basically do something like, “05-0312:30pm”. Basically what I’m doing is this: I’ve created a widgetized sidebar for my client for easier customization on his end in which I’d like to list the events, but the options in the sidebar only allow you to show or hide the date and time together, not separately. That said, I figure that modifying the code that will be displayed in the sidebar (wp-content/themes/plugins/events-calendar-pro/views/events-advanced-list-load-widget-display.php) is the best way to approach this. However, being a front-end developer with limited knowledge of programming, I’m struggling with this. Thanks!


    @Henry
    : Thanks for the quick response! I have to admit my ignorance here and say that I’m not sure how to use those functions and where they should go. I messed around with them in the wp-content/themes/plugins/events-calendar-pro/views/events-advanced-list-load-widget-display.php file but it broke every time I changed something. Hopefully I made myself more clear above. Can you explain how to use those in a little more detail? Thanks!

    #18427
    Rob
    Member

    Thanks, Jim. Just wanted to give you a heads up that I’m talking this over with the dev team and should be able to get you some guidance on it by the afternoon. Stay tuned and thanks for being patient thus far.

    #18436
    Jim
    Participant

    Thanks Rob. I just realized that the HTML I typed didn’t come through so hopefully you understand what I’m trying to explain. Let me know if you need any more clarification.

    #18464
    Rob
    Member

    Gotcha. Thanks, Jim – I think I understand the issue here, but as this is a bit outside my area of expertise, I’ve asked Jonah from our dev team to take a look and respond directly. Expect to hear from him shortly…and if he isn’t sure I can run it up the flagpole until we’ve got you something substantive here.

    #18476
    Henry
    Member

    @Jim

    They have to be wrapped in php tags so the browser knows to treat them as php code. See an example here:
    http://pastebin.com/K2HcPXjG

    Hope this helps.

    #18538
    Jonah
    Participant

    Hey Jim,

    Like Henry pointed out those tags do need to be wrapped in PHP tags but let me elaborate a little more…

    The tribe_get_start_date() function can be used as many times as you to spit out whatever you want about the start date/time for an event. By default the function is going to use your date/time display format in Settings > General, but you can easily override this. All you need to do is pass in parameters to trim down what particular date/time information is being displayed for each instance. The function accepts standard PHP date format parameters to determine the format. It may help to take a look at those: http://php.net/manual/en/function.date.php

    So, let’s say you only wanted the first part to display the month on line 46. Just change line 46 to read:

    echo tribe_get_start_date( $post->ID, $start, 'M' );

    Or you could change it to display the full month name:

    echo tribe_get_start_date( $post->ID, $start, 'F' );

    Then, if you wanted to display the time chunk, just either add another div outside of the div with the class of “when” or add it within and it doesn’t need to be a div, it could be any html element. Maybe try a span first.

    So, right below line 46 you could add: http://pastie.org/private/hagxmeraymgojaegxfw8a

    And that will give you a span tag with the time inside that you can style via the event-time class in your CSS.

    Let us know how it goes. I hope that helps!

    #18558
    Jim
    Participant

    Ok, that did the trick! Thanks so much everyone for the help! I really appreciate it!

    #18570
    Jonah
    Participant

    Glad to hear Jim, let us know if there’s anything we can do!

    – Jonah

    #976705
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Separate Date and Time in events-advanced-list-load-widget-display.php File’ is closed to new replies.