Plugin: Summary
Posted: 08 February 2010 02:23 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  11-16-2007

This plugin will take a block of text and only return the first line (e.g. everything before a newline/return). It’s useful for showing summaries/excerpts from blog entries or on EE search result pages where you don’t have an exceprt/summary field already setup. HTML is not stripped out either.

Usage is simply:

{exp:summary}
    Text to be processed
{
/exp:trim_title}

An example would be as follows:

{exp:summary}
    
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent nulla mauris, pharetra ac iaculis at, aliquet id diam.</p>
    <
p>Suspendisse sem massa, lacinia ac auctor at, fermentum sed arcu. Quisque lobortis porta neque, ut venenatis magna feugiat vitae.</p>
    <
p>Mauris vehicula semper accumsan. Proin mollis enim nec enim adipiscing congue. Vestibulum vitae iaculis odio. Ut tincidunt, dolor quis volutpat accumsan, ante massa feugiat nisl, vitae pulvinar leo ipsum at purus.</p>
{/exp:trim_title}

What would be returned is this:

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent nulla mauris, pharetra ac iaculis at, aliquet id diam.</p>

You can also specify how many lines to return by flagging the returns parameter:

{exp:summary returns="2"}
    
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent nulla mauris, pharetra ac iaculis at, aliquet id diam.</p>
    <
p>Suspendisse sem massa, lacinia ac auctor at, fermentum sed arcu. Quisque lobortis porta neque, ut venenatis magna feugiat vitae.</p>
    <
p>Mauris vehicula semper accumsan. Proin mollis enim nec enim adipiscing congue. Vestibulum vitae iaculis odio. Ut tincidunt, dolor quis volutpat accumsan, ante massa feugiat nisl, vitae pulvinar leo ipsum at purus.</p>
{/exp:summary}

...will return the following:

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent nulla mauris, pharetra ac iaculis at, aliquet id diam.</p>
<
p>Suspendisse sem massa, lacinia ac auctor at, fermentum sed arcu. Quisque lobortis porta neque, ut venenatis magna feugiat vitae.</p>

If you leave out the returns parameter, it will default to only return the first line.

You can download the latest version here:

http://ee.cwhapps.com/plugins/summary/latest.zip

File Attachments
summary-1.0.1.zip  (File Size: 1KB - Downloads: 14)
 Signature 

Crucial Web Hosting
Ready To Split-Shared Hosting?

Profile
 
 
Posted: 08 February 2010 07:32 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  420
Joined  08-31-2004

You guys are awesome. It’s especially nice to have some ‘free’ 2.X addons .... thanks for being so generous with all your work.

 Signature 

Bloodred theme for 2.0 CP

Profile
 
 
Posted: 10 February 2010 03:13 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  75
Joined  09-15-2008

This looks great. Any possibility of having a parameter to for the number of retunrs? i.e. returns=“1” would be the default, but if you want to include two paragraphs, you could do returns=“2”.

 Signature 

Jim Arment
http://jarment.com · http://canyoncreekonline.com

Profile
 
 
Posted: 10 February 2010 03:31 PM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  11-16-2007

@JArment: Done. Usage is as follows:

{exp:summary returns="2"}
    
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent nulla mauris, pharetra ac iaculis at, aliquet id diam.</p>
    <
p>Suspendisse sem massa, lacinia ac auctor at, fermentum sed arcu. Quisque lobortis porta neque, ut venenatis magna feugiat vitae.</p>
    <
p>Mauris vehicula semper accumsan. Proin mollis enim nec enim adipiscing congue. Vestibulum vitae iaculis odio. Ut tincidunt, dolor quis volutpat accumsan, ante massa feugiat nisl, vitae pulvinar leo ipsum at purus.</p>
{/exp:summary}

...will return the following:

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent nulla mauris, pharetra ac iaculis at, aliquet id diam.</p>
<
p>Suspendisse sem massa, lacinia ac auctor at, fermentum sed arcu. Quisque lobortis porta neque, ut venenatis magna feugiat vitae.</p>

If you leave out the returns parameter, it will default to only return the first line.

 Signature 

Crucial Web Hosting
Ready To Split-Shared Hosting?

Profile
 
 
Posted: 11 February 2010 11:57 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  75
Joined  09-15-2008

Sweetness! Thanks!

 Signature 

Jim Arment
http://jarment.com · http://canyoncreekonline.com

Profile
 
 
Posted: 12 February 2010 05:40 PM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  66
Joined  06-27-2009

Thanks for the awesome plugin! I am however having a problem getting it to work. When I try to call the plugin, I am getting the following error:

A PHP Error was encountered

Severity
: Notice

Message
: Trying to get property of non-object

Filename
: summary/pi.summary.php

Line Number
: 17

Fatal error
: Call to a member function fetch_param() on a non-object in /home/juser/site_system/expressionengine/third_party/summary/pi.summary.php on line 18

Any ideas of what is going on here?

Profile
 
 
Posted: 12 February 2010 05:51 PM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  11-16-2007

@Jerman:

Could you please let me know what version you are using and paste the EE code? Thank you!

 Signature 

Crucial Web Hosting
Ready To Split-Shared Hosting?

Profile
 
 
Posted: 12 February 2010 05:53 PM   [ Ignore ]   [ # 7 ]  
Grad Student
Rank
Total Posts:  66
Joined  06-27-2009

Sure. I am running version v2.0.1pb01 - Build:  20100121

The code is:
{exp:summary}{body}{/exp:summary}

I of course tried it with sample text as well, same problem.

Profile
 
 
Posted: 12 February 2010 05:59 PM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  11-16-2007

Thanks. This has only been tested on 1.6.8, but I’ll get my 2.x copy up and get back to you shortly. Thank you for the heads up!

 Signature 

Crucial Web Hosting
Ready To Split-Shared Hosting?

Profile
 
 
Posted: 12 February 2010 06:05 PM   [ Ignore ]   [ # 9 ]  
Grad Student
Rank
Total Posts:  66
Joined  06-27-2009

No prob. Sorry for misunderstanding about the version #. Someone above mentioned 2.x so I thought it meant this was a 2.x plugin. smile Thanks again, can’t wait for the proper version!!

Profile
 
 
Posted: 06 March 2010 09:45 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  438
Joined  05-15-2007

Hi there,

Thanks for this plugin, it looks really useful as it will save me having to bother with separate ‘summary’ and ‘body’ fields! smile

I have one request though - is there any chance you can add a ‘skips’ or similarly named parameter that would literally skip the first x number of lines and then output the rest of the content?

I’m thinking that this could be useful on article-like pages.  For example, I have a single field called ‘Content.’  In order to get my first line summary, I use your plugin around my ‘Content’ field and I will also style this line differently as it’s an introduction paragraph. Then I’ll repeat the same ‘Content’ field but my problem is that it’ll repeat the first line again. So this ‘skips’ parameter would allow me to enter a value of 1, and it’d then output the entire field contents after skipping the first line.

Also, I originally downloaded this from Devot-ee and noticed that the download link there links to the 1.0.0 version so you might want to update this for anyone who doesn’t see this forum thread.

Thanks.

 Signature 

 
Stephen McIver | Zest Web Design | Merseyside, UK | Twitter

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 1743, on December 02, 2009 02:47 PM
Total Registered Members: 119162 Total Logged-in Users: 69
Total Topics: 125503 Total Anonymous Users: 35
Total Replies: 660652 Total Guests: 305
Total Posts: 786155    
Members ( View Memberlist )