Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Problem implementing nested URLs

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: 4411 Views
  • sethstacey
    Avatar
    Community Member
    7 Posts

    Problem implementing nested URLs Link to this post

    I needed to get nested URLs on a site I am making for a design company, using silverstripe.

    http://sstest.grayzagdesign.com/nested-urls-dev/

    I found this page and made the changes described. Now, when I go to a page on the site it says:

    Parse error: syntax error, unexpected T_RETURN in /home/firemake/public_html/sapphire/core/control/ModelAsController.php on line 58

    That is an entry that was added in the change:

    "return $modelFinder::get_one('SiteTree', '`SiteTree`.URLSegment = \"$urlSegments[$currentSegment]\" AND `SiteTree`.ParentID = $model->ID');"

    Anyone have any ideas?

    The site is www.firemakerdesign.com.

    Seth

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Problem implementing nested URLs Link to this post

    Could you post the code with a few lines before and after that line too?

    It's a code syntax type error, rather than a SS error as such.

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Problem implementing nested URLs Link to this post

    Ahh.. had a look at the script. They're evaluating the object? Ouch.

    I don't quite understand why they're doing it like that - maybe because they couldn't figure out the quote escaping?? Which seems unlikely considering the complexity of the solution.

    See what happens if you replace the eval(...) with:

    $modelFinder::get_one('SiteTree', '`SiteTree`.URLSegment = "'.$urlSegments[$currentSegment].'" AND `SiteTree`.ParentID = '.$model->ID);

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Problem implementing nested URLs Link to this post

    Although, reading the php documentation for eval, maybe they're testing if there is a parse error in that line - which is still a messed up way to do things.

    Hmmmmm...

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: Problem implementing nested URLs Link to this post

    Hey there,

    Thanks for your interest in my nested URL patch! Im the author of the code you mentioned. Firstly, id just like to say that you use this code at your own risk. I know it sounds cliche - but its completely untested and some of the more advanced functionality may break.

    Anyway,
    Firstly, your using the development version of the nested URL patch, which is now quite out of date. Im in the process of moving to a new site, and the new patch will be available there once i get my server working properly ;) For the time being, id reccomend using the non-dev version.

    As for your problem: its not actually related to the eval() statement (which was a byproduct of me coding lazily ). Otherwise it would throw a different error. Instead, I think its a problem with how the patch was applied.

    Instead of going through manually and adding and removing code, its best to use something like TortoiseSVN, and checkout the 2.2 branch of SilverStripe. Then you can click on your project, and select apply patch, and itll all be done automatically.

  • sethstacey
    Avatar
    Community Member
    7 Posts

    Re: Problem implementing nested URLs Link to this post

    Thank you all for your responses!

    I just grabbed TortoiseSVN, as well as the non-dev version of the patch.

    I'll be messing with it now and hopefully have it up and running soon. Thank you all very much for your help. I'll post the results.

    Seth

  • sethstacey
    Avatar
    Community Member
    7 Posts

    Re: Problem implementing nested URLs Link to this post

    Ok, that program is nifty. However, I am having issues working getting it to patch the files.

    I have silverstripe 2.2.2. I've never messed with the source files before now. I am using files that were backed up before I made the first changes for the nested url thing, so they are the originals.

    When I try to apply the dif file, it pulls up the files necessary, but I cannot patch/preview them. I get an error that says "Could not retrieve revision 55074 of the file <my file path>/sapphire/core/control/Director.php. Patching is not possible."

    According the the TortoiseSVN help area, that has to do with a version conflict. The way I understood it was that the patch file is to go from version 1 to version 2, but my file is version 1.4 or something (made up numbers).

    Thank you all for you help.

    Will that patch be making its way into an actual release in the near future?

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: Problem implementing nested URLs Link to this post

    Hey there Seth,

    I think what youll want to do is checkout the SilverStripe version that i created my patch against. To do that, create a folder called something like "nested" or whatever. Then right click on it -> SVN Checkout.

    Enter http://svn.silverstripe.com/open/phpinstaller/trunk for the "URL of Repository", and then select "Revision" in the revision area, and enter 55074 in the text box. Thats the version my patch is create against. Once youve done this, just right click on your folder again, and go TortoiseSVN -> Apply Patch and select the patch.

    As for making it into an actual release, not in its current form, as its quite hacky. Im working on a newer version though, so maybe a bit later down the track.

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