Jump to:

3435 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » Set image width in SiteConfig

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

Page: 1
Go to End
Author Topic: 814 Views
  • shrike
    Avatar
    Community Member
    15 Posts

    Set image width in SiteConfig Link to this post

    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:

    <?php

       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?

  • shrike
    Avatar
    Community Member
    15 Posts

    Re: Set image width in SiteConfig Link to this post

    I found another post from forum: http://www.silverstripe.org/template-questions/show/11731

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

  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    Re: Set image width in SiteConfig Link to this post

    And this is my stock answer to using a variable as a param...
    http://www.silverstripe.org/template-questions/show/13619#post290481

    814 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.