Forums / Setup & design / Use id for url

Use id for url

Author Message

Sao Tavi

Friday 27 May 2011 7:28:40 am

Is it possible to use the object id for the url?

It is something like this: users should be able to add data that is no readable by other users. The problem is that it is very common for the users to add objects with the same name. So if 2 users will create some content called "content", the first user will see the url to content as "parent/content", the second one will see the url to it's content like "parent/content-2".

I would not like this to happen, and I can see 2 options:

1) use for object's url it's id, like parent/77 (where 77 is the object's id)

2) add to object's url the owner's id, like parent/content-88 (where 88 is the user's id)

 

Are these setups possible?

Gaetano Giunta

Friday 27 May 2011 8:38:52 am

I suppose you know you can use /content/view/full/$nodeid and that it would not suit your needs, correct? Because using these urls all content objects are created equal...

As for data that is not readable by other users: this is a problem of permissions, not of urls. Because if you do not use permissions to block access to a given node, it will show up both in search results and when using the /content/view/full/$nodeid url syntax

Principal Consultant International Business
Member of the Community Project Board

Marko Žmak

Friday 27 May 2011 8:57:25 am

Sao, just a note...

When there are two subitems with the same name under the same parent node, eZ automatically generates different URL's for them. In your example that would be:

  • /parent/content
  • /parent/content_1

And when you use $node.url_alias for this nodes you'll get this different urls.

Does this help?

P.S. Your second option won't work properly if the same user creates two contents with the same name.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Sao Tavi

Friday 27 May 2011 10:29:13 am

Thank you for your replies.

Gaetano, yes, but how can I get that url? I mean... Using url instead of url_alias (in fetch ('content', 'list'..)) makes no difference. The documentation says that it depends "on a configuration setting", but that does not help much.

Marko, yes, you are right. So the user id part seems to be a wrong idea. So only the first option still stands.

Marko Žmak

Friday 27 May 2011 10:38:13 am

"

Thank you for your replies.

Gaetano, yes, but how can I get that url? I mean... Using url instead of url_alias (in fetch ('content', 'list'..)) makes no difference. The documentation says that it depends "on a configuration setting", but that does not help much.

Marko, yes, you are right. So the user id part seems to be a wrong idea. So only the first option still stands.

"

It's a little bit unclear what are you trying to do...

Why (and how) do you want to use url in fetch(content, list)?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Sao Tavi

Friday 27 May 2011 10:45:45 am

Yes, sorry, I was ambiguous. So I have a new class that in it's template gets it's subitems with fetch(content, list). I should have said directly in class ezcontentobjecttreenode.

eZ debug

Timing: Jan 17 2025 22:46:28
Script start
Timing: Jan 17 2025 22:46:28
Module start 'content'
Timing: Jan 17 2025 22:46:29
Module end 'content'
Timing: Jan 17 2025 22:46:29
Script end

Main resources:

Total runtime0.7438 sec
Peak memory usage4,096.0000 KB
Database Queries205

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 588.7188180.8594
Module start 'content' 0.00610.6208 769.5781621.2891
Module end 'content' 0.62690.1169 1,390.8672337.0938
Script end 0.7437  1,727.9609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.4991210.0002
Check MTime0.00140.1906210.0001
Mysql Total
Database connection0.00090.126510.0009
Mysqli_queries0.671690.29842050.0033
Looping result0.00190.26052030.0000
Template Total0.718396.620.3592
Template load0.00200.264320.0010
Template processing0.716496.311820.3582
Template load and register function0.00020.022310.0002
states
state_id_array0.00060.082410.0006
state_identifier_array0.00070.087920.0003
Override
Cache load0.00170.2333380.0000
Sytem overhead
Fetch class attribute can translate value0.00110.150240.0003
Fetch class attribute name0.00110.142980.0001
XML
Image XML parsing0.00160.212940.0004
class_abstraction
Instantiating content class attribute0.00000.002890.0000
General
dbfile0.00280.3792350.0001
String conversion0.00000.000830.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
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs