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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

SS3 SiteConfig Problems on /dev/build


Go to End


4 Posts   2537 Views

Avatar
danzzz

Community Member, 175 Posts

8 October 2012 at 2:51am

Edited: 08/10/2012 3:22am

hi,

I use this CustomSiteConfig.php

<?php
 
class CustomSiteConfig extends DataExtension {
     
    static $db = array(
        'FooterContent' => 'HTMLText'
    );
 
    public function updateCMSFields(FieldList $fields) {
        $fields->addFieldToTab("Root.Main", new HTMLEditorField("FooterContent", "Footer Content"));
    }
    
}

Then on /dev/build:

[User Error] Couldn't run query: SELECT DISTINCT "SiteConfig"."ClassName", "SiteConfig"."Created", "SiteConfig"."LastEdited", "SiteConfig"."Locale", "SiteConfig"."Title", "SiteConfig"."Tagline", "SiteConfig"."Theme", "SiteConfig"."CanViewType", "SiteConfig"."CanEditType", "SiteConfig"."CanCreateTopLevelType", "SiteConfig"."FooterContent", "SiteConfig"."ID", CASE WHEN "SiteConfig"."ClassName" IS NOT NULL THEN "SiteConfig"."ClassName" ELSE 'SiteConfig' END AS "RecordClassName" FROM "SiteConfig" WHERE ("Locale" = 'de_DE') LIMIT 1 Unknown column 'SiteConfig.FooterContent' in 'field list'

Whats wrong here?

Object::add_extension('SiteConfig', 'CustomSiteConfig');

in _config.php is set.

Shouldnt /dev/build create the new Column? The new column conatins in the query, thats wrong.

If I create the column before runing /dev/build no errors occure.

Avatar
martimiz

Forum Moderator, 1391 Posts

10 October 2012 at 5:37am

Hi Danzzz,

I just copied and replayed your code (needed something like it anyway ) and for me it worked fine... Went as far as switching to German :)

I hope it's something trivial after all...

Avatar
Lamin Barrow

Community Member, 22 Posts

8 March 2015 at 3:42am

I have had a similar issue today and in the end, i found out that i have some code that was extending the "Controller" class and in it, i have some code that was referring "SiteConfig" in the "afterInit" method . The controller class get called in the dev/build process and at that point your siteconfig dataextension tables have not been created yet.

TO fix it, i simply change my code to extend "ContentController" instead of the base "Controller" and the issue was solved. Try that and it might help.

Avatar
helenclarko

Community Member, 166 Posts

9 March 2015 at 2:19pm

Hi Danzzz,

Try the following in your _config.php.

SiteConfig::add_extension('CustomSiteConfig');

Although this shouldnt make a difference, its what I have used and is working for me.

The other thing I believe could be an issue, you dont seem to be returning anything from your updateCMSFields.
I'm not sure if this is an issue, but it may explain your error.

<?php
 
class CustomSiteConfig extends DataExtension {
     
    private static $db = array(
        'FooterContent' => 'HTMLText'
    );
 
    public function updateCMSFields(FieldList $fields) {
        $fields->addFieldToTab("Root.Main", new HTMLEditorField("FooterContent", "Footer Content"));
        return $fields; //Add this!
    }
    
}

Then run /dev/build?flush=1

Good luck
-helenclarko