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.

eZ debug

Timing: Jan 18 2025 03:09:02
Script start
Timing: Jan 18 2025 03:09:02
Module start 'layout'
Timing: Jan 18 2025 03:09:02
Module start 'content'
Timing: Jan 18 2025 03:09:03
Module end 'content'
Timing: Jan 18 2025 03:09:03
Script end

Main resources:

Total runtime1.3312 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 589.1797152.6406
Module start 'layout' 0.00630.0046 741.820339.4844
Module start 'content' 0.01091.3191 781.3047639.0078
Module end 'content' 1.33000.0012 1,420.312520.1250
Script end 1.3312  1,440.4375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.2691160.0002
Check MTime0.00160.1207160.0001
Mysql Total
Database connection0.00070.052110.0007
Mysqli_queries1.254594.2366680.0184
Looping result0.00080.0615660.0000
Template Total1.293197.120.6466
Template load0.00230.169520.0011
Template processing1.290996.967320.6454
Template load and register function0.00010.005910.0001
states
state_id_array0.00210.159310.0021
state_identifier_array0.00120.088620.0006
Override
Cache load0.00200.1471590.0000
Sytem overhead
Fetch class attribute can translate value0.00060.046130.0002
Fetch class attribute name0.00130.095290.0001
XML
Image XML parsing0.00140.103830.0005
class_abstraction
Instantiating content class attribute0.00000.0019120.0000
General
dbfile0.00120.0869290.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs