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.

Template Questions /

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

Set image width in SiteConfig

Go to End

3 Posts   1145 Views


Community Member, 15 Posts

17 October 2011 at 7:47am

I tried to control templates main image width by customizing SiteConfig and added there data field for number. Now I'd like to read this number in template like this:

<div class="MainImage">$MainImage.SetWidth($SiteConfig.MainImageMaxWidth)</div>

But, that does not seem to work. My CustomSiteConfig goes like this:

	class CustomSiteConfig extends DataObjectDecorator {
		function extraStatics() {
			return array(
				'db' => array(
				'MainImageMaxWidth' => 'Int',
	public function updateCMSFields(FieldSet &$fields) {
        $fields->addFieldToTab("Root.Main", new TextField('MainImageMaxWidth', _t('SiteConfig.MAXMAINIMAGEWIDTH','Set maximum width for main image in template')));


What I did wrong?


Community Member, 15 Posts

18 October 2011 at 4:15am

I found another post from forum:

I think I have a same kind of problem: can not use variables...


Forum Moderator, 1848 Posts

18 October 2011 at 4:57am

And this is my stock answer to using a variable as a param...