Jump to content


* * * * * 1 votes

Friendly URL Folders


  • You cannot reply to this topic
21 replies to this topic

#1 Nick

    Etomite Forum Newbie

  • Member
  • 26 posts

Posted 13 December 2004 - 06:15 AM

NOTE: THIS MOD NO LONGER WORKS

Hi All,

I've managed to code a simple mod for Etomite, which allows documents to be inside folders like so:

http://yoursite.com/Folder/document.html

You can see it in action at the temporary URL: http://eto.vorxhost.com

One problem though, I'm not sure how to make links outside 'Folder' change back to their normal link (http://yoursite.com/document.html), so if anyone has any ideas, I'd be very grateful :)

Below is the code for anyone that's interested:

This adds the document parent alias to the URL, if it's a folder, otherwise it's a normal document. (Note: you have to edit a document and save for it to work).
// processors/save_content.processor.php

// Line 30:
if ($isfolder == 0){
	$sql = "SELECT alias FROM $dbase.".$table_prefix."site_content WHERE $dbase.".$table_prefix."site_content.id = $parent;";
	$rs = mysql_query($sql);
	$docaliasprefix = mysql_fetch_assoc($rs);
	$alias = $docaliasprefix['alias'].'/'.$alias;
}

This removes the folder/ alias when editing the document, so it doesn't duplicate it:
//  actions/dynamic/mutate_content.dynamic.action.php

// Line 100:
list ($folder, $document) = explode ('/', $content['alias']);
$content['alias'] = $document;

Note:
The same thing happens with the URLs if you change a document's alias to Folder/document rather than using the code above.

#2 Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 22 April 2005 - 09:19 PM

Hello,

This code modification is ideal for migrating another site to Etomite, as it allows search engines to maintain any URLs it has referenced to be valid in the new site if the same structure is used. :D

I do have one small issue though. I might have missed something, but here goes... I was just trying this out and I appear to have an issue with image and CSS paths. I have Etomite installed in a sub directory from the root. On the pages which appear in the alias 'folders', the relative path for the images and CSS appears to be incorrect.

Other than putting absolute paths in the template, is there a way round this?

#3 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,505 posts
  • Gender:Male

Posted 23 April 2005 - 01:35 AM

Robsta, on Apr 22 2005, 06:19 PM, said:

Hello,

This code modification is ideal for migrating another site to Etomite, as it allows search engines to maintain any URLs it has referenced to be valid in the new site if the same structure is used.  :D

I do have one small issue though. I might have missed something, but here goes... I was just trying this out and I appear to have an issue with image and CSS paths. I have Etomite installed in a sub directory from the root. On the pages which appear in the alias 'folders', the relative path for the images and CSS appears to be incorrect.

Other than putting absolute paths in the template, is there a way round this?
The problem you are having is being caused by the difference between that actual relative location of these files versus the spoofed location presented by the aliased folders... Two solutions come to mind immediately and I'm sure there are other ways to adjust for this issue...

The easiest way, but not the most efficient by far, would be to store your CSS code in Chunks and to place chunk calls wherever you need a given CSS file. The downfall of this concept is that the style sheets will never be cached and will be transferred with every new page... But, then again, so does inline style...

Another way to remedy this problem would be to use a snippet to generate the proper path to your CSS files and then use the snippet call to plug the proper location into your pages... This method would allow for the style sheets being cached... Essentially, the concept would be to send the actual relative path to the snippet and then have the snippet code calculate the correct path based on the alias folder location in one of several ways...

See if you can take one of these ideas and run with it... Otherwise, maybe other members will have will have suggestions... Good luck, and let us know if you get it working... :eto:

#4 Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 23 April 2005 - 11:44 AM

Thanks Ralph,

With the style sheet I could use an absolute path from the root, it's actually something I've never tried before but I'm sure it works. The main problems are the images in the page. The sites I develop are not completely stylesheet based.

#5 jaredc

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,193 posts

Posted 23 April 2005 - 02:50 PM

The other thing you want to keep in mind is that in the config settings, you have the option to "rewrite image paths" - this should be YES if you're not going to be in the root folder, or especially, if you will eventually migrated the site to a different folder, server, etc. I've just found that rewriting the image path's is a good thing.

Something I've noticed tho is that image paths that get rewritten when Eto is NOT in the root, can wind up messed up because they get a forward slash put in the beginning (which indicates starting at the root). So they can wind up like this:
/somefolder/inyourpath/picture.jpg
Instead of being truly relative like so:
somefolder/inyourpath/picture.jpg
So you might take a look and see if that's what's happening. I'm not sure why that happens or if that's an Eto bug or a WYSIWYG editor bug.

Second point regarding style sheets. You shouldn't have issues with an external style sheet because any imagery is relative to the location of the stylesheet. I ONLY use external style sheets and have yet to have an problem with this. I just put a styles folder in the Eto root and hold everything relative to the various templates/styles in there. Like this:

Styles
-- firstTemplateStyle
---- styles.css
---- logo.gif
---- otherImages.jpg
-- nextTemplateStyle
---- ...etc...

This way the styles.css stylesheet can call the logo.gif with just "logo.gif" - since paths are relative to the stylesheet itself.

Ok- I'm rambling. Maybe all this was already known and I'm missing the point. :D

#6 Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 23 April 2005 - 03:07 PM

Actually, what is interesting now I look a little closer at what it's doing. I go to the page in the 'Folder', and the images and CSS are not used. Hover over the menu options and the paths are incorrect... It looks for 'home' within the folder. The general path references are incorrect.

I'll make sure I followed the instructions correctly again. I'm pretty sure I did as per instructions, but not sure whether this quote (from the original post) below indicates a relative path bug with the code (as experiencing) or an observation for changing it back.

Quote

One problem though, I'm not sure how to make links outside 'Folder' change back to their normal link (http://yoursite.com/document.html), so if anyone has any ideas, I'd be very grateful

Jaredc, thanks for your comments. I enabled the rewrite paths to see if it made a difference, and it doesn't. I thought that option only affected the images which appear in the actual pages, and not in the templates. But then I suppose this change to the site layout also affects the images within the pages.

Maybe this mod is not as easy to implement after all... :blink: Thanks for your comments guys. :D

#7 Nick

    Etomite Forum Newbie

  • Member
  • 26 posts

Posted 24 April 2005 - 12:48 PM

Hi,

Just an idea Ralph - if Eto 0.6.1 includes the folder id in the query string, then I could rewrite Alex's friendly url rules.

E.g.

mysite.com/somedir/thefile.html -> index.php?did=somefolder&fid=thefile.html

I reckon friendly urls would be more extensible that way.

Just a thought though :)

#8 MrDigory

    Etomite Forum Newbie

  • Member
  • 3 posts

Posted 29 June 2005 - 02:44 PM

Has this been sorted out yet? Has anyone else had trouble with the images and css?

#9 Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 23 August 2005 - 10:19 AM

MrDigory, on Jun 29 2005, 03:44 PM, said:

Has this been sorted out yet? Has anyone else had trouble with the images and css?
I've not re-addressed this idea, as I decided it was causing more problems in the long run than it was worth. To ensure old paths do not become wasted, I've put refresh pages in the subdirectories forwarding to the new page in Etomite. Probably the best solution to the probem. :D

Edited by Robsta, 23 August 2005 - 10:19 AM.


#10 fgroup

    Etomite Forum Newbie

  • Member
  • 29 posts

Posted 23 January 2006 - 11:00 AM

Nick, on Dec 13 2004, 08:15 AM, said:

Hi All,

// processors/save_content.processor.php

...

This removes the folder/ alias when editing the document, so it doesn't duplicate it:
//  actions/dynamic/mutate_content.dynamic.action.php
...

Note:
The same thing happens with the URLs if you change a document's alias to Folder/document rather than using the code above.

I have used this fix, but I cannot get url :(
Also, after edit, I got new prefix:
page: "full"
this page in folder "order"
After save I got: "order/full' alias
After next save action I got
"order/order/full"

How I can fix it and use
"/order/full.html" page?

P.S.
Etomite 0.6.1 version.

?

#11 TheBear

    Etomite Forum Newbie

  • Member
  • 30 posts

Posted 05 June 2006 - 07:48 PM

I'd like to request an update to this mod to the latest version of Etomite.
Thanks in advance for your work!

#12 sophietje

    Etomite Forum Newbie

  • Member
  • 13 posts

Posted 18 June 2006 - 11:20 AM

Wow, this is what I need! Does this work with the latest version of Etomite?

If it works, then I could convert my royalty-site which is pretty big.

#13 Dean

    Loves Etomite Forums!

  • Admin
  • 4,744 posts
  • Gender:Male

Posted 07 August 2006 - 09:18 PM

can someone look into this, to see if this could fix our virtual folders issues, and what the solution would be?

#14 Ingo Rasen

    Etomite Forum Newbie

  • Member
  • 14 posts

Posted 08 August 2006 - 02:26 PM

View PostDean, on Aug 7 2006, 11:18 PM, said:

can someone look into this, to see if this could fix our virtual folders issues, and what the solution would be?

I don't think that the stuff posted there will help you as it only converts /a/b/c.html to something like a-b-c.php. For we don't have such a structure, it's not usable here.

I think that changing the code is not that hard. One would have to change the makeUrl(...)-method and the part where the aliases are converted into ids. For the makeURL(...)-part as well as the [~xx~]-thing one should take the path from the current document up to the root collecting all aliases. For example if we have a structure like that:

Root
  +-- products (alias: products)
	+-- product a (alias: product_a)

we could form a relative url like /products/product_a.html (if .html is the suffix). This should not be that hard. The same with the other way round: I think that, if someone writes http://www.yourserver.com/products/product_a.html then the url-rewriting-mechanism of apache calls the index.php like that: index.php?q=products/product_a.html (Maybe with a leading slash!?) So etomite should then explode it with slashes like explode( "/", $q ) and foreach it through the database-content-aliases.

If I have some time, I will try that procedure...



Yours, Ingo.

Edited by Ingo Rasen, 08 August 2006 - 02:26 PM.


#15 linjection

    Etomite Forum Newbie

  • Member
  • 5 posts

Posted 10 December 2006 - 11:24 PM

hi,

which lines of codes must i rewrite with the new version of etomite 0.6.1.2?
anyone done it yet?

greetings

lin

#16 0zz

    Etomite Forum Fan

  • Member
  • Pip
  • 82 posts

Posted 18 January 2007 - 10:03 AM

I have to UP this topic.. Would be great to have solution on UFUs (User Friendly URLs)..
p.s. .htaccess solution doesn't work for me..

#17 Dean

    Loves Etomite Forums!

  • Admin
  • 4,744 posts
  • Gender:Male

Posted 18 January 2007 - 11:21 AM

It's not gonna happen any time soon....

#18 0zz

    Etomite Forum Fan

  • Member
  • Pip
  • 82 posts

Posted 18 January 2007 - 02:43 PM

in previous versions of Etomite it was possible to create alias names as "folder/name" and use them without prefixes and endings (like .html) and it was quite satisfactory. Is there any way to change things back?

#19 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,505 posts
  • Gender:Male

Posted 18 January 2007 - 03:27 PM

View Post0zz, on Jan 18 2007, 09:43 AM, said:

in previous versions of Etomite it was possible to create alias names as "folder/name" and use them without prefixes and endings (like .html) and it was quite satisfactory. Is there any way to change things back?
While one or two revisions of Etomite didn't put file extensions on Friendly Aliases there were complaints that for SEO purposes they should be appended so that bit of code was reverted back to adding an extension if one was supplied... It would take some digging in order to find where this would need to be addressed in the parser and there surely won't be a configuration panel change for the current code base to address this issue... Hunting this down isn't at the top of the priority list so if you want to sort your way through the parser to see if you can figure it out, feel free to do so...

#20 Dean

    Loves Etomite Forums!

  • Admin
  • 4,744 posts
  • Gender:Male

Posted 18 January 2007 - 03:49 PM

I also know why it was possible to use folder/file ... its because the alias field wasn't made safe in the parser, and due to security concerns it had to be...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users