How do you make URLs appear like directories??

Author Message

Russell Michell

Sunday 03 October 2010 11:33:24 pm

Hi guys, I have already asked a very similar question but didn't get a lot of interest, sorry for the repeat posting, I hope to make it a little clearer:

In eZ, the URI scheme of both regular and container content-objects look exactly the same. That is, normally in a regular HTML directory listing under apache you'd expect either a trailing '/' for directories and/or a file suffix like .html, .nsf or whatever for files (or non-directories), but this is not the case for eZ's URIs.

I really, really need to be able to differentiate between the two. Something in the kernel code or an override I suppose that checks if the current node is a container (e.g. a 'Folder') and simple appends a slash to the URI. Either that or any other method you can think of.

I have tried several methods including using URL filtering (which fails on two counts, that '/' is stripped and replaced with a '-' and that running updateniceurls.php seems to twice repeat the filter on each URL). I also tried Apache rewrites, but this method of appending a '/' is only as good as the "hooks" Apache can get from eZ, i.e. - none (all object URIs appearing the same), instead rewrite rules simply append a slash onto *everything*.

If anyone has any ideas that lead to a robust solution how I might achieve this, I'd be happy to offer a small payment via PayPal as I am completely stumped! :-(

Thanks a lot for reading folks,
Russell

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Ivo Lukac

Monday 04 October 2010 12:43:48 am

Go to folder(s) class and there you have "URL alias name pattern" field. Enter some prefix (e.g. -dir) like this (let say that "name" is the name attribute of the class):

<name>-dir

Run updateniceurls.php

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Abdelkader RHOUATI

Monday 04 October 2010 4:37:39 am

Hi Ivo Lukac,

I had the same thoughts, thinking about changing the definition of the class, and at the model of url, put something like <name>-dir.html.
But in the case of a node of the second level for eg (in general level> 1), his url will be : <name node level 1>-dir.html /<name node level 2>-dir.html.

It's not good !

TKS

Abdelkader RHOUATI

Blog (french) : http://arhouati.com
----
Extension arh_jdebug : EzDebug using jquery

Russell Michell

Monday 04 October 2010 11:46:53 am

Thank you both for your replies.

I had also tried this method of altering classnames. I'm developing a static deployment module that uses Wget to scrape an eZ site into static HTML.

But Wget doesn't know what is and what isn't a directory or an HTML page, so either all pages are named blah.html or I use rewrites to force a trailing '/' which makes Wget think that all pages are directories, and generates an index.html.

I need a bit of one and a bit of the other! ;-)

Perhaps it's down to my tree structure in eZ. I have simply mapped virtual dirs to how I'd like the eventual site to appear, where most of those dirs also have some text/image content in them too, so they appear as "pages".

I think the best solution is to find a way to code or override the kernel to check that current node is a container, and if so, append a trailing slash - does anyone know how this might be done?

Thanks very much
Russell

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Russell Michell

Tuesday 05 October 2010 12:45:27 am

So I had another go at custom URLs, and while the URL change worked, you cannot use a '/' as part of the URL that gets stored in the ezurlalias_ml table - it gets replaced somewhere in the eZURLAliasML class.

I tried to force it in my filter class using an encoded string (%2F I think) but that's just getting really 'hacky' and didn't work anyway simply becuase the '%' symbol gets removed as well.

@Abdelkader, you're right - any such update to a node will result in each "directory" having the same suffix, which is why I wanted to use a slash.

I see that in ezurlaliasml.php there is a static class method "sanitizeURL" which seems like it's the one stripping the trailing slashes, but I tried hacking it and overriding it, by removing the call to trim() but still no luck.

My partner - who also works in I.T. - suggested using a separate rewrite rule in .htaccess for each directory. But that means manually adding a new rule every time a directory is created.

I guess I could code something up that automatically wrote a new rule to .htaccess each time a container object was created, but am not sure where to start looking - or even if it's just a bad idea.

I'm really stuck.

Thanks for your time folks
Russell

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Russell Michell

Thursday 07 October 2010 11:54:44 am

SOLVED.

Sometimes, just taking another look at what you're trying to do does the job.

Insead of trying to force directories, I forced pages instead by appending .html to the URIs of non-container objects. All Wget needed was one or the other to differentiate between which content object URIs to append a trailing slash to, and which ones to leave alone.

Thanks to Ivo for prompting me to look again at a class-level change.

That was all it took.

I had to manually re-edit and publish all my content again though for the changes to take effect (updateniceurls.php seemed to break my site, whichever flags I passed to it).

Thanks again to everyone for their input.

Russ

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.