Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

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

dynamic cms sitetree icon


Go to End
Reply

15 Posts   2984 Views

Avatar
keeny

10 June 2010 at 12:21pm Community Member, 48 Posts

Hi all,

I know that you can customise the cms page tree using statics such as:

// tree customisation
static $icon = "mysite/images/icons/my-pretty-icon";

Is it possible to make the icon dynamic - either using a function icon() or maybe setting it on an event (page saved, etc)?

Basically under the behaviour tab I want to have a checkbox that affects the icon.

Thanks a lot!

Barry

Avatar
drye

22 September 2010 at 5:24pm Community Member, 49 Posts

I have the same question as Keeny. Anyone know if this is possible?

Avatar
Willr

22 September 2010 at 6:30pm Forum Moderator, 5511 Posts

You may be able to overload the default static using Object::set_static('PageType', 'icon', 'path/to/icon.png'); see the set static docs for more info. Not sure if it'll work but its worth a try.

http://api.silverstripe.org/2.4/sapphire/core/Object.html#methodset_static

Avatar
Lukin

29 September 2010 at 10:06pm Community Member, 42 Posts

have found a solution for changing the icon?

Avatar
Devis

1 November 2010 at 2:57am Community Member, 4 Posts

using Object::set_static() partially works but it still search for a GIF file, e.g.

Object::set_static('news', 'icon', 'themes/mysite/icons/news.png');

results in

url("themes/mysite/icons/news.png-file.gif")

Avatar
Martijn

1 November 2010 at 3:25am Community Member, 271 Posts

You dont need the file part:

Object::set_static('ErrorPage', 'icon', 'mysite/images/icons/error');

Avatar
Invader_Zim

1 November 2010 at 4:49am Community Member, 141 Posts

^^ thats right, but you end up using .gif icons anyway.

I posted a possible enhancement ticket to use .png icons: [url]http://open.silverstripe.org/ticket/6155[/url]

Please tell me what you think about it. Maybe there is still a better way to use .png icons ...

Cheers,
Christian

Avatar
Devis

1 November 2010 at 9:01am (Last edited: 1 November 2010 9:01am), Community Member, 4 Posts

Christian that seems a reasonable solution, the extension shouldn't have been hard coded.

Go to Top