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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

"Global site info" question


Reply

5 Posts   1454 Views

Avatar
Karamba

22 February 2009 at 7:01am Community Member, 3 Posts

Hi, all.

I have a phone number in the head section and need it to be editable from cms. Now i have a text field with this field on content tab of HomePage. And i do sql query when i parse it in every page code.

Question: is there in SS special place for "global" fields as a phone in head section?

Avatar
Carbon Crayon

22 February 2009 at 8:43am Community Member, 598 Posts

Hi Karamba, welcome to Silverstripe :)

Unfortunately i don't think this is possible. I always though it would b great if you could add fields to the top 'Site Content' item on the site tree, but as far as I know there is no way to do that without going into the core files.

Of course you could always create a page type 'Global content', but then as far as I know you cant set a limit on the number of a certain page type is created so a user could create a number of these pages and potentially screw things up.

Avatar
Nathan Cox

23 February 2009 at 1:34pm Community Member, 99 Posts

My solution here was to make a module that puts a "Site Settings" item in the CMS main menu. In there I had a form that saves everything to Site Setting data objects, and made a Page_Controller decorator that fetches them for use in the templates. I used it to set things like contact details, "global" meta data, taglines and whatnot.

I think it would make alot more sense to have a settings page like that at the root of the Site Tree, from a user point of view, but I had a look at the files there once and it didn't look like a fun thing to try hack.

Of course if you're using 2.3 you could manage settings with a ModelAdmin page but it's not a very user friendly interface for someone who just wants to set one or two variables.

Avatar
Karamba

24 February 2009 at 2:41am Community Member, 3 Posts

Thank you.

aram, its very sad that SS have no special solution for this task. I think that this functionality is required for big percent of sites.

Nathan, your solution was the first idea in my head. Unfortunately i am not so good in SS now for doing module by self hands.

P.S. The "Subscribe to this topic" checkbox not work for me. I don't receive mails about your posts.

Avatar
dospuntocero

7 December 2009 at 1:41am Community Member, 54 Posts

You can do a very simple trick.

create the $Phone field in the homepage in a tab called contact details for example and then in your templates use. Im assuming that the same phone will be showed in every page

<% control Page(home) %>
   $Phone
<% end_control %>

all your pages will be able to read the field