Mango



Thread: Difference getPageContent & getPageExcerpt

Created on: 02/08/12 02:43 PM

New topic Reply    Page: 1  

Replies: 5
bph


bph's Gravatar
Joined: 02/05/10
Posts: 22

02/08/12 2:43 PM

How do I make a plugin that works for the event getPageContent also work for the getPageExcerpt.

Example: Using Seb's YouTube plugin.

Here is the handler code:
<cfif eventName EQ "postGetContent" OR eventName EQ "pageGetContent" OR eventName EQ "postGetExcerpt" OR eventName EQ "pageGetExcerpt">

            <cfset data = arguments.event.accessObject />         

         

            <cfloop condition="noMoreMatches is false">

               <cfset match = refindnocase("\[youtube:([-_[:alnum:]]+)\]", data.content, 1, true) />

                           

               <cfif match.len[1] eq 0>

                  <cfset noMoreMatches = true />

               <cfelse>

                  <cfset fullTag = mid(data.content, match.pos[1], match.len[1]) />

                  <cfset videoId = mid(data.content, match.pos[2], match.len[2]) />

                  

                  <cfsavecontent variable="embedCode"><cfoutput><iframe width="550" height="373" src="http://www.youtube.com/embed/#videoId#?rel=0" frameborder="0" allowfullscreen></iframe></cfoutput></cfsavecontent>

                  <cfset data.content = replace(data.content, fullTag, embedCode, "all") />

               </cfif>

            </cfloop>

         </cfif>

The only change I made was adding the events pageGetExcerpt and postGetExcerpt to the cfif condition and added them to the plugin.xml

In theory that should work out of the box. It doesn't produce any error in the LogViewer.
It just doesn't seem to execute...

How could I troubleshoot this?

Link:
Full post - Video showing
http://www.igiftedschool.org/post.cfm/launch-of-beta-test-for-debate-club

Excerpt view - Video no showing
http://www.igiftedschool.org/archives.cfm/category/virtual-debate-club
online developer & strategist 4 small business & nonprofits. presents on all-things online. astro-nut. Follow @bph
Link | Top | Bottom
Laura

Wizard
Laura's Gravatar
Joined: 01/29/05
Posts: 1521

02/08/12 2:45 PM

You also need to register the plugin to listen to that event from the plugin.xml file.
Link | Top | Bottom
bph


bph's Gravatar
Joined: 02/05/10
Posts: 22

02/08/12 2:57 PM

Thanks, Laura!

Did that already. No change.
<listens>

<event name="pageGetContent" type="synch" priority="5" />

<event name="postGetContent" type="synch" priority="5" />

<event name="postGetExcerpt" type="synch" priority="5" />

<event name="pageGetExcerpt" type="synch" priority="5" />

</listens>
online developer & strategist 4 small business & nonprofits. presents on all-things online. astro-nut. Follow @bph
Link | Top | Bottom
Laura

Wizard
Laura's Gravatar
Joined: 01/29/05
Posts: 1521

02/08/12 3:00 PM

The plugin is looking for and changing the data.content. That is the body of the post. You would need to specifically look into and change data.excerpt for the excerpt.
Link | Top | Bottom
bph


bph's Gravatar
Joined: 02/05/10
Posts: 22

02/08/12 9:54 PM

That works indeed! Thank you so much! Now I also know why other plugins don't work in excerpt... ie. linkify, colorcoding...

That's an easy fix!
online developer & strategist 4 small business & nonprofits. presents on all-things online. astro-nut. Follow @bph
Link | Top | Bottom
bph


bph's Gravatar
Joined: 02/05/10
Posts: 22

02/08/12 10:31 PM

The updated Version of the YouTube Plugin (1.2) is available on my blog: idxTools
http://goo.gl/mm39L

Thank you to Laura Arguello for helping out on the excerpt problem and Seb Duggan for creating the first version.

Please post comments or questions there.
online developer & strategist 4 small business & nonprofits. presents on all-things online. astro-nut. Follow @bph
Link | Top | Bottom

New Post

Please login to post a response.