EllisLab text mark
Advanced Search
1 of 2
1
   
Plugin: tag_limit
Posted: 08 May 2006 10:27 AM   [ Ignore ]
Avatar
Joined: 2006-03-22
575 posts

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>
<
class="foo">paragraph 1 with class foo</p>
<
p id="bar">paragraph 1 with id bar</p>
<
p>paragraph 2</p>
<
class="foo">paragraph 2 with class foo</p>
<
p id="bar">paragraph 2 with id bar</p>
<
p>paragraph 3</p>
<
class="foo">paragraph 3 with class foo</p>
<
p id="bar">paragraph 3 with id bar</p>
<
p>paragraph 4</p>
<
class="foo">paragraph 4 with class foo</p>
<
p id="bar">paragraph 4 with id bar</p>
<
p>paragraph 5</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

<class="foo">paragraph 3 with class foo</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: 746)
 Signature 

(a.k.a the_butcher)

 
Posted: 08 May 2006 11:35 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2005-01-05
115 posts

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.

 
Posted: 08 May 2006 11:53 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-22
575 posts
smallbeer - 08 May 2006 03:35 PM

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)

 
Posted: 25 October 2006 06:39 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-22
575 posts

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)

 
Posted: 06 March 2007 09:39 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-22
575 posts

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)

 
Posted: 07 March 2007 10:54 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-22
575 posts

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)

 
Posted: 01 January 2009 06:17 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

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 | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 01 January 2009 06:58 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-22
575 posts

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)

 
Posted: 01 January 2009 07:03 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

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 | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 01 January 2009 07:56 PM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

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 :

<class="test">Test paragraph 1</p>
<
class="test">Test paragraph 2</p>
<
p>Test paragraph 3</p>
<
class="test">Test paragraph 4</p>
<
p>Test paragraph 5</p>
<
p>Test paragraph 6</p>
<
p>Test paragraph 7</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 | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 02 January 2009 05:03 AM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2008-04-12
241 posts

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 

gridonic | Twitter


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

 
Posted: 02 January 2009 05:33 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

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 | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 19 January 2009 05:17 AM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2007-03-18
486 posts

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

Note: I used to be slapshotw on this forum.

 
Posted: 07 March 2009 05:04 PM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Joined: 2005-03-25
537 posts

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

 
Posted: 09 July 2009 07:53 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Joined: 2008-06-26
276 posts

Useful plugin! Thanks!

Quick question: is there a way to keep multiple tags (if I want to keep p, ol, ul tags, for example)?

 
Posted: 10 July 2009 11:26 AM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-22
575 posts

I’ll look into that request at some point. This plugin is still on my “2.0 convert” list. I’ll be honest with you though, and say that I can’t promise anything - honouring that request would likely add some significant bloat to the plugin, where other plugins might be better suited for your needs (none which come to mind, though)

 Signature 

(a.k.a the_butcher)

 
1 of 2
1