Update web part content

Targutai Yesugei asked on August 25, 2017 16:36

Hello again.

I have something like static html web part. And i want to update this webpart on all pages when i change value of field. I tried to use field default value but it doesn't update existing web parts. How can i handle this?

Thanks in advance.

Recent Answers


Roman Hutnyk answered on August 25, 2017 16:42

I'm not clear on the question, so my answer is based on some assumptions.

So it sounds like you have multiple pages with static html on it.

Question: do those page share the same page template?

Once you update some field of the page on the form tab you'd like static html content to update. Question: how this content should change? Would you like to show that new value somewhere in the content?

If answer is yes - use macro to grab the value of the page field: {%field_name%}

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on August 25, 2017 17:05

Targutai, if you use a web part on different templates, then the configuration is tie to each template individually. You can't change the default value of a configuration through CMS and expect that to force all instances where that web part was used to be updated. Those configurations are stored in the data base. The only way to force some change to all instance of that web part is through the actual user control ascx and ascx.cs file, but you may not want go that direction.

So, you basically need to go to all templates which contains that web part and update the value manually. To help you speed up things, you can go to Web Parts application, find the Web Part, click on the Usage tab to see which are the templates that contains that web part. Then update each one of them.

1 votesVote for this answer Mark as a Correct answer

Targutai Yesugei answered on August 25, 2017 18:32

Roman, I'm sorry, i'll try to clear things up.

I have at least two templates (probably, more) for a lots of pages with concrete widget on them. So this widget should display some text, which can be edited (i don't know how, but it should be changed from one place) at any time, so i want all pages to get updated text.

So, i change text in webpart somewhere -> all pages are updated and shows this new text. _ Rui, thanks for you answer, but updating 500+ pages manully is what i'm trying to avoid.

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on August 25, 2017 18:58

Is it web part or widget? Text you configured to web part is template dependent, which means one template update can affect all pages using that template. But if you are talking about widget, then the text is page dependent, you will have to update it manually or ....

Not something we would recommend, but can be an option. You can use API or SQL script to update it. Basically going through all the pages get the DocumentContent filed (which is in CMS_Document table), located that widget and update the value.

For widget added through widget zone, the HTML looks like this

<webpart id="dancinggoat_editabletextwithbackground;99fdcdf5-1aec-49f3-ae2f-2315b21774ed"><![CDATA[<h2 class="banner-heading">Roasting premium coffee</h2>
<p class="banner-text">Discover the fascinating world of Dancing Goat high-quality coffee and you will never miss a single coffee break again.</p>
]]></webpart>

For widget added as inline widget, the HTML looks like this {^widget|(name)InstagramEmbed|(URL)https%3a%2f%2fwww.instagram.com%2fp%2fBYJATN9FIS2|(title)solar|(Width)400|(Container)InstagramEmbed|(widget_displayname)Instagram+Embed^}

1 votesVote for this answer Mark as a Correct answer

Targutai Yesugei answered on August 25, 2017 20:40

It's a web part. I still can't understand difference between web part and widget. Ok, i'll try you suggestion, thanks for your reply.

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on August 25, 2017 20:51

Web part, you configure it on a template (under the Design tab), the property setting ties to the template.

Widget, you configure under the Page tab, the setting is like data/text you entered directly to the page, it's not stored in the template.

Those are two different things in Kentico. (Although widget is build based on web part)

So in your case, if you are saying it's web part, not widget, then the setting for the web part is going to be in the CMS_PageTemplate table [PageTemplateWebParts]

In that filed, you would fine web part property setup on a template been stored like this

<webpart controlid="Repeater" guid="acf93fb1-6f81-4769-aa7d-b917172ec6bd" type="repeater" v="1"><property name="alternatingtransformationname"></property><property name="backnextlocation">split</property><property name="cachedependencies">##DEFAULT##
</property><property name="cacheitemname"></property><property name="cacheminutes"></property><property name="cat_open_ajax"></property><property name="cat_open_output_filter"></property><property name="cat_open_performance"></property><property name="cat_open_time zones"></property><property name="cat_open_visibility"></property><property name="categoryname"></property><property name="checkpermissions">False</property><property name="classnames">DancingGoat.Office</property><property name="columns">OfficeEmail, OfficeCity, OfficeZipCode, OfficePhone, OfficeCodeName, OfficeStreet, OfficeName, OfficeCountry</property><property name="combinewithdefaultculture"></property><property name="container"></property><property name="containercssclass"></property><property name="containercustomcontent"></property><property name="containerhideonsubpages">False</property><property name="containertitle"></property><property name="contentafter"></property><property name="contentbefore"></property><property name="controlid">Repeater</property><property name="culturecode"></property><property name="customtimezone"></property><property name="datasourcename"></property><property name="disablemacros">False</property><property name="disableviewstate">False</property><property name="displaytoroles"></property><property name="enableoutputfilter">False</property><property name="enablepaging">False</property><property name="filtername"></property><property name="filteroutduplicates">False</property><property name="hidecontrolforzerorows">True</property><property name="hideonsubpages">False</property><property name="instanceguid">acf93fb1-6f81-4769-aa7d-b917172ec6bd</property><property name="itemseparator"></property><property name="loadpagesindividually">False</property><property name="maxrelativelevel">-1</property><property name="nestedcontrolsid"></property><property name="newbuttontext"></property><property name="orderby"></property><property name="outputconverttablestodivs">none</property><property name="outputfixattributes">True</property><property name="outputfixhtml5">True</property><property name="outputfixjavascript">True</property><property name="outputfixlowercase">True</property><property name="outputfixselfclose">True</property><property name="outputresolveurls">True</property><property name="pagenumbersseparator">-</property><property name="pagerhtmlafter"></property><property name="pagerhtmlbefore"></property><property name="pagerposition">bottom</property><property name="pagesize">10</property><property name="pagingmode">querystring</property><property name="partialcachedependencies">##DEFAULT##
</property><property name="partialcacheminutes"></property><property name="path">/Contact/%</property><property name="preservepartialcacheonpostback">False</property><property name="querystringkey"></property><property name="relatednodeisontheleftside">False</property><property name="relationshipname">isrelatedto</property><property name="relationshipwithnodeguid">00000000-0000-0000-0000-000000000000</property><property name="resultsposition">top</property><property name="selecteditemtransformationname"></property><property name="selectonlypublished">True</property><property name="selecttopn"></property><property name="showdeletebutton">False</property><property name="showeditbutton">False</property><property name="showeditdeletebuttons">False</property><property name="showfirstlast">True</property><property name="showfordocumenttypes"></property><property name="shownewbutton">False</property><property name="sitename"></property><property name="timezonetype">inherit</property><property name="transformationname">DancingGoat.Office.FooterOfficeContact</property><property name="useupdatepanel">False</property><property name="visible">True</property><property name="webparttitle">OfficeContacts</property><property name="webparttype">repeater</property><property name="wherecondition"></property><property name="zerorowstext">No data found</property></webpart>

You will need to update the property based on the name of that property.

1 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on August 28, 2017 14:19

Hi Targutai,

You best approach would be to use Content blocks available in Kentico. It's a way to define global strings in Kentico and then use it with any webpart. It will be a key value pair association. as discussed in the above article by Jane Hermann from kentico support.

After installing this package and creating key value pairs you will just call key that you want to show string for. Any change done for the key/value will appropriately reflect in all web parts.

This is the best way I have come across and we use it often.

Thanks, Chetan

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.