Forums / Developer / How do you make URLs appear like directories??

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.

eZ debug

Timing: Jan 29 2025 13:47:15
Script start
Timing: Jan 29 2025 13:47:15
Module start 'content'
Timing: Jan 29 2025 13:47:15
Module end 'content'
Timing: Jan 29 2025 13:47:16
Script end

Main resources:

Total runtime0.1375 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 588.0625180.8203
Module start 'content' 0.00490.0047 768.8828106.0391
Module end 'content' 0.00970.1278 874.9219535.3594
Script end 0.1375  1,410.2813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00312.2200200.0002
Check MTime0.00120.8545200.0001
Mysql Total
Database connection0.00080.587510.0008
Mysqli_queries0.091366.37051410.0006
Looping result0.00130.95481390.0000
Template Total0.127692.810.1276
Template load0.00080.578010.0008
Template processing0.126892.173410.1268
Override
Cache load0.00050.356410.0005
Sytem overhead
Fetch class attribute can translate value0.00060.458910.0006
XML
Image XML parsing0.00020.158610.0002
General
dbfile0.00513.6821200.0003
String conversion0.00000.002830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs