Jump to:

23367 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » assets error b/o class named folder

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

Page: 1
Go to End
Author Topic: 1533 Views
  • yurigoul
    Avatar
    Community Member
    202 Posts

    assets error b/o class named folder Link to this post

    I already solved the problem, but it brings back a question about naming conventions:

    I created a class named 'folder extends Page' with a nice folder icon in order to store some pages there that are not visible in the site directly (footer-content etc). And then I ran into the following error when accessing assets in the backend:

    [User Error] Couldn't run query: SELECT `File`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` WHERE (`SiteTree`.`ID` = 1) AND (`File`.ClassName IN ('Folder')) ORDER BY Name LIMIT 1 Unknown column 'SiteTree.ID' in 'where clause'
    GET /_s/admin/assets/

    Line 401 in /Users/yurigoul/Sites/_s/sapphire/core/model/MySQLDatabase.php

    Removing the folder-class and giving a dev/build removes the problem.

    Here is my folder-class for those who are in doubt (and my file in ./mysite/code was called folder.php):

    <?php
    class folder extends Page {
    static $db = array(
       );
    public static $has_one = array(
       );
       static $icon = "themes/annomedia/images/icons/folder";
    }

    class folder_Controller extends Page_Controller {
       public function init() {
          parent::init();

       }
    }
    ?>

    Also my question is: what names should I not use, or what else did I do wrong?

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: assets error b/o class named folder Link to this post

    SilverStripe already has a Folder class in the core. By creating your own you are effectively override it, which leads to errors as yours would conflict and has wildly different functionality.

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: assets error b/o class named folder Link to this post

    Exactly what I was thinking, but the real question is: what are names I should not use for classes. I could not find a list or so. Or is the general guideline I should use Page at the end of every class name?

    Another thing is that I used 'folder' with a lowercase and the error is because of a class named 'Folder' with uppercase.

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: assets error b/o class named folder Link to this post

    That is one way to get around it. Also, PHP is case insensitive except for variable names.

  • rbquirke
    Avatar
    Community Member
    70 Posts

    Re: assets error b/o class named folder Link to this post

    As a convention, I generally use whatever my project name is as the start of my custom classes to avoid conflict so:
    AcmeRecruitFolder
    AcmeRecruitAdmin

    etc

    This avoids your problem without trying to consult a list of possible classes already in use.

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: assets error b/o class named folder Link to this post

    Thanks for the answers.

    But the main reason why I ask this question - and in the future I might be asking similar questions - is because I have this sense that certain things are missing from the manual section. I have the feeling that the manual section contains just enough to get you going, but certain very important details are very hard to find.

    One of the reasons is that the search function in doc.silverstripe.org is really bad: if you for instance search for DataObject::get I am under the impression you get a result for 'dataobject' OR 'get'

    Another reason is that a lot of items are just place holders with links to the api page. This might work for experienced programmers and for people who are working with the cms a long time, but for someone whose main interest is creating themes it is hard to get a firm grip on the subject. Sometimes there are even links to nonexistant items, like http://doc.silverstripe.org/doku.php?id=silverstripe-tutorial or http://doc.silverstripe.com/doku.php?id=devmode. Thes links come up during the install. (I will make a ticket for these)

    And in general I think it is a good thing there are a bunch of links in the index of doc.silverstripe.com, but I have the feeling it could be better and that it is incomplete.

    I might be volunteering to do something in that section, but not before I have a better insight in the material. Hence a question like this.

    Thank you for your time

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