Change Sitefinity Content Block Value Dynamically - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Change Sitefinity Content Block Value Dynamically

  • Change Sitefinity Content Block Value Dynamically
  • Hi, 

    We have a CMS website where certain content is repeated on multiple pages as part of a larger content. For example website has APR displayed at different locations and each time bank rate changes, we need to change this content. As it is part of larger content block, I am unable to use Shared Content block. 

    I have 2 ideas as I understand - 
    Option 1 - Add a placeholder in content block (for example @@APR@@) and interject page rendering. If I see placeholder on current page, show current APR value. This way I can change APR value at one place and it will reflect everywhere. I am not sure how to do this or even if it is possible/advisable.
    Option 2 - Another option is to use my own custom module to house content blocks with placeholder text and then I can render my module instead of sitefinity content block on page.

    I can get option 2 to work but would prefer option 1 so that I don't have to create my own module and everything.

    Thanks for your help.

  • Its certainly possible. Have a look at this github repo and its accompanying youtube video for an example.

  • Hi Christopher,

    This is exactly what I was looking for. Thank you very much. I believe Sitefinity should have similar functionality built right into it. It comes handy when you have some text replaced in many different places.

    If someone has trouble adding "Tokens" section to settings, global.asax.cs code should go under Application_Start() instead of Start().