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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.