0

I've created a module that allows to insert HTML fragments inside it.

These HTML fragments (plain HTML pages) will be created by the user of the CMS in the virtual file system /sites/default/.

Can I access from my module to the HTML file and insert it into the generated page? how?

When I use an iFrame, an image or link everything works fine... because all these elements have a src attribute. For example:

<iframe src="/opencms/demo_en/myfile.html"></iframe>

However, when I use the openCMS tag < cms:include > or the JSP tag < jsp:include > it doesn't work... why?

<cms:include page="/opencms/demo_en/myfile.html"></cms:include>

throws:

org.opencms.file.CmsVfsResourceNotFoundException: Unable to read resource "/opencms/demo_en/myfile.html"

Could it be a permissions problem?

So .. Should I do this with an iFrame? Is there a better way to access and embed this HTML resource?

Thanks in advance!

Dan A.S.
  • 654
  • 8
  • 24

1 Answers1

0

Ok, when you're saying: "Can I access from my module" you're meaning from your /system/modules/foo.bar.qux.my.module/... isn't it?

In this case you're getting this error because you're not using the correct path.

The example would be in your case:

<cms:include page="/sites/default/demo_en/myfile.html"></cms:include>

That's because inside your module you're located under the "/" context, and not under the "/sites/default/" context, that means that you need to fully qualify the path in the VFS to include the file.

This example specify the path in an absolute fashion, but you can also use a relative path, using ../ and ./ to navigate throught folders, while you're including files withing your module you may like to use this one, but otherwise I would recommend the absolute path.

PaK-Zer0
  • 55
  • 12