Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Web parts - content remains when the web part is deleted and then placed back View modes: 
User avatar
Member
Member
dima - 2/10/2011 2:46:54 AM
   
Web parts - content remains when the web part is deleted and then placed back
Hello
I am not sure if it's a bug or a configurable feature.
I add a web part on the page (i.e. Editable Text), then I add some text to it. Then I delete the web part. Then I decide to add the same web part back on the page. And when I add the web part - I can see the content that I added to the web part prior to deleting it. Shouldn't the content have been deleted when I deleted the web part? I am a bit confused here. Please advise.

Thanks

User avatar
Member
Member
kentico_michal - 2/10/2011 5:52:31 AM
   
RE:Web parts - content remains when the web part is deleted and then placed back
Hi,

Well, content of Editable text web part and Editable image web part is stored in particular document where one of these web parts is placed. So the content won't be deleted when you remove the web part. You can take a look into DocumentContent field ( CMS_Document table ) to see the content of particular document.
If you have Editable text web part with ID=editabletext, you will see something like this:

<webpart id="editabletext;af313209-5951-4cfd-8ae3-9a54b1c1b782"><![CDATA[content of editable text web part]]></webpart>

So if you delete this web part, the content will be still available in DocumentContent field and if you add Editable text web part on the page the content will be applied in the newly added web part.

Best regards,
Michal Legen

User avatar
Member
Member
dima - 2/10/2011 6:14:46 AM
   
RE:Web parts - content remains when the web part is deleted and then placed back
Hi Michal,

Thanks for the explanation. I still don't understand the advantage of this and still don't see why it was implemented this way.
Because when we remove a webpart from a page doesn't it mean that we would like to get rid of the content as well? This is really confusing.

User avatar
Member
Member
kentico_michal - 2/10/2011 9:01:32 AM
   
RE:Web parts - content remains when the web part is deleted and then placed back
Hi,

In general data can be stored as a part of document or a template.
The point is that in case of document it allows you to have different data within Editable image/text web part on one template which is used on more documents. If the data were stored as a part of template you would get the same content on each document.

Best regards,
Michal Legen

User avatar
Member
Member
dima - 2/10/2011 9:26:15 AM
   
RE:Web parts - content remains when the web part is deleted and then placed back
I don't want the data to be stored as a part of template or document :) Sorry if I didn't make myself clear.

I think that the data should be relevant to a webpart placed inside specific document version.
So when we delete a webpart from a document the data that is relevant to the webpart should be removed from the database. At least that's what I think. What's the point of storing the data of the deleted webpart?

So when we remove a webpart editabletext;af313209-5951-4cfd-8ae3-9a54b1c1b782 from a context I would make sense if the following content would be removed from the database as well:

<webpart id="editabletext;af313209-5951-4cfd-8ae3-9a54b1c1b782"><![CDATA[content of editable text web part]]></webpart>

Hope that's clear.

Thank you

User avatar
Member
Member
kentico_michal - 2/11/2011 6:04:29 AM
   
RE:Web parts - content remains when the web part is deleted and then placed back
Hi Dima,

If you remove the content from Editable text web part manually, it will be deleted from CMS_Documents table for that particular document. On the other hand, if you remove the Editable text web part which has contained some content, it will be stored in the CMS_Documents table.

Please consider this by design behavior as a some kind of backup. Let’s imagine that you have template with Editable text web part. This template is used on 100 documents. You have different content within Editable text web part on each document. Now if you remove this web part from one document, it will be removed from all 100 documents which use the same template. If the content was not stored, you would lose data from each document. But the content is still available in CMS_Documents table, so if you later decide to get back, you will just add new Editable text web part with the same ID as Editable text web part you have removed and content will display.


Best regards,
Michal Legen

User avatar
Member
Member
dima - 2/11/2011 6:27:22 AM
   
RE:Web parts - content remains when the web part is deleted and then placed back
Hi Michal,

Thanks for the answer. Now I see why it's implemented this way. Still it would be great to have it configurable.

The website I've been working on has very few pages that would share the same templates. So usually the user would create a blank page using one of the preset page layouts - then the user just places web parts and configure the content. So you see why it would be a bit confusing for my users to expect that.

Anyway - thanks for the reply.

User avatar
Member
Member
kentico_michal - 2/14/2011 1:01:18 PM
   
RE:Web parts - content remains when the web part is deleted and then placed back
Hi Dima,

I truly understand your situation. Regrettably, this behavior is currently by desing. I have set this as a future requirement. And we will consider this feature for future versions of Kentico CMS.

Best regards,
Michal Legen