ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

word limit, and stripping XHTML?

October 25, 2007 7:10am

Subscribe [2]
  • #1 / Oct 25, 2007 7:10am

    Jan_Huygens

    106 posts

    I’ve got some weblog entries where the formating is XHTML and thats just right for the normal display, since users will be creating those fields.

    However, I also wanted to to use the word limit plugin to display some of the entry text as a link.

    Unfortunately this means I get an opening in the text output from Word Limit, and no closing .
    :long: 


    So, my question is: is there a way to suppress the XHTML formating on this occasion, without turning it off completely? 

    Alternatively, is there a better way to do this not using Word Limit?

    thanks

  • #2 / Oct 25, 2007 11:08am

    allgood2

    427 posts

    I use TruncHTML plugin (may have the name slightly off). I use it when I need to make a summary from the body field. I don’t want summaries to have links, plus, I typically also have the same data (the summary) as part of the metadata, which can not have HTML.  It works very well for stripping the HTML out, but it uses a character count instead of a word count, which is kind of irritating.

    Alternatively, I’ll embed plugins, like using the Strip HTML plug-in, surrounded by the Word Count plugin like

    {exp:word_limit total="50"}{exp:html_strip}{body}{/exp:html_strip}{/exp:word_limit}
  • #3 / Oct 25, 2007 11:26am

    Jan_Huygens

    106 posts

    brilliant 😊

    thanks

    Ive just tried the second option and it works nicely!

  • #4 / Oct 25, 2007 3:11pm

    Daniel Walton

    553 posts

    Instead of using multiple plugins per field display, which I’m sure will have some kind of performance impact, you could consider setting the field formatting to ‘none’, and using one of the few typography plugins around (pi.ee_typography.php springs to mind) to wrap the field on the ‘normal’ display.
    e.g., on your regular template:

    {exp:weblog:entries etc="etc"}
     ...
        {exp:ee_typography formatting="xhtml"}{my_field}{/exp:ee_typography}
     ...
    {/exp:weblog:entries}

    This will have considerations though, for example, if you were displaying the entry in full on several different templates - managing this in the future would be a little more cumbersome.

  • #5 / Oct 25, 2007 3:19pm

    allgood2

    427 posts

    The EE Typography plug-in would work if he/she wanted the full field of data, but would still require the word limit plugin to be encased to limit the word count. But also, it also (the typography plugin) doesn’t solve the issue of tag being opened but not closed due to the word limit feature. Both those issues are handled by the two solutions I offered. TruncHTML is particularly nice for this since it will close any tags that are still open, when the character count is reached. The second option just strips all HTML so you don’t have to worry about the tags at all.

  • #6 / Oct 25, 2007 4:21pm

    Daniel Walton

    553 posts

    I think you misunderstood.

    The regular ‘full’ display template would need only the ee_typography plugin. The template showing the shortened version would need only the word limit plugin (albeit encased with and <a> tags) to wrap the field.

    I’m not arguing that my solution is best, just viable under some circumstances.

  • #7 / Oct 25, 2007 4:26pm

    cclus

    10 posts

    Just a quick note to say how much this helped me with a current problem I’m having. Thanx!

  • #8 / Oct 25, 2007 5:10pm

    Jan_Huygens

    106 posts

    @the_butcher

    thanks for that thought, i’ll certainly bear it in mind for the future. 

    In my current case, I only have a few entries to link, so that performance hit with nested plugins seems to be quite acceptable.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases