Nested URLs Update

67 views
Skip to first unread message

Andrew Short

unread,
Dec 14, 2008, 1:03:10 AM12/14/08
to SilverStripe Development
Hey Everyone,

As you may be aware, I've been working on adding nested URL support to
SilverStripe for the last
three months (site.com/page/sub-page/). I've been meaning to send out
a quick status update for
a while, so here it finally is!

IMPLEMENTATION

* Nested URLs are disabled by default, and you can enable them by
adding
"SiteTree::enable_nested_urls()" in your _config.php file
* The entire system is built on SiteTree::get_by_link() which allows
you
to pass in almost any valid link and get a SiteTree object back
* Conflicts are resolved automatically, either when theres both a
ParentID
and URLSegment conflict, or when theres an $allowed_actions
conflict on
a parent controller
* You can pretty easily upgrade an old site to run with the
nestedurls
branch - all your old non-nested links will automatically be
rewritten
and redirected
* Most functions (the linkorsection stuff, Link(), RelativeLink())
still
work just as before, with some minor changes. Now, if you need to
use a
CSS class unique to a page, you use $ElementName instead of
$URLSegment

PROGRESS SO FAR

Currently, the actual implementation of the nested URL stuff is pretty
much done, and is partially
supported by tests. All the base functionality seems to work fine, and
you can switch pretty easily
between nested & non-nested URLs. I would say that, as long as you
have an advanced knowledge of
OOP PHP, you could get away with using the nestedurls branch for
projects which don't require things
like the subsites module (note that all modules are untested with the
branch).

Note: for a commit log you can visit
http://open.silverstripe.com/log/modules/sapphire/branches/nestedurls

TODO

* The link tracking and inserting stuff is going to be rewritten as
part
of the nestedurls branch in order to allow for easier tracking and
more
resilient linking. Rather than just writing out a plain link, the
link
inserted will be updated to use links like "$Link[ID]"

This will then be translated into a real link at runtime using an
escaping
method. This means that links will automatically update when moving
pages,
renaming them etc. It also means that links will only be broken
when the
pages are deleted - and broken links can be managed much more
easily.
* Write lots of tests, as well as manual testing with some of the
modules

Fuz...@gmail.com

unread,
Dec 15, 2008, 3:14:13 AM12/15/08
to SilverStripe Development
Hi Andrew,


On Dec 14, 7:03 am, Andrew Short <andrewjsh...@gmail.com> wrote:
> Hey Everyone,
>
> As you may be aware, I've been working on adding nested URL support to
> SilverStripe for the last
.....

You are going to make a _LOOOOT_ of people very happy with this ! ;-)

Thanks for the update and the work.

Andrew Short

unread,
Dec 16, 2008, 12:58:14 AM12/16/08
to silverst...@googlegroups.com
Hey again Everyone,

I'm glad to see that everyone is looking forward to this feature - in case you haven't noticed the SS core team recently used the nestedurls branch to build a project (http://www.metlinkmelbourne.com.au/) - I'll take this moment to present Mr. Munn with an e-cookie for doing such a fantastic job (as well as anyone else who helped). I think this is a sign that the branch is reasonably stable.

As for anything people can do to help, the main area that people can help in is either ideas or testing. I think the ideas are pretty well fleshed out - me and Sam have worked out a pretty good game plan of what needs to happen to finish off the branch - I'm sure he's tired by now of me bugging him every 10 minutes ;) However, if you notice any flaws or have any suggestions, feel free to email me.

The thing I would love for people to do is to download and play around with the nested urls branch - maybe even use it for a project if your adventurous. Oh - and if your really dedicated you can write unit tests - the test suite is fairly shallow at the moment and could do with some fleshing out ( hint hint :P ).

Andrew Short

Sigurd Magnusson

unread,
Dec 16, 2008, 3:20:31 AM12/16/08
to silverst...@googlegroups.com
Awesome to see it in production!

Gareth

unread,
Dec 16, 2008, 5:16:51 PM12/16/08
to silverst...@googlegroups.com
FYI: Sitemap link brokeded.

http://www.metlinkmelbourne.com.au/footer/sitemap

Fantastic application though. iPhone app on the way?

Gareth

http://computerrescue.com.au
http://ninja.net.au
ph: 0422 538 559
int: +61422538559

-----------
There is no excellent beauty that hath not some strangeness in the proportion.
- Sir Francis Bacon (1561 - 1626)



2008/12/16 Andrew Short <andrew...@gmail.com>:

dio5

unread,
Jan 16, 2009, 3:48:36 AM1/16/09
to SilverStripe Development
Hi Andrew,

great stuff, can't wait to see this in a stable release.

I've been checking out the nested urls branch and noticed there was a
flaw in SSViewer.php. around the lines 422 - 427,
where the regexes for Foo(Bar, Baz) etc are.

In the regex for the exceptions, comma's were not included: "(([^)]
+)", which caused CroppedImage(220,200) and equal syntax to fail
because it was read as one argument. (which was how we discovered).
If the comma is added (([^),]+) it works.

I'm not sure if this is fixed somewhere or if someone is aware of
this, but I've noticed that the regexes SSViewer in 2.3 trunk as well
as branches are pretty different.

regards,

dieter

Andrew Short

unread,
Jan 19, 2009, 4:27:39 AM1/19/09
to SilverStripe Development
Thanks for pointing that out dio5! I went ahead and applied your fix
in r70329. As for the reason I have a slightly customsed SSViewer
regex in the nestedurls branch, I had to update SSViewer so you could
do <% control ChildrenOf(about-us/staff) %> - before it would only
recognise alphanumeric characters + underscores in arguments.

dio5

unread,
Jan 19, 2009, 6:25:14 AM1/19/09
to SilverStripe Development
Hey Andrew,

great to have it fixed.

There's another issue I ran into, I'm not sure if this is related to
the nestedurls but it doesn't happen in 2.3 branch if I'm correct.

The issue is: ImageField 'upload from the file store' seems to be
broken. While upload from the pc works perfect, it's impossible to
select a folder from the filestore.
The content of the dropdown keeps hangin on 'loading' and I get an
error of:

500 Error: "Object::__call() Method 'field' not found in class
'Image_Uploader'" at line 133 of xxxxx\sapphire\core\Object.php

I tried to trace it back, but I couldn't really see the exact problem
yet.

Jim Muir

unread,
Jan 21, 2009, 11:16:41 AM1/21/09
to SilverStripe Development
Hey guys, I am having the exact same problem,
I've traced it back to the URL that the form tries to request after
the dropdown is selected (trying to load the image list from the file
store)

nestedurls:
GET http://nestedurls.localhost/images/EditImageForm/Page/1/FeaturedPhoto/field/ExistingFile/gettree?forceValues=

2.3rc2:
GET http://silverstripe.localhost/images/index/Page/1/FeaturedPhoto/EditImageForm/field/ExistingFile/gettree?forceValues=


I've traced it back to the FormAction() method in the Form class
here: /sapphire/forms/Form.php line 577:

nestedurls branch:
return $this->controller->Link($this->name);

2.3rc2:
return Controller::join_links($this->controller->Link(), $this->name);

when changing the line to be the same as the 2.3rc2 code, the 'upload
from file store' dropdown works again!

Andrew Short

unread,
Jan 21, 2009, 5:55:17 PM1/21/09
to silverst...@googlegroups.com
That certainly is a interesting problem - I changed that code so that search forms on the home page would work, but it seems I broke some functionality - I'll do some investigation later today/tomorrow.

David White

unread,
Feb 19, 2009, 4:58:55 PM2/19/09
to silverst...@googlegroups.com
Thank you. I grabbed the nested branch, installed it and add a few
pages. And when I looked at the new site... nothing had changed. A
quick look back at e-mail and adding

""SiteTree::enable_nested_urls()" in your _config.php file"
and it worked!

My office-mates gave me odd looks as I squealed with happiness.

Thank you,
David

Reply all
Reply to author
Forward
0 new messages