Jump to:

324 Posts in 153 Topics by 156 members

Migrating a Site to Silverstripe

SilverStripe Forums » Migrating a Site to Silverstripe » Some questions for migrating

What you need to know when migrating your existing site to SilverStripe.

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

Page: 1
Go to End
Author Topic: 1792 Views
  • knarzer77
    Avatar
    Community Member
    3 Posts

    Some questions for migrating Link to this post

    Hi,

    i make my first steps with silverstripe by migrating a "hand-made"-website. Now I have some questions:

    (1) table prefix
    My webhoster supports only 1 mysql database. So I need for futher the table prefix. Does anybody know if and when the table prefixes come (to hack the MySQLDatabase.php is not nice)?

    (2) including external php-scripts
    At the moment I'm using different php-scripts (gallery, guestbook, wordpress blog, access to google calendar). Mostly i do a php-include to the scripts and ref the css-files in the accordingly template file. What is the best way to use these scripts in ss? (To set the $Layout variable would not be bad, but how?)
    Where is the best place for the css-files, which I only need in one file?

    (3) including javascript-code
    In some pages I'm using a little slideshow script, to show some pictures. For the script I have to ref some javascript-files and have to insert some special div-tags (which are replaced by the javascript). Can I do this in ss?

    (4) Global php-functions
    At the moment I have some php-functions, which I need at all place of the website (f.e. get the date of the latest wordpress-entry).
    How can I do this in ss (central class, ...)?

    regards
    Jan

  • UncleCheese
    Avatar
    4085 Posts

    Re: Some questions for migrating Link to this post

    (1) table prefix
    My webhoster supports only 1 mysql database. So I need for futher the table prefix. Does anybody know if and when the table prefixes come (to hack the MySQLDatabase.php is not nice)?

    ==> Don't believe this is available yet. I could be wrong, though.

    (2) including external php-scripts
    At the moment I'm using different php-scripts (gallery, guestbook, wordpress blog, access to google calendar). Mostly i do a php-include to the scripts and ref the css-files in the accordingly template file. What is the best way to use these scripts in ss? (To set the $Layout variable would not be bad, but how?)
    Where is the best place for the css-files, which I only need in one file?

    ==> Well, remember if you navigate to any .php file, it will execute. The .htaccess is not sensitive to files that actually exist. So you can always just break out of the CMS framework if you want. If you want to include it as a layout file, it's certainly an option to overload the layout method, but I might do it something like this:

    class MyCustomScriptPage extends Page
    {

    }
    class MyCustomScriptPage_Controller extends Page_Controller
    {
    function CustomScript()
    {
    ob_start();
    include('my_custom_script.php');
    $contents = ob_get_contents();
    ob_end_fush();
    return $contents;
    }
    }

    Then create a CustomScriptPage in the CMS.

    then in your /templates/Layout/MyCustomScriptPage.ss

    $CustomScript

    (3) including javascript-code
    In some pages I'm using a little slideshow script, to show some pictures. For the script I have to ref some javascript-files and have to insert some special div-tags (which are replaced by the javascript). Can I do this in ss?

    ==> In the controller for the page type:

    function init()
    {
    parent::init();
    Requirements::javascript('mysite/javascript/my_javascript.js');
    Requirements::css('mysite/css/my_css.css');
    }

    of course, if you want it globally on every page, just augment the init() method in Page_Controller.

    (4) Global php-functions
    At the moment I have some php-functions, which I need at all place of the website (f.e. get the date of the latest wordpress-entry).
    How can I do this in ss (central class, ...)?

    ==> Most people just add these methods to the Page or Page_Controller class.

  • knarzer77
    Avatar
    Community Member
    3 Posts

    Re: Some questions for migrating Link to this post

    Hi UncleCheese,

    thank you for your very good answers. I will try it.

    Jan

  • knarzer77
    Avatar
    Community Member
    3 Posts

    Re: Some questions for migrating Link to this post

    Hi UncleCheese,

    i have a problem with the php-include. I have:

    class Gallery extends Page
    {

    }
    class Gallery_Controller extends Page_Controller
    {
    function Content() {
    ob_start();
    include ('mysite/phpinc/twg2/index.php');
    $contents = ob_get_contents();
    ob_end_flush();
    return $contents;
    }
    }

    But nothing is rendered. When I replace "return $contents" with for instance "return '123'", than 123 is shown.
    So I think it's maybe a problem with the path "mysite/phpinc/twg2/index.php". I tried something, but nothing works.

    Any tipp?

    Jan

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