Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Try to understand the background of the subsites module

Our old forums are still available as a read-only archive.

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

Page: 1 2
Go to End
Author Topic: 6300 Views
  • carnal
    Avatar
    Community Member
    19 Posts

    Try to understand the background of the subsites module Link to this post

    Hi everybody,

    can someone give me a little explanation of the logic behind the subsites module!?

    How will the content put into each subsite?

    How will the url control the access to each subsite?

    Where are the subsites stored physically?

    Thank you all.

    Carnal

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Try to understand the background of the subsites module Link to this post

    Hi Carnal,

    The subsites module changes the database in a few ways:

    * Adds a Subsite table
    * Adds a SubsiteID to the Group, File and SiteTree table.

    Each of the latter tables can therefore hold multiple sub-sites. The URL-uniqueness checker, for example, is updated to only check for unique URLs in a single subsite.

    The SiteTree content with SubsiteID = 0 is considered to be the 'default subsite'. Groups and Files with SubsiteID = 0 are considered to be accessible by all subsites.

    To create subsites, you should use the Subsites section of the CMS; it's a new main menu item that appears. If you give it a Subdomain, then you can access it. If you're working on a local development environment, a good thing to do is to set up some aliases in your /etc/hosts file so that you can access your local development environment with multiple aliases:

    localhost -> default site
    something.localhost -> site with Subsite.Subdomain = 'something'
    other.localhost -> site with Subsite.Subdomain = 'other'

    Within the CMS, a dropdown appears in the top-right, once you have more than one subsite. Use this to switch between subsites. The content, group, or file tree will update accordingly.

  • carnal
    Avatar
    Community Member
    19 Posts

    Re: Try to understand the background of the subsites module Link to this post

    Hi Sam,

    thanks for the info - now i know how it should work - but it do not at my installation.
    I don't know if you are in the mood to help me with a trunk-module, but this module would be very important for me to use.

    I have three problems:

    (1) After uploading the module, the installation is not accessible. After i commented these two lines in _config.php i can run "db/build?flush=1" and one Table "subsite" are created (should be another one created: "subsite_templates"?!).

    (2) I cannot choose a template at the "add-subsite-dialog"

    (3) I have to create the subsites manually in the db, because i get the error: Fatal error: Call to a member function createInstance() on a non-object

    (4) I don't get the dropdown at the top-right to select the created subsites.

    Thats all for now, hope to get info on this.

    Thanks.

    Carnal

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Try to understand the background of the subsites module Link to this post

    Hi Carnal,

    Try manually going into the database, and adding an entry in the Subsite table with ClassName = 'Subsite_Template'. This might fix the issue.

  • carnal
    Avatar
    Community Member
    19 Posts

    Re: Try to understand the background of the subsites module Link to this post

    Hi Sam,

    i have done this, now i can add subsites to silverstripe with no error message! Great.
    Now i have "just" another question, hope you don't mind ;-)

    (1)
    You wrote:
    Within the CMS, a dropdown appears in the top-right, once you have more than one subsite. Use this to switch between subsites. The content, group, or file tree will update accordingly.

    I don't get this dropdown, how can i fix this?! Because i have to switch between the sites to add pages etc. Maby i can call the urls manually?!

    Thanks again.

    Carnal

  • carnal
    Avatar
    Community Member
    19 Posts

    Re: Try to understand the background of the subsites module Link to this post

    Hi all,

    me again ;-)

    Has somebody a little hint about accessing the urls to each subsite in the Admin!?

    Thanks.

    Carnalito

  • ewonde
    Avatar
    Community Member
    2 Posts

    Re: Try to understand the background of the subsites module Link to this post

    Ok, searched this forum and Google from the back to the front on how to get this usefull module working.

    For now, after getting the SVN trunk of subsite to the root directory of my Silverstripe installation i get the same error over and over again when i try to run /db/build?flush=1:

    Fatal error: DataObject::buildSQL: Can't find data classes (classes linked to tables) for Subsite in /var/www/vhosts/lodown.nl/httpdocs/SilverStripeSite/sapphire/core/model/DataObject.php on line 1430

    I tried the hack of Carnal mentioned in his post at http://www.silverstripe.com/extending-hacking-silverstripe-forum/flat/37125?showPost=128586 and commented some lines out in the _config.php
    Greatfully the /db/build worked after applying his hack, but i got the feeling that the module doesn't install properly, isn't it? For example there are no changes made by the build process to the table Groups.

    So i ended up now with a big ? What do i have to do, to get the module installed properly on my Silverstripe 2.2.2 (a question i've read from quite a people on this forum ) ??? Any helping hand?

    For the record, i also found this post of Racc, which seems to have installed the module without any problems at all... how?? http://www.silverstripe.com/site-builders-forum/flat/127215

    [edit 15:26] Ok, found out that only the Object::add_extension('Group', 'GroupSubsites'); has to be commented out to get /db/build giving a positive result, so there should be the problem for me, anyone any idea where to look for?

    [edit 15:54] Well, added the column SubsiteID (int(11), not null default '0') to the table "groups" manually and added an index to it. Now i can remove the comment for Object::add_extension('Group', 'GroupSubsites'); and call the website without any errors.
    After entering the CMS i can't find the "subsites"-menu tab, so up to the next issue Any input on this one?

    [edit 03-08-08] After i searched for something like a rights problem i discovered that the daily build of Silverstripe had a bug concerning setting rights to groups (rights are set to groupID=0 instead of groupID= id group editted) i installed the latest stable download from the website, did the things above to get Subsites running and voila, "Sub-sites" appears into the CMS menu Can some explain how to assign templates to individual subsites?

    After i added a new subsite (my first), silverstripe crashes with an error:

    FATAL ERROR: DataObject::get_by_id passed a non-numeric ID #
    At line 1669 in /var/www/vhosts/lodown.nl/httpdocs/SilverStripeSite3/sapphire/core/model/DataObject.php
    user_error(DataObject::get_by_id passed a non-numeric ID #,512)
    line 1669 of DataObject.php
    DataObject::get_by_id(Subsite_Template,)
    line 101 of SubsiteAdmin.php
    SubsiteAdmin->addintranet(Array,Form)
    line 238 of Controller.php
    Controller->run(Array)
    line 104 of Director.php
    Director::direct(/admin/subsites/)
    line 158 of main.php
    Context
    Debug (Debug::showError() in line 180 of Debug.php)
    * callerClass =
    Subsite_Template
    * id =
    Fatal error: Call to a member function createInstance() on a non-object in /var/www/vhosts/lodown.nl/httpdocs/SilverStripeSite3/subsites/code/SubsiteAdmin.php on line 113

    Great, but after adding manually a record to Subsite like Sam discribed above, i'm able to successfully add more subsites and templates But, now the dropdown at the top right is missing, needed to switch the trees for the different subsites. I discovered that ?flush=1 or manually deleting the cache content located in /tmp does miracles, and in this case it did, the dropdown shows up

    I'm curious how to add different templates to the different subsites. The definition of "Template" within the module configuration is another one than "template" as the visualisation of your website, it's only a way to quickly create subsites from default settings.

    Sam and other users, how do i set the allowed_themes and allowed_domains for the module?

  • vstrazz
    Avatar
    Community Member
    63 Posts

    Re: Try to understand the background of the subsites module Link to this post

    This is how we did it...

    we added this in the controller of mysite/page.php

    if ($this->SubsiteID) {
    $subsite = DataObject::get_by_id("Subsite", $this->SubsiteID);
    SSViewer::set_theme($subsite->Theme);
    }


    and this in mysite/_config.php

    //Set the available sub site themes like so
    Subsite::set_allowed_themes(array('theme1', 'theme2'));

    theme1 and theme2 corresponding to theme folders with the same name.. Adding to this array, while adding new themes gives you the ability to change themes from the subsite admin menu.

    6300 Views
Page: 1 2
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.