1

I need to publish configuration files to a specific location on the webserver. Configuration files are implemented as .cfg pages.

Website pages go to C:\inetpub\wwwroot\ and this is set in the storage configuration files

cfg "pages" need to go to C:\config\ and this is also set for .cfg extension in the storage configuration files.

There is a "catch", all configuration files need to be in the C:\config folder and not in it's subfolders and root structure group has a directory set (this can not be changed/removed).

What would be the best way to proceed?

1

SDL Tridion is by default only able to deploy to the locations you specify in the cd_storage_conf.xml, so if you have something like this in there:

<Storage Type="filesystem" 
         Class="com.tridion.storage.filesystem.FSDAOFactory"
         Id="defaultFile">
    <Root Path="c:\inetpub\wwwroot" />
</Storage>

Then it will be impossible to send stuff to C:\config\, you could consider adding a second location:

<Storage Type="filesystem" 
         Class="com.tridion.storage.filesystem.FSDAOFactory"
         Id="configFile">
    <Root Path="c:\config" />
</Storage>

But then you will run into an issue with your item type mapping, since you can only map a certain type once.

So if the configuration files are a specific type (a Page for example) which you don't use for anything else, then you can map them quite easy, like this:

<Item typeMapping="Page" cached="false" storageId="configFile"/>

But most likely, you will have a few Pages needing to go to the defaultFile storage and your config files need to go to configFile.

The only solution I can think for that is to build a storage extension, and identify if your item is a normal Page or a config file in the storage extension, and fix it like that.

update

I forgot about the itemExtension option we have, maybe it isn't that hard afterall. So lets take a storage config like this:

<Storage Type="filesystem" 
         Class="com.tridion.storage.filesystem.FSDAOFactory"
         Id="defaultFile">
    <Root Path="c:\inetpub\wwwroot" />
</Storage>
<Storage Type="filesystem" 
         Class="com.tridion.storage.filesystem.FSDAOFactory"
         Id="configFile">
    <Root Path="c:\config" />
</Storage>

...

<ItemTypes defaultStorageId="defaultFile" cached="false">
    <Item typeMapping="Page" itemExtension=".cfg" storageId="configFile" cached="false"/>

...

Then your config files will use c:\config as their root, and then you say, but what about the Structure Groups. Well, most simple solution, put all those config files in the root Structure Group. Optionally, map the Root Path to c:\ and place all your config pages in a Structure Group with the directory name config.

Any other requirements, and you have to go the Storage Extension route and customize it any way you want. You could even do that in combination with the above, and extend the com.tridion.storage.filesystem.FSDAOFactory for your configFile storage.

| improve this answer | |
  • Hi @Bart, I have configured storage to put my .cfg pages to a specific folder <Item typeMapping="Page" itemExtension=".cfg" cached="false" storageId="defaultconfig" /> the problem is in the subfolders. All .cfg files should go to C:\Config and not to subfolders. – user3760419 Oct 15 '14 at 9:09
0

If you dont want to implement a storage extension, one option you have is to publish the .cfg files not as pages, but as binary variants. To cut a long story short, in your template code to render configuration (this could be triggered by publishing page(s) or DCP(s)) you can create a binary variant on the fly, relate it to the component containing your configuration, and publish it to the root Structure Group of the site. You can then use a similar method to the one Bart described to map the .cfg extension to a particular filesystem storage (typeMapping would be for Binaries rather than Pages).

The Tridion Reference Implementation uses this method to publish all its configuration and resources as .json files, without having to actually create those files as pages (Note that there is no flattening of structure though). Check the PublishJson method in our TemplateBase class for a code example.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.