Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

2479 Posts in 728 Topics by 538 members

Customising the CMS

SilverStripe Forums » Customising the CMS » escaping HTML tags in page title

Page: 1
Go to End
Author Topic: escaping HTML tags in page title 421 Views
  • Anatol
    avatar
    102 posts

    escaping HTML tags in page title Link to this post

    Hi,

    I'm looking for a way to allow escaped HTML tags in the page title. It's no problem to use $Title.XML in the template to escape the tags properly, but if I have a title like "<p> The Paragraph Tag" it confuses the site tree in the CMS. How can I escape HTML titles in the CMS site tree?

    I can enter "&lt;p&gt; The Paragraph Tag" into the navigation label field and it works - but it's always nice to have escapes done automatically. And this could also be a possible error source if a client uses a page title with a '<' or '>' character.

    Cheers!
    Anatol

  • aram
    avatar
    Community Member
    481 posts

    Re: escaping HTML tags in page title Link to this post

    Hi Anatol

    I think you could use onBeforeWrite() to escape the string using htmlentities() before writing, something like this:

    function onBeforeWrite(){

    $this->Title = htmlentities($this->Title);

    return Parent::onBeforeWrite();
    }

    Havn't tried it but something like that should work

    421 Views
Page: 1
Go to Top

Currently Online: CodeGuerrilla , Willr

Welcome to our latest member: jhstripe

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.