Etomite Community Forums: Friendly URL Folders - Etomite Community Forums

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Friendly URL Folders Rate Topic: ***** 1 Votes

#1 User is offline   Nick 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 26
  • Joined: 14-May 04
  • Location:England, UK

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 User is offline   Robsta 

  • Likes Etomite Forums!
  • PipPip
  • Group: Member
  • Posts: 360
  • Joined: 23-December 04
  • Location:Exeter, Devon, UK

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 User is offline   Ralph 

  • Etomite Administrator
  • Group: Admin
  • Posts: 6,418
  • Joined: 01-July 04
  • Gender:Male
  • Location:Jamestown, NY USA
  • Interests:Computers, Camping, Hiking, Aviation

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 User is offline   Robsta 

  • Likes Etomite Forums!
  • PipPip
  • Group: Member
  • Posts: 360
  • Joined: 23-December 04
  • Location:Exeter, Devon, UK

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 User is offline   jaredc 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,193
  • Joined: 02-July 04
  • Location:Earth > USA > Ohio > Columbus
  • Interests:Family, church (LDS), foosball, Boy Scouts.

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 User is offline   Robsta 

  • Likes Etomite Forums!
  • PipPip
  • Group: Member
  • Posts: 360
  • Joined: 23-December 04
  • Location:Exeter, Devon, UK

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 User is offline   Nick 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 26
  • Joined: 14-May 04
  • Location:England, UK

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 User is offline   MrDigory 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 3
  • Joined: 16-June 05

Posted 29 June 2005 - 02:44 PM

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

#9 User is offline   Robsta 

  • Likes Etomite Forums!
  • PipPip
  • Group: Member
  • Posts: 360
  • Joined: 23-December 04
  • Location:Exeter, Devon, UK

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

This post has been edited by Robsta: 23 August 2005 - 10:19 AM


#10 User is offline   fgroup 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 29
  • Joined: 21-January 06

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 User is offline   TheBear 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 30
  • Joined: 22-January 06

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 User is offline   sophietje 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 14
  • Joined: 15-May 06
  • Location:Belgium

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 User is offline   DeanC 

  • Etomite Administrator
  • Group: Admin
  • Posts: 4,722
  • Joined: 08-June 04
  • Gender:Male
  • Location:United Kingdom

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 User is offline   Ingo Rasen 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 14
  • Joined: 30-May 06

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.

This post has been edited by Ingo Rasen: 08 August 2006 - 02:26 PM


#15 User is offline   linjection 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 5
  • Joined: 05-December 06
  • Location:Germany

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

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users