Tag Limit enables you to take html and show only certain tags. for example a … .
Parameters
tag - the tag you wish to show. (default p) num - the number of tags to show. (default 1) offset - offset the first result returned by given amount, if the offset os greater than the number of matching tags you will get nothing returned. class - search for only tags with a certain class. id - same as class but by id. show_tags - ‘off’ will return the match without encasing tags, on will return them. (off or on, default is on) word_limit - limits the word total of the returned data. This can be set to limit on each tag found, should you set ‘num’ to greater than 1, or on the output as a whole, using the below parameter. limit_style - (each or all, default each)
Example usage
Imagine this is your content (please note duplicate id references are invalid in xhtml)
paragraph 1
paragraph 1 with class foo
paragraph 1 with id bar
paragraph 2
paragraph 2 with class foo
paragraph 2 with id bar
paragraph 3
paragraph 3 with class foo
paragraph 3 with id bar
paragraph 4
paragraph 4 with class foo
paragraph 4 with id bar
paragraph 5
paragraph 5 with class foo
paragraph 5 with id bar
Using these tag parameters
{exp:tag_limit tag="p" class="foo" num="2" offset="2"}
You will get
paragraph 3 with class foo
paragraph 4 with class foo
The word limiter functionality comes from EE’s built in word_limit function, so remains the same issues with leaving tags open as with the official word_limit plugin.
You can use class and id together if you so wish, there is no set order that the two parameters need to be (within the html tag).
Current version: 1.3.1
That’s cool. What would also be useful would be the ability to take everything but the first paragraph. You could then insert content between the two.
Indeed that would be kinda cool, one way you could do it is just give the first paragraph in your entry a class/id different to that of the 2nd/3rd/4th paragraph etc. Or use custom fields in your blog 😊
Hi Daniel,
Just came across this plugin from seeing another post somewhere on the forums here and I think I must be having a senior moment or something as I have been trying to rack my brain to think of ways to use this.
Do you think you could possibly give me a couple of examples where you could think of using this? I think my brain must have gone into overload over the holiday season or something! 😉
Hope you had a great Christmas and a Happy New Year.
Best wishes,
Mark
Say you wanted to take the first paragraph from a content field to use as a summary, rather than having a separate summary custom field. Maybe you want to inset google adwords after the first couple of paragraphs. Say you had a custom field which you insert images into, but want to ensure only one image is displayed on your template? I could go on but I won’t. I had a need (which I cannot remember) and this filled the niche.
Is there any way to do this sort of thing?
{exp:weblog:entries weblog="default_site" url_title="testing_tag_limit_plugin" limit="1" disable="member_data|trackbacks|pagination|categories|category_fields"}
<h1>{title}</h1>
{exp:tag_limit tag="p" num="10" class="test"}
{body}
{/exp:tag_limit}
{/exp:weblog:entries}
Say I have this as the entry contents :
Test paragraph 1
Test paragraph 2
Test paragraph 3
Test paragraph 4
Test paragraph 5
Test paragraph 6
Test paragraph 7
Test paragraph 8
Test paragraph 9
Test paragraph 10
How would you (without knowing the amount of p tags with the test class) set the plugin parameters to return all the p tags with the test class. In the example above there are 4 p tags with the test class but how would you let the plugin dynamically know to return all of them instead of having to program the num=”4” parameter?
I’m probably just missing something somewhere I guess?
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.