Okay
  Public Ticket #2017442
Event Variables
Closed

Comments

  • Julien Rusev started the conversation

    Hello,

    Is it possible to display Event Icon, Event Location and Event Start Date in my homepage? I was trying to find an icons or variables into database but I couldn`t.  

    Thanks for attention !!! :)

  •  894
    Zhivko replied

    Hi,

    Could you elaborate?

    You want to display this data outside the calendar or in specific calendar view?

    Outside the calendar you can query an event with php like this:

    <?php
            $event_id   = 2413;
            $event      = new Stachethemes\Stec\Event_Post($event_id);
            
            $icon       = $event->get_icon();
            $location   = $event->get_location();
            $start_date = $event->get_start_date();
    ?>



    Stachethemes Developer

  • Julien Rusev replied

    Hello, 

    I am trying to display this data outside the calendar, in other plugin. This plugin display my events in slider. 

    I attached some screenshots. I already have description and background image in front end, but can`t find event logo, event date and event location.

    I tried to query event with php but nothing is happens...

    Best regards!


  •  894
    Zhivko replied

    Try this code:

    <?php
    $events = \Stachethemes\Stec\Events::get_events();
    if ($events) {
        foreach ($events as $event) {
            if (!($event instanceof \Stachethemes\Stec\Event_Post)) {
                continue;
            }
            $title             = $event->get_title();
            $date              = \Stachethemes\Stec\Admin_Helper::get_the_timespan($event, 0, true);
            $short_description = $event->get_description_short();
            $full_description  = $event->get_description();
            $images            = $event->get_parsed_images();
            if ($images) {
                $images = array_map(function($image) {
                    return $image->src;
                }, $images);
            }
            // example
            echo "<p>{$title}</p>";
            echo "<p>{$date}</p>";
            echo "<p>{$short_description}</p>";
            foreach ($images as $src) {
                echo "<img src='{$src}' />";
            }
        }
    }
    ?>


    Stachethemes Developer