For multi-publicational purpose I need all publications to override some items in appSettings area of the web.config file of my web application.

Is there a clever way that my TridionPageProvider.PublicationId property to be binded to appSettings/MyPublication.PublicationId?

I do not want to override this part of the web.config in the sub-config files.

Now, by default the web.config looks like:

      <add key="MyPublication.PublicationId" value="6"/>
        <typeAlias alias="IPageProvider"
                 type="DD4T.ContentModel.Contracts.Providers.IPageProvider, DD4T.ContentModel.Contracts" />
        <typeAlias alias="PageProvider"
                 type="DD4T.Providers.SDLTridion2011sp1.TridionPageProvider, DD4T.Providers.SDLTridion2011sp1" />
        <container name="main">
            <!-- map the implementations to the interfaces -->
            <type type="IPageProvider" mapTo="PageProvider">
            <!--          <lifetime type="singleton" /> -->
              <property name="PublicationId" type="int" value="0"/>

My solution at the moment is:

  1. create a new class which inherits TridionPageProvider
  2. create a new PublicationId property with "new" modifier and hiding the parent's property
  3. when the setter is called check if the value is "-1" and if it is true then check ConfigurationManager.AppSettings["MyPublication.PublicationId"] and set that value to the parent's property

But I think there is a better solution. Thanks in advance.


DD4T now contains a PublicationResolver which helps you deal with multi-publication web sites.

Basically, each factory (e.g. the PageFactory) now has a PublicationResolver attached, whose job it is to return the publication id for the current request. It is explained (including code examples) in this post: http://blog.trivident.com/2013/01/dd4t-web-publication-resolving/.

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.