Plugin: Summary
Posted: 08 February 2010 03:23 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  51
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 ametconsectetur adipiscing elitPraesent nulla maurispharetra ac iaculis ataliquet id diam.</p>
    <
p>Suspendisse sem massalacinia ac auctor atfermentum sed arcuQuisque lobortis porta nequeut venenatis magna feugiat vitae.</p>
    <
p>Mauris vehicula semper accumsanProin mollis enim nec enim adipiscing congueVestibulum vitae iaculis odioUt tinciduntdolor quis volutpat accumsanante massa feugiat nislvitae pulvinar leo ipsum at purus.</p>
{/exp:trim_title} 

What would be returned is this:

<p>Lorem ipsum dolor sit ametconsectetur adipiscing elitPraesent nulla maurispharetra ac iaculis ataliquet 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 ametconsectetur adipiscing elitPraesent nulla maurispharetra ac iaculis ataliquet id diam.</p>
    <
p>Suspendisse sem massalacinia ac auctor atfermentum sed arcuQuisque lobortis porta nequeut venenatis magna feugiat vitae.</p>
    <
p>Mauris vehicula semper accumsanProin mollis enim nec enim adipiscing congueVestibulum vitae iaculis odioUt tinciduntdolor quis volutpat accumsanante massa feugiat nislvitae pulvinar leo ipsum at purus.</p>
{/exp:summary} 

...will return the following:

<p>Lorem ipsum dolor sit ametconsectetur adipiscing elitPraesent nulla maurispharetra ac iaculis ataliquet id diam.</p>
<
p>Suspendisse sem massalacinia ac auctor atfermentum sed arcuQuisque lobortis porta nequeut 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: 115)
 Signature 

Crucial Web Hosting
Ready To Split-Shared Hosting?

Profile
 
 
Posted: 08 February 2010 08:32 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  484
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.

Profile
 
 
Posted: 10 February 2010 04:13 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  151
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 04:31 PM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  51
Joined  11-16-2007

@JArment: Done. Usage is as follows:

{exp:summary returns="2"}
    
<p>Lorem ipsum dolor sit ametconsectetur adipiscing elitPraesent nulla maurispharetra ac iaculis ataliquet id diam.</p>
    <
p>Suspendisse sem massalacinia ac auctor atfermentum sed arcuQuisque lobortis porta nequeut venenatis magna feugiat vitae.</p>
    <
p>Mauris vehicula semper accumsanProin mollis enim nec enim adipiscing congueVestibulum vitae iaculis odioUt tinciduntdolor quis volutpat accumsanante massa feugiat nislvitae pulvinar leo ipsum at purus.</p>
{/exp:summary} 

...will return the following:

<p>Lorem ipsum dolor sit ametconsectetur adipiscing elitPraesent nulla maurispharetra ac iaculis ataliquet id diam.</p>
<
p>Suspendisse sem massalacinia ac auctor atfermentum sed arcuQuisque lobortis porta nequeut 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 12:57 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  151
Joined  09-15-2008

Sweetness! Thanks!

 Signature 

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

Profile
 
 
Posted: 12 February 2010 06:40 PM   [ Ignore ]   [ # 5 ]  
Lab Assistant
RankRank
Total Posts:  102
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 06:51 PM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  51
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 06:53 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
RankRank
Total Posts:  102
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 06:59 PM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  51
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 07:05 PM   [ Ignore ]   [ # 9 ]  
Lab Assistant
RankRank
Total Posts:  102
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 10:45 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  464
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 | Made by Bridge | Liverpool, UK | Twitter

Profile
 
 
Posted: 18 March 2010 05:22 PM   [ Ignore ]   [ # 11 ]  
Lab Assistant
RankRank
Total Posts:  102
Joined  01-29-2010

Wow, this doesn’t work for me at all unfortunately.  :(

After installing, my plug-in manager is all messed up. This shows up on the top of the page, looks like a PHP message:

'Summary''pi_version' => '1.0.1''pi_author' => 'Kyle Anderson''pi_author_url' => 'http://www.crucialwebhost.com/''pi_description' => 'Grabs the first line or paragraph from a block of text.''pi_usage' => Summary::usage() ); class Summary { var $return_data ''; function Summary() global $TMPL$text $TMPL->tagdata$returns $TMPL->fetch_param('returns'); if(!$returns || $returns == 1{ preg_match('/^(.*)/'$text$matches); $this->return_data $matches[1]else { $lines preg_split('/\r\n|\r|\n/'$text, ($returns 1)); $return ''; for($i 0$i < ($returns); ++$i{ $return .= $lines[$i]} $this->return_data $return} } function usage() { ob_start(); ?> This plugin will take a block of text and only return the first line (e.geverything 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 setupHTML is not stripped outThe following will return only the first line before a return is met{exp:summary} text you want processed {/exp:summary} If you want to return more than one line, do the following{exp:summary returns="3"} text you want processed {/exp:summary} Which will return the first three (3lines

Summary does not show up in the plug-in list, but it does create a second instance of another plug-in in the list.

I tried using the {exp:summary} code on my page but all it did was delete the whole design and replace it with the code above. I’m very surprised!

I’m on Build:  20100121 of 1.6.8, BTW. I’m sure it’s something odd, sounds like a great plug-in.

Jeremy

Profile