324 Posts in 153 Topics by 156 members
|Go to End|
8 September 2009 at 10:51am
I need the LegacyURL function for the site I am building. I took the code from the CD that came with the German SilverStripe handbook. But the code does not seem to have any effect. Here is what I found out so far:
1. There seems to be a LegacyURL field in the datastructure, even before I added the code.
2. After I added the code into page.php, _config.php and had set up CustomModelAsController.php, the field "Old URL" appears in the Backend after I did /db/build/?flush=1
3. When I enter e.g. "testtest.html" as LegacyURL in the Backend, and then call up that html file, if that file exist, it is displayed, if the file does not exist, the usual "Page not found" error message comes, but no redirection is done in eighther case.
4. The recipe says in mysite/code/page.php: $fields->addFieldsToTab('Root.Content.Main', new TextField('LegacyURL', 'Alte URL'));
but another line in my page.php is $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("Sidebar"));
Now is "addFieldToTab" correct or "addFieldsToTab" ?
(Note: I use SS 2.3.2 on a typical Suse LAMP System, my SS Installation runs in a subfolder: www.mydomain.tld/CMS/ not in the root folder does that affect the LegacyURL?)
Is there anybody who can help? Does the LegacyURL recipe work for anyone?
13 September 2009 at 6:14pm
There's some discussion about the limitations of this recipe here (in German): http://www.silverstripes.de/backend-anpassung/show/396
Perhaps start with a new SilverStripe project, and do the recipe step-by-step alongside the instructions to avoid code duplications etc.
> The recipe says in mysite/code/page.php: $fields->addFieldsToTab('Root.Content.Main', new TextField('LegacyURL', 'Alte URL'));
It should be addFieldToTab() (singular), that was actually a typo in the book... - I've added it to the "Errata" page on http://silverstripe-buch.de/errata/
23 January 2013 at 10:13am Last edited: 23 January 2013 10:15am
Just figured out that the CustomModelAsController class from the book uses HTTPResponse instead of correct SS_HTTPResponse. Just modify this line and your redirects will work properly:
$response = new SS_HTTPResponse();
|Go to Top|