[opencms-dev] how to modify and write to a CmsFile during a Publish Project sequence

Nacho Fernandez snatcho at gmail.com
Fri May 30 08:25:26 CEST 2008


Hi again, frankg.

I'm glad I could be of assistance. If I understand correctly, all you should
do is surround your code with a temporary change of project (I do that when
modifying xml files), and optionally a publishing of the file, like this:

            CmsProject project = cms.getRequestContext().currentProject();
            cms.getRequestContext().setCurrentProject( cms.readProject(
"Offline" ) );
            //Here goes the before mentioned code
            cms.unlockResource( filePath );
            cms.publishResource( filePath );
            cms.getRequestContext().setCurrentProject( project );

I hope again it helps. Greetings,

Nacho Fernandez.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20080530/059056d3/attachment.htm>


More information about the opencms-dev mailing list