We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Help Needed on Update of Paragraph to <br />

Development and Programming

Greg Aker's avatar
Greg Aker
6,022 posts
17 years ago
Greg Aker's avatar Greg Aker

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

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

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

       
Greg Aker's avatar
Greg Aker
6,022 posts
17 years ago
Greg Aker's avatar Greg Aker

Darn!

I was excited about doing this on my own! 😊

Thank you,

-greg

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.