This Question is Resolved.

If you have a similiar issue that this thread does not address, click the button below to open a new related support topic.

 
 
{exp:word_limit} removing the closing </p>
Posted: 08 August 2006 11:34 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  853
Joined  01-07-2003

{exp:word_limit total="25"}

{main_content}

{
/exp:word_limit}

So I’m looking all over the page checking all of my divs and spans trying to fugure out what is shrinking all of my fonts in the second half of the page and then I zero in on it . . . . . 

It appears that the word limit plugin limits more than words. . .  it also removes the closing </p> tag.

That’s just not right.  ohh

 Signature 

 NetRaising is a member of the EE Pro Network

Profile
 
 
Posted: 09 August 2006 05:50 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  756
Joined  03-22-2004

Is the formatting for your {main_content} field Xhtml?
The only thing I can think of is that you have manually added <p> tags to your entry which has its formatting turned to Xhtml. That is to say you can see <p> tags in our entry form field rather than adding it by using a paragraph break

Profile
 
 
Posted: 09 August 2006 06:28 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1097
Joined  03-22-2006

have you tried setting your custom field to formatting: none

then using tags this way in your template:

{exp:textile}{exp:word_limit total="xx"} {your_custom_field_etc_etc} {/exp:word_limit}{/exp:textile}

This in theory would work, though i cannot confirm right now.

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 09 August 2006 07:55 AM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15743
Joined  06-03-2002

Just to clarify here Kurt, it sounds like that field has its formatting set to “none” and the markup is keyed in manually as part of the field’s content?  I’m not thinking of a way of changing that plugin that would make sense, as it would need to read and fully understand the intent of HTML markup within a field.  What if someone constructed fields so that the markup did not begin or terminate within that particular custom field?  There could be an intentional lack of a matched pair in that situation.  Also, which markup would be safe to discard from the leftover words and which would be safe to keep?  There’s not really any way again of knowing the publisher’s intent.

If you’re using the word limiter, it might be best to use a format type for the custom field.  But if you always know the intent and what markup is supposed to be there, you could easily modify the Word Limiter plugin to see if there is a closing paragraph tag, and if there’s not, slap one on the end.

 Signature 
Profile
MSG
 
 
Posted: 09 August 2006 07:59 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1097
Joined  03-22-2006

That is, if the first x amount of words is in a paragraph smile  Ive talked about this with a coworker, and decided that it definitely needs some dev time - building an array of opening tag pairs etc, then closing them sequentially.

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 09 August 2006 08:07 AM   [ Ignore ]   [ # 5 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15743
Joined  06-03-2002

the_butcher, you could still easily have a problem where your layout was expecting and required <div class=“foo”>bar</div>, but if the opening part of that tag fell outside of the word limit, it would get cut out. In that case the plugin would have to know explicitly what markup for the field is “required”, and the only real way to handle that is for that specific site’s developer to modify the plugin within the parameters of what markup they know their layout requires.

 Signature 
Profile
MSG
 
 
Posted: 09 August 2006 08:52 AM   [ Ignore ]   [ # 6 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1097
Joined  03-22-2006

Or even just put layout critical markup within the template itself, or even a different custom field. Good design never hurt anyone.

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 09 August 2006 10:42 AM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  756
Joined  03-22-2004

Just to clarify here Kurt, it sounds like that field has its formatting set to “none” and the markup is keyed in manually as part of the field’s content?

That would be defined version of what I was trying to say smile

Profile
 
 
Posted: 09 August 2006 01:12 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  853
Joined  01-07-2003

Hello everyone. . .

OK. . . the formatting of the field is set to XHTML and there are no paragraph tags in the entry. . . .

I really don’t want to set the field formatting to none if it can be avoided becuase setting it that way by default will mess with the rest of a very full site, and my poor web-master/publisher has enough to remember about EE already. ;~)

For now I’ve just added a closing </p> to the template and it works. .. . but I’m thinking there must be a better way.

I’m guessing that the XHTML formatting happens before the word limiting. . . .  so is it possible to have the word limiting happen before the XHTML formatting. . .  then we would be home free. . . at least I think we would.

 Signature 

 NetRaising is a member of the EE Pro Network

Profile
 
 
Posted: 09 August 2006 01:17 PM   [ Ignore ]   [ # 9 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15743
Joined  06-03-2002

So indeed it is.  A quick solution would be to change the formatting to “none”, and use the XHTML typography plugin around the field and word limit plugin.  The inner plugin will get parsed first, and then XHTML typography applied only to the remaining text.

 Signature 
Profile
MSG
 
 
Posted: 09 August 2006 01:24 PM   [ Ignore ]   [ # 10 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  15167
Joined  05-15-2004

For now I’ve just added a closing </p> to the template and it works. .. . but I’m thinking there must be a better way.

Yes, me to. For very short entries that are not shortened because they don’t reach the threshold, that actually leads to </p></p>. Well, not much of a problem in reality, if not exactly elegant.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 11 October 2006 10:15 AM   [ Ignore ]   [ # 11 ]  
Grad Student
Avatar
Rank
Total Posts:  84
Joined  09-25-2006

greetings and salutations ...

i am also experiencing the removal of the </p> using both {word_limit} and {word_limit_plus} plugins.
as with kurt my body field has no <p> tags, is XHTML and i’m also loathed to change it for the sake of one template.

but if i manually add a </p> in the template then for entries that are less than xx words then i’ll get an erroneous </p> and the page will fail XHTML validation.

have any of you clever bods out there thought of an alternative answer?

 Signature 

gravity is a myth ... the earth sucks gulp

Profile
 
 
Posted: 12 October 2006 05:51 AM   [ Ignore ]   [ # 12 ]  
Grad Student
Avatar
Rank
Total Posts:  78
Joined  05-12-2006

I solved this by just stripping XHTML tags out of the truncated content.  I keep the excerpts small enough that it is fine if it is condensed into a single paragraph.

I use word_limiter_plus and at the beginning of the word_limiter_plus function in the plugin file, I just added “$str = strip_tags($str);”, i.e:

// ----------------------------------------
    //  Word limiter
    // ----------------------------------------
    
    
function word_limiter_plus($str, $if_Exceeds = 500, $stop_after = 500, $the_link = "")
    
{
        $str
= strip_tags($str);

        if (
strlen($str) < $stop_after)
        
{

And then I just put my truncated content inside of <p> tags:

<p>{exp:word_limit_plus if_exceeds="N" stop_after="M" the_link="XXX"}{body}{/exp:word_limit_plus}</p>

And I don’t have to worry about broken tags then.

Other than stripping the tags, you’d have to do some HTML parsing or DOM tree parsing to keep track of the tags in order to properly close them all.

Profile
 
 
Posted: 12 October 2006 07:49 AM   [ Ignore ]   [ # 13 ]  
Grad Student
Avatar
Rank
Total Posts:  84
Joined  09-25-2006

that’s fantastic! many thanks smile

 Signature 

gravity is a myth ... the earth sucks gulp

Profile
 
 
Posted: 12 October 2006 08:54 AM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  853
Joined  01-07-2003

That’s great dreamscape,

Now if I can just remember what site I was working on back in August . . . I can update their templates. .. .

Thanks.

 Signature 

 NetRaising is a member of the EE Pro Network

Profile
 
 
Posted: 26 June 2008 12:58 PM   [ Ignore ]   [ # 15 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1053
Joined  06-05-2007

Man!  Needed that.  This is a great solution even two years later.  Thanks dreamscape.

 Signature 

grantmx | designs - design | development | photography | consulting | ee pro profile

Profile
 
 
Posted: 26 June 2008 01:43 PM   [ Ignore ]   [ # 16 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32773
Joined  05-14-2004

Glad you were able to find this thread, Grant!  There are other options now as well, including TruncHTML I believe; or possibly Word Limit Plus. =)

 Signature 
Profile
MSG
 
 
 

This Question is Resolved.

If you have a similiar issue that this thread does not address, click the button below to open a new related support topic.

 
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64535 Total Logged-in Users: 21
Total Topics: 81113 Total Anonymous Users: 28
Total Replies: 436441 Total Guests: 189
Total Posts: 517554    
Members ( View Memberlist )
Newest Members:  marlusbluespotmusicvolandspinhirnetheminiokostiamasterjeMBossbchaleyalvonsius