[opencms-dev] Using Include?

Christian Steinert christian_steinert at web.de
Mon Sep 11 22:37:44 CEST 2006


> I've created a template and it needs to include some html that my users 
> will need to update. I have the template in the modules folder and I put 
> the html page under the default site. I use something like <cms:include 
> file="/sites/default/ads_content.html" element="body" editable="true"/>. 
> This method doesn't seem to be working for me. I'm not completely 
> understanding what is doing wrong, but I get file not found messages. 
> What strange is it will work for a while then stop working. I'm not sure 
> if this connected to the logout or what. So my question is how should I 
> do this. I want some content that's included in the template, and is 
> located in a place where my users can edit it. As in I didn't think 
> letting them in the module section would be ok. Anyone have some advice?
> 

This is *difficult* to explain - ok let's try:

Opencms has something called 'site root'. The site root is like the home path for one website. 
When opencms comes out of the box then there is one pre-configured website with the site root "/sites/default"

Ok, now when a request comes in, then opencms will:
- check, if you are logged in. If this is the case then the site root setting will be taken from the current state of the workplace
  (You have this dropdown box, where you can choose the site root that is currently used)
- if you are *not* logged in, then the site root of your website will be used.
  For the default configuration the site root is set to "/sites/default"


Opencms will add your site root in front of any path that you request.
Ok, so what happens if somebody is not logged in and requests a file called  "/test".
If the current site root is set to /sites/default then requesting /test will actually try to read the file /sites/default/test
or - in other words: opencms will try to read a file called "/test", but starting from the current site root and not necessarily from the root of the complete virtual filesystem.

So in your case, you probably try to read "/ads_content.html" instead.
But it's important to understand the concept behind.

hth.
christian
_______________________________________________________________________
Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos.
Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222




More information about the opencms-dev mailing list