I’m still really new to php, and as an attempt to “write” a plugin, I have decided to tweak an existing one to suit my needs.
This adds <li></li> tags in place of Paragraph & tags, but I would like some assistance in making the output html a little “prettier.”
Here is the nuts & bolts of what I did
class List_item
{
var $return_data = "";
function List_item($str = '')
{
global $TMPL;
$this->return_data = '';
if ($str == '')
$str = $TMPL->tagdata;
$str = str_replace("
", "</li><li>", $str);
$str = str_replace("", "<li>", $str);
$str = str_replace("", "</li>", $str);
$this->return_data = $str;
}
Here is how I used it in the template
{exp:weblog:entries}
<ul>
{exp:list_item}{body}{/exp:list_item}
</ul>
{/exp:weblog:entries}
Here is how how it outputs the html
<h2>Draft Beers</h2>
<ul>
<li>Michelob Light
</li><li>
Rogue Dead Guy Ale
</li><li>
Schlafly Oatmeal Stout
</li><li>
O’Fallon I.P.A.
</li><li>
Boulevard Unfiltered Wheat
</li>
</ul>
Any suggestions on how to make it “prettier”? Or should I really care 😊
-greg
Hi Greg,
You could perhaps learn from this plugin here. 😊
Pretty sure that this does exactly what you want already but if not then you can perhaps pull it apart to learn from it?
Hope that helps.
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.