Templating a WordPress Plugin?

I have just created a simple WordPress Plugin which basically gets some data from sources and displays it using a loop.

I want to be able to template this so that users can have a choice in how it displays or even create their own.

Something like Smarty would be fantastic but I can’t seem to find a way to do this?

Currently my code is like this:

 echo '<div class="row">';
    foreach ($results->products as $product) {

        echo '<div class="col-md-4 col-xs-12 text-center fiflitem">';
        echo '<div class="thumbnail"><a href="' . $product->link . '" target="_blank"><img src="' . $product->thumbnail . '" width="125px" height="125px"></a></div>';
        echo '<div class="prodname"><a href="' . $product->link . '" target="_blank">'.$product->product_name.'</a></div>';
        echo '<div class="store"><img src="'.$product->merchant_logo.'" alt="'.$product->merchant_name.'"></div>';

       if ($product->price_was!='0.00') {
        echo '<div class="pricing">£'.$product->price.' (was £'.$product->price_was.')</div>'; }
        else {
            echo '<div class="pricing">£'.$product->price.'</div>';

        echo '<div class="buybutton"><a href="' . $product->link . '" target="_blank" class="btn btn-default">More Info</div>';

        echo '</div>';

    echo '</div>';

So as you can see it is going to be quite complicated for somebody to edit, however if it was using something like Smarty (or similar) I could simplify the templates a lot more for users to be able to edit it.

Where would I start trying to get something like this working inside the plugin?

Source: wordpress

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.