I have not Deklin - I was hoping that you would do this as you asked for a way without hacking silverstripe and decorators often are that way - I am very interested to implement, but not interested enough to do it dev it just yet - as it's on my list for "mobile must be faster" in the future :)
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
- Previous 10 entries
- 1
- Page 22(current)
I have tried to decorated the controller through a module but I don't have a clue what I am doing.
My code produces an error:
[Notice] Trying to get property of non-object
how about...
Object::add_extension('Page_Controller','ZapWhitespace');
instead of...
Object::add_extension('SiteTree', 'ZapWhitespace');
Thanks, swaiba.
That got us closer but there is still an error:
[Notice] Trying to get property of non-object
<?php
class ZapWhitespace extends Extension {
public function ZapWhitespace() {
$str = $this->owner->value;
$str = '<!-- Test-->'.preg_replace("/(?=\s\s)\s*?(\n)\s*|(\s)\s+/", "$1$2", trim($str)) . '<!-- Test-->';
return $str;
}
}
?>
right... this might be a little simpler :)
(note I haven't tried it with the regular expression - I don't use them unless I FULLY understand them - but I have tested that this gets you access to the body :) )
in your Page.php
class Page_Controller extends ContentController {
...
public function handleRequest(SS_HTTPRequest $request) {
$ret = parent::handleRequest($request);
$temp=$ret->getBody();
$temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $temp);
$ret->setBody($temp);
return $ret;
}
...
}
- Previous 10 entries
- 1
- Page 22(current)