Plugin: tag_limit
Posted: 08 May 2006 07:27 AM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1142
Joined  03-22-2006

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)

<p>paragraph 1</p>
<
p class="foo">paragraph 1 with class foo</p>
<
p id="bar">paragraph 1 with id bar</p>
<
p>paragraph 2</p>
<
p class="foo">paragraph 2 with class foo</p>
<
p id="bar">paragraph 2 with id bar</p>
<
p>paragraph 3</p>
<
p class="foo">paragraph 3 with class foo</p>
<
p id="bar">paragraph 3 with id bar</p>
<
p>paragraph 4</p>
<
p class="foo">paragraph 4 with class foo</p>
<
p id="bar">paragraph 4 with id bar</p>
<
p>paragraph 5</p>
<
p class="foo">paragraph 5 with class foo</p>
<
p id="bar">paragraph 5 with id bar</p>

Using these tag parameters

{exp:tag_limit tag="p" class="foo" num="2" offset="2"}

You will get

<p class="foo">paragraph 3 with class foo</p>
<
p class="foo">paragraph 4 with class foo</p>

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

File Attachments
pi.tag_limit.txt  (File Size: 5KB - Downloads: 369)
 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 08 May 2006 08:35 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
RankRankRank
Total Posts:  559
Joined  01-05-2005

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.

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 08 May 2006 08:53 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1142
Joined  03-22-2006
smallbeer - 08 May 2006 08:35 AM

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 smile

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 25 October 2006 03:39 AM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1142
Joined  03-22-2006

1.2

- With need for dragging out single tags like img, comments, etc i have gone and updated this plugin.

As always please test and mail me bugs.

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 06 March 2007 06:39 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1142
Joined  03-22-2006

1.3

- Updated the plugin to make it a bit leaner, and cleaner.  Also rewritten the first post to explain some the new added functionality.

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 07 March 2007 07:54 AM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1142
Joined  03-22-2006

1.3.1

- Fixed a bug with ‘show_tags’ set to ‘on’ that was letting the plugin return all tagdata rather than suitable matches

- Added ‘offset’ parameter to allow results starting beyond the first match.

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 01 January 2009 03:17 PM   [ Ignore ]   [ # 6 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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! wink

Hope you had a great Christmas and a Happy New Year.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin
Full list of add-ons
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 01 January 2009 03:58 PM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1142
Joined  03-22-2006

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.

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 01 January 2009 04:03 PM   [ Ignore ]   [ # 8 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

Fantastic. The ideas (and my brain!) are now flowing! wink

Thanks for getting my noggin’ going on this one!!

Best wishes,

Mark

 Signature 

Shopping Cart Plugin
Full list of add-ons
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 01 January 2009 04:56 PM   [ Ignore ]   [ # 9 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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 :

<p class="test">Test paragraph 1</p>
<
p class="test">Test paragraph 2</p>
<
p>Test paragraph 3</p>
<
p class="test">Test paragraph 4</p>
<
p>Test paragraph 5</p>
<
p>Test paragraph 6</p>
<
p>Test paragraph 7</p>
<
p class="test">Test paragraph 8</p>
<
p>Test paragraph 9</p>
<
p>Test paragraph 10</p>

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

 Signature 

Shopping Cart Plugin
Full list of add-ons
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 02 January 2009 02:03 AM   [ Ignore ]   [ # 10 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  299
Joined  04-12-2008

Hey Mark

The simplest would probably be to put in a value for num that’s pretty unreal to reach, something like:

{exp:tag_limit tag="p" class="test" num="999"}

I suppose. The probability that you’ll have more than 999 paragraphs with the class test is rather small I’d say.

 Signature 

Designchuchi | Twitter

URL Field Extension
Required Category Extension
DC FreeForm GeoIP Extension
DC Template Manager

Profile
 
 
Posted: 02 January 2009 02:33 AM   [ Ignore ]   [ # 11 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

Hiya,

Yep that’s what I did in the end. Just thought that perhaps if you didn’t supply the num=”“ parameter or if it were blank then might be nice if the plugin just went and output all of them but yep as you say 999 should do it wink

Thanks again.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin
Full list of add-ons
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 19 January 2009 02:17 AM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  473
Joined  03-18-2007

This was perfect for displaying the first bit of recent comments on a sidebar without having to deal with their formatting—thanks!

 Signature 

Follow me on Twitter: twitter.com/mrw

Profile
 
 
Posted: 07 March 2009 02:04 PM   [ Ignore ]   [ # 13 ]  
Lab Technician
RankRankRankRank
Total Posts:  1066
Joined  03-25-2005

Is it possible to remove an image if there is one in text?

thanks

 Signature 

BKDesign Solutions - Learn XHTML and use   Web Standards to build accessible websites that validate

Profile
 
 
   
 
 
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: 77559 Total Logged-in Users: 44
Total Topics: 101553 Total Anonymous Users: 32
Total Replies: 544388 Total Guests: 259
Total Posts: 645941    
Members ( View Memberlist )