Jump to:

325 Posts in 200 Topics by 157 members

Migrating a Site to Silverstripe

SilverStripe Forums » Migrating a Site to Silverstripe » LegacyURL recipe from SS handbook doesn't do anything

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: 3192 Views
  • Bernhard
    Avatar
    Community Member
    3 Posts

    LegacyURL recipe from SS handbook doesn't do anything Link to this post

    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?

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: LegacyURL recipe from SS handbook doesn't do anything Link to this post

    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/

  • wojt
    Avatar
    Community Member
    2 Posts

    Re: LegacyURL recipe from SS handbook doesn't do anything Link to this post

    Hi,

    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();

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