Change Sitefinity Content Block Value Dynamically

Posted by Community Admin on 04-Aug-2018 16:10

Change Sitefinity Content Block Value Dynamically

All Replies

Posted by Community Admin on 10-Apr-2017 00:00

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.
Atit

Posted by Community Admin on 10-Apr-2017 00:00

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

https://github.com/timw255/Tokens

Posted by Community Admin on 11-Apr-2017 00:00

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().

Thanks
Atit

This thread is closed