Jump to:

3432 Posts in 1025 Topics by 865 members

Template Questions

SilverStripe Forums » Template Questions » How to include HTML in Navigation Label

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 3625 Views
  • comfixit
    Avatar
    Community Member
    3 Posts

    How to include HTML in Navigation Label Link to this post

    I am trying to create a navigation effect similar to http://www.SimpleBits.com

    They seem to place HTML in their navigation elements.

    The problem is that the Navigation Label seems to insist on sanitizing the text entered and as a result when I put my HTML in the Navigation Label it outputs the escaped codes rather then what I am intending when I display $MenuTitle.

    Is there a different variable that will display the value without substituting what I entered?

  • comfixit
    Avatar
    Community Member
    3 Posts

    Re: How to include HTML in Navigation Label Link to this post

    I was able to work around this by going into /sapphire/core/model/SiteTree.php, line 65 and change the MenuTitle attribute from Varchar(100) which does not seem to allow HTML characters to HTMLVarchar(100) which works like a charm.

    Any chance we could open a discussion about making this a permanent change?

    If you think about it the MenuTitle is meant to be displayed within the confines of an HTML page so being able to include HTML tags (although a bit unorthodox) should be permitted. If a person needs to put in a special character they can utilize the HTML escape code for that.

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: How to include HTML in Navigation Label Link to this post

    How about adding a new variable to the CMS/db?

    like a $SubTitle or something...

    You could then create you navigation html in the templates - where it belongs imho - with $MenuTitle and $SubTitle...

  • comfixit
    Avatar
    Community Member
    3 Posts

    Re: How to include HTML in Navigation Label Link to this post

    Dio5

    So if I am understanding what you are suggesting correctly I should extend the model in a similar manner as is done in the second tutorial and place the code in there?

  • ianski
    Avatar
    Community Member
    2 Posts

    Re: How to include HTML in Navigation Label Link to this post

    Have you tried in the relevant *.ss template file, using .RAW e.g.

    $MenuTitle.RAW

    It might well do what you need...

  • krzepa
    Avatar
    Community Member
    5 Posts

    Re: How to include HTML in Navigation Label Link to this post

    Ok, so is there any easy way to get html in MenuTitle without changing SiteTree or adding additional field?

    3625 Views
Page: 1
Go to Top

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

Comments on this website? Please give feedback.