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 re: plugin that alters EE output

Development and Programming

Kerim Satirli's avatar
Kerim Satirli
52 posts
17 years ago
Kerim Satirli's avatar Kerim Satirli

I have a template that outputs certain articles from some categories as plain text files.

just about everything is working fine, with the only exception being that the article is rendered as one long line.

Now, my solution would be to write a plugin (lets call it ee:linebreak for now) that takes a number as an argument (say 80) and inserts a \r\n when it reaches that count and keeps doing that until the article is done, thereby breaking the article into many lines instead of one.

what I am looking for is the following:

1.) is my reasoning sound? That is, would it work like that or are there better, easier, faster approaches?

2.) how would I write this plugin? Do I hook into typography?

any other points would be greatly appreciated.

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

Kerim,

Sounds good to me. I might check to make sure this doesn’t already exist first.

Your plugin would not need to hook into the Typography class.

I’m thinking maybe it would wrap the article in the template and would strip any HTML out of the resulting $TMPL->tagdata.

Then you would go through do the line breaks after it has been cleaned out.

Make sense?

Jamie

       
Kerim Satirli's avatar
Kerim Satirli
52 posts
17 years ago
Kerim Satirli's avatar Kerim Satirli

Jamie,

thanks for the pointers; they make a lot of sense. I am already using the truncate HTML plugin and it is working fine. Yes, it does strip the images too, but then again, since it is only plain text output, I am fine with that.

When you say “go through and do the line breaks”, do you have a special function in mind? I figure that just counting the length of the string itself would not do me much good.

I am kinda stuck there, any help, even if it is just a function name, would be greatly appreciated!

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

Kerim,

Take a look at the Character Limit and Word Limit plugins in the Add-On Library to see how others have done similar things.

You want to do similar sort of thing except you want to add a line break after your limit instead of truncating the text. You also probably want to preserve words (unless you use a - to end a word that gets cut in half).

There isn’t really a single function that is going to do this for you. You will likely be using str_len, explode and count. You probably want something similar to the Word Limit Plus plugin but in a loop of some kind. You will also want to keep track of both words and characters in a line (thus why you have str_len as a probable function).

Jamie

       

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.