23490 Posts in 18996 Topics by 2878 members
|Go to End|
30 September 2012 at 7:13am
Hoping there is an easy solution...
Using SilverStripe 3.0.2, and I'm trying to insert "Anchors" in to an HTMLEditorField. Something like <a name="anchor"></a>. However, when I save my page the tag ends up being converted to a self-closing <a> tag like this: <a name="anchor" />. This results in browsers thinking there's an unclosed tag on the page and causing some general bugginess.
Does anyone know what's happening here or how to prevent it? I think it's SilverStripe making this change and NOT TinyMCE (viewing the source in TinyMCE still shows separate opening and closing tags).
30 September 2012 at 8:13am
You may want to consider asking why you are doing this as there are likely better solutions. If you want to create the ability to link to parts of the page I would recommend adding ids (not names) to the elements you want to link to. I'm digging into my memory banks here but I seem to remember that a LONG time ago (maybe even as far as Netscape 3?) there were browsers that couldn't do internal page links to ids on elements and required and empty <a> element. Now you can just add an id to an element and link to it no problem.
1 October 2012 at 2:59am
Thanks Tim. I'm using anchors because that's what TinyMCE does and what my clients want. There's not an easy way to assign IDs to various headings using a WYSIWYG editor.
So, regardless of what's best... I still need to figure out how to prevent SS from making tags self-closing.
8 November 2012 at 8:00pm
this issue is solved in Silverstripe 3.0.3.
However if you need a quick fix:
Change this in HTMLValue.php Line 33: (HTMLValue::getContent())
return preg_replace (
|Go to Top|