Share » Forums » Developer » How do you make URLs appear like...

How do you make URLs appear like directories??

How do you make URLs appear like directories??

Sunday 03 October 2010 11:33:24 pm - 5 replies

Author Message

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.

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu