maybe place some code in the Page onbeforewrite that does a search replace to enter the space on $this->MyHTMLText
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)
Thanks, but that's not ideal because the code will vary depending on each video setting, and obviously I can't do a find & replace just on a self closing tag or it would affect other code.
I'm not recommending a blanket acceptance of self closing tags - a regular expression matching something like "<iframe*vimeo*></iframe>" and you'd be able to identify the specific self-closing tags that you want to keep.
Ah, I misunderstood. That works a treat, thanks!
function onBeforeWrite() {
$this->VimeoCode1 = str_replace("></iframe>", "> </iframe>", $this->VimeoCode1);
parent::onBeforeWrite();
}
I've found that doing this:
function onBeforeWrite() {
$this->Content = str_replace("></iframe>", "> </iframe>", $this->Content);
parent::onBeforeWrite();
}
doesn't work because the content has already been loaded into the object using domdocument so it's already collapsed the iframe. I've used this regexp instead:
function onBeforeWrite() {
$this->Content = preg_replace('|<iframe(.*)/>|Uims', '<iframe\\1> </iframe>', $this->Content);
parent::onBeforeWrite();
}
I just want to confirm Chris' solution works, thanks!
Spoke too soon, didn't help. Instead I'm just putting an ' ' inside the iframe tags...not a great solution.
If someone's still having the same problem: I tried Chris's solution with ttyl's input - didn't work. It still removes the closing tag.
What did it for me (2.4.7) was the post from dendeffe on Page 1 of this thread.
Change the field form a HTMLText to a Text and use $myfield.RAW in the template. That's it.
- Previous 10 entries
- 1
- Page 22(current)