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 contact fields


Reply


3 Posts   200 Views

Avatar
petokavva

Community Member, 2 Posts

1 May 2014 at 10:15pm

Hi all,

I would like to ask you a very basic question. I wanted to make tab 'contacts' in admin page edit where will be everything. From phone numbers, address, to social links. It works like a charm, even in templates I used <% if $Twitter, etc..
But then I found that what I put in is tied to one page, based on page ID. But, I would like to have those contacts as global var, so I can set them once (admin frontend update required) and have them available across all pages, includes, etc..
How to do it properly? Or do I have to make some contact module for it?

Thank you

Avatar
martimiz

Forum Moderator, 1106 Posts

4 May 2014 at 9:03pm

Edited: 04/05/2014 9:03pm

That is where the SiteConfig class comes in - see the Settings menuitem in the left menubar. Here you can add your sitewide settings. The way to do that is create a DataExtension for the SiteConfig, and access its properties from the template as $SiteConfig.SomeProperty. The Silverstripe docs will tell you more:

http://doc.silverstripe.org/framework/en/reference/siteconfig

Avatar
petokavva

Community Member, 2 Posts

4 May 2014 at 10:09pm

Hi martimiz,

can it be that easy? :) I followed instructions on that link you posted and solved it in five minutes.
Thank you very much for your help. Now it works across whole page and its nicely wrapped in settings.

Thanks, have a nice day