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.

Migrating a Site to Silverstripe /

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

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

Some questions for migrating


Go to End


4 Posts   3135 Views

Avatar
knarzer77

Community Member, 3 Posts

6 January 2009 at 4:25am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

6 January 2009 at 5:01am

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

Avatar
knarzer77

Community Member, 3 Posts

6 January 2009 at 7:56am

Hi UncleCheese,

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

Jan

Avatar
knarzer77

Community Member, 3 Posts

6 January 2009 at 10:07am

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