Forums / Developer / How does ez publish parse fancy "/obj1/obj2/obj3" URL's through one design script ? possible to do in PHP ?

How does ez publish parse fancy "/obj1/obj2/obj3" URL's through one design script ? possible to do in PHP ?

Author Message

Armen Zourabian

Tuesday 29 June 2004 3:39:17 am

Hi All!

I noticed that ezPublish, which is implemented in PHP, gives a site very nice looking subdirectory structure like www.mydomain.com/users/amn/ or /forums/php/php4/iis... and the best if it all is that none of these directories actually exist at the site, only URLs look like that and they work. I would like to have a similiar site structure, and somehow detect which URL subdirectory is requested but control it all through a centralised script. Is it possible ? I know that in ez, each virtual url subdirectory represents an object. I want to know how to create such framework in PHP, only the part of it which uses one script template for all URL's of a domain, without having the directories actually corresponding to that URL.

My reasons are that it is much easier for people to remember such URLs, but I don't wont to create physical directories with subdirectories, because a lot of my sites content (design, style sheets etc) is shared for all pages, and distributing them across directories is a waste of time, resources, redundancy and space. Instead, I would like to keep the URL structure, but have it all go to one or two scripts at the root of the site or something which will parse the url with its "/"'s accordingly and make some sense out of it..

Thanks in advance,
Amn.

Bård Farstad

Tuesday 29 June 2004 4:09:55 am

This is actually rather simple to make. What we do is to store an alias for all objects. When we store an object we generate the "path" to that object based on the names of the parents (e.g. /frontpage/news/latest_news ). This name is converted into only valid characters.

When you request a page eZ publish will first check if there exists an alias for the current url, if it does it will look up in this alias to see which "page id" it should use.

--bård

Documentation: http://ez.no/doc

Armen Zourabian

Tuesday 29 June 2004 4:48:43 am

Takk for svaret bård ;)

But then again, yo explained the other half of the function, but how does the server know which file to send when you request an URL of "/obj1/obj2/obj3" ? Usually server map virtual directories to physical directories on the server disk, but in ez case, they are completely virtual maps ? That is what I am interested in. I would like to create similiar framework in PHP, and do not want to create directories called obj1, obj2 or obj3...

And since you mentioned that "ez publish checks the alias", this already implies that whatever URL, the request is sent to one master script right which does this checking?

Bård Farstad

Tuesday 29 June 2004 5:02:21 am

We use apache rewrite rules so all requests are sent to index.php. In this file we simply check if the requested uri e.g. /obj1/obj2/obj3 is in our alias table, if so -> then serve that page.

We use the $_SERVER['REQUEST_URI'] variable in PHP for fetching the current URI.

--bård

Documentation: http://ez.no/doc

eZ debug

Timing: Jan 19 2025 01:23:40
Script start
Timing: Jan 19 2025 01:23:40
Module start 'content'
Timing: Jan 19 2025 01:23:40
Module end 'content'
Timing: Jan 19 2025 01:23:40
Script end

Main resources:

Total runtime0.1469 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.0067 589.5703180.7656
Module start 'content' 0.00670.0061 770.335998.1484
Module end 'content' 0.01290.1340 868.4844527.6719
Script end 0.1468  1,396.1563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00362.4532200.0002
Check MTime0.00140.9730200.0001
Mysql Total
Database connection0.00080.518010.0008
Mysqli_queries0.104471.04931410.0007
Looping result0.00120.83831390.0000
Template Total0.133690.910.1336
Template load0.00090.615410.0009
Template processing0.132790.311210.1327
Override
Cache load0.00070.443810.0007
Sytem overhead
Fetch class attribute can translate value0.00090.599810.0009
XML
Image XML parsing0.00020.131910.0002
General
dbfile0.00292.0071200.0001
String conversion0.00000.003430.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