eventsmanager

Excerpt Length

Feb 25th, 2013
143
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. This snippet will override placeholder #_EXCERPT which will
  3. limit the event details to 120 characters with read more link.
  4. */
  5. add_filter('em_event_output_placeholder','my_em_styles_placeholders',1,3);
  6. function my_em_styles_placeholders($replace, $EM_Event, $result){
  7.     switch( $result ){
  8.         case '#_EXCERPT':
  9.  
  10.         $maxchars = 120;
  11.         $text = $replace;
  12.  
  13.         if(strlen($text) > $maxchars) {
  14.                 $text = substr($text, 0, $maxchars);
  15.                 $position = strrpos($text, " ");
  16.                 if($position > 0) {
  17.                     $text = substr($text, 0, $position);
  18.                 }
  19.                 return $text.'...<a href="'.$EM_Event->output('#_EVENTURL').'" class="eventreadmore">Read More...</a>';
  20.         }          
  21.  
  22.         break;
  23.     }
  24.     return $replace;
  25. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×