Hi,

A new URL tool (portal_url), extending the CMF one, has been designed to handle virtual hosting in CPS. The most complex case is when part of the portal is hidden in the URL, and part of the URL is completely virtual, for instance:
- virtual url: http://www.site.com/foo/bar/my-folder/my-file
- zope absolute path: /cps/workspaces/my-folder/my-file

Here are the methods to remember and use:
- utool.getRpath(object) gives 'workspaces/my-folder/my-file' (alias for getRelativeContentURL from CMF) - utool.getBaseUrl() gives '/foo/bar/' (would give '/cps/' without virtual hosting). This should only be used when generating URLs that are not placeful, like links to fixed images or fixed skins like the directory ones. - utool.getUrlFromRpath(rpath) gives 'http://www.site.com/foo/bar/my-folder/my-file' when given rpath 'workspaces/my-folder/my-file'. - utool.getRpathFromPath(path) gives 'workspaces/my-folder/my-file' when given '/cps/workspaces/my-folder/my-file'.

Additional methods handle breadcrumbs.

Some object methods can be used too:
- obj.absolute_url() gives 'http://www.site.com/foo/bar/my-folder/my-file'
- obj.absolute_url_path() gives '/foo/bar/my-folder/my-file'

More info about existing methods is here:
http://svn.nuxeo.org/trac/pub/file/CPSCore/trunk/doc/virtual-hosting.txt

You should not use the deprecated skin scripts getBaseUrl.py, getContextUrl.py or getBreadcrumbs.py anymore, but query the tool instead. Also, you should never create URLs by joining the base url and the object rpath, as it will generate incorrect URLs in the case of virtual hosting given above.

Regards,

--
Anahide Tchertchian
Mail: at at nuxeo.com - Tel: +33 (0)1 40 33 71 60
Nuxeo Collaborative Portal Server: http://www.nuxeo.com/cps
Gestion de contenu web / portail collaboratif / groupware / open source
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel

Reply via email to