Skip to content

Instantly share code, notes, and snippets.

@chocnut
Created September 17, 2012 03:23
Show Gist options
  • Save chocnut/3735394 to your computer and use it in GitHub Desktop.
Save chocnut/3735394 to your computer and use it in GitHub Desktop.
SilverStripe HTMLText Extension
<?php
class CustomTextExtension extends Extension {
public function Paragraph($count){
$doc = new SS_HTMLValue($this->owner->value);
$content = $doc->getElementsByTagName('p');
$current = 0;
foreach($content as $p){
++$current;
if($x == $count)
return $p->nodeValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment