• Hi there,

    I’m just wondering about the format attribute of the EM_Events function. Can I have a little more info on this? If I read correctly, I am guessing there is a way to reference a specific template file for the layout of the output, but I’m not sure how to pass this argument. Would this be correct?

    'format'=>'index-events.php'

    where index-events is my template for how events should be displayed on the homepage?

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter creativelifeform

    (@creativelifeform)

    Ah okay that was not correct. To anyone else who is wondering this, here’s a solution:

    <?php
    
        ob_start();
        include 'events-index.php';
        $result = ob_get_contents();
        ob_end_clean();
    
        if (class_exists('EM_Events'))
        {
                echo EM_Events::output( array('limit'=>3,'orderby'=>'start_date','format'=>$result) );
        }
    ?>

    you can use shortcodes to display events in your homepage.

    e.g.
    On the default twentyeleven theme the homepage displays post Hello World! and if you add shortcode [events_list] to it; it will let display events list in homepage.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    the format att is meant to accept a string with placeholders.

    however, your idea is actually a pretty neat suggestion…. like a template=> option

    Thread Starter creativelifeform

    (@creativelifeform)

    Yep that’s pretty much what I’ve done, it works perfectly. Shouldn’t be too hard to write a class for it and include it as an option for this function I guess.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    one thing I’d do though is force a specific template name for security, e.g. template => ‘loop’

    which points to something like templates/parts/loop.php

    Thread Starter creativelifeform

    (@creativelifeform)

    Just curious, why would the current method pose a security risk?

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    if someone gets access to that variable, they can load/execute anything on your filesystem.

    this way, just clean that string (i.e. alphanumeric + dashes only) and slot it into the filename.

    not a high risk, but still worth taking precaution i think

    Thread Starter creativelifeform

    (@creativelifeform)

    Yeah when I write the class I will do as you suggested, thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Format attribute’ is closed to new replies.