content blocks content deleted Topic is solved

General project discussion. NOT for help questions.
Post Reply
fadum

content blocks content deleted

Post by fadum »

Ive noticed that if you use a template with extra content blocks, then change to a template without extra blocks(by accident) the content blocks are deleted, so when you return to the correct template your content block content has gone.

I dont know if its just me but i find this worrying.

To avoid it i have made the following changes to class.content.inc.php

Comment out:

Code: Select all

		//	$query = "DELETE FROM ".cms_db_prefix()."content_props WHERE content_id = ?";
		//	$dbresult = $db->Execute($query, array($content_id));
and replace:

Code: Select all

$query = "INSERT INTO ".cms_db_prefix()."content_props (content_id, type, prop_name, 
param1, param2, param3, content) VALUES (?,?,?,?,?,?,?)";
with:

Code: Select all

$query = "REPLACE ".cms_db_prefix()."content_props (content_id, type, prop_name, 
param1, param2, param3, content) VALUES (?,?,?,?,?,?,?)";
May help someone concerned about content loss
iNSiPiD

Re: content blocks content deleted

Post by iNSiPiD »

Sh!t. I'd never considered that possibility. That definitely explains the loss of much of my earlier content.  :-X

How embarassment.

Wishy, I know you transitioned the upgrade automatically with the old 'head' content field beautifully, but this sounds like a beach to solve.

A simple template change by an uninformed content editor could result in lost data; and imagine the result if they set the template site-wide!
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: content blocks content deleted

Post by Ted »

But it shouldn't have been doing the delete unless you were saving the content, right?

What is particularly weird is that I have a bug saying the exact opposite.  http://dev.cmsmadesimple.org/tracker/in ... 6&atid=101
iNSiPiD

Re: content blocks content deleted

Post by iNSiPiD »

You understood that? I think I need a translation for that post.

What he is saying, I think, is that if he changes the {content} block in his template to {content block="content-header"} after having entered content for that page, that instead of having the content disappear it now appears in both places?

Isn't this the same probelm I had yesterday with my cutsom 404 page,  where duplicate content was being rendered in both the head and content of the page? And in my case the template didn't even have a second content block in it.

What I was suggesting in my earlier post above is, what happens if you have a template with multiple content blocks in it that is used across your site, and then some n00b comes along and sets another template with only the standard {content} block in it to the entire site?

Where does the data go? How is it stored?
jab
Forum Members
Forum Members
Posts: 60
Joined: Sun Oct 30, 2005 4:21 am

Re: content blocks content deleted

Post by jab »

I experienced the same problem with CMS 10.3. I had added extra content blocks to a template. When I switched to another template or renamed one of the content blocks my content was deleted in all the content blocks. Since I was just starting out with this CMS I didn't report it.

Regards,
Jab
iNSiPiD

Re: content blocks content deleted

Post by iNSiPiD »

wishy has informed me that the content doesn't get deleted from the database. So, if you re-apply your content blocks to the template and use the correct block names, the old content should return to the pages that have that template applied.
fadum

Re: content blocks content deleted

Post by fadum »

How can that be true with

$query = "DELETE FROM ".cms_db_prefix()."content_props WHERE content_id = ?";

deleting all content from that page when submit
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: content blocks content deleted

Post by Ted »

Keep in mind that I didn't research the code at all yet.  I'm just getting two conflicting stories, which is just strange.

From what I remember (I don't have time to dig at the moment)...

If you change the template (which has less content blocks) while editing a page and then hit Save or Apply, the content blocks would go away.

If you did a global template change, they wouldn't, because that goes around the content object and just hits the database directly.

Now, if you're editing content, change the template and then change it back before Saving, it should come back.

If you remove a content block from a template, but never save the content, then it'll still be there after you change your template back.

Are we saying it should never go away?  There could be stuff stuck in the database for months that's never seen again because of a template change...
westis

Re: content blocks content deleted

Post by westis »

I think we're talking about two different things.

The issue with content blocks is, as fadum points out, that someone may just play around with different templates for fun, some templates containing just the {content} tag and others containing also {content block='name'} tag(s).

Then it would be very sad to lose content that has been added to a content block when that person too late is realizing that that template didn't include a content block tag...

My suggestion is that content entered into content blocks should always be kept in the database and only deleted if the entire page is deleted.

What WiseQ is writing about in his bug report has nothing to do with content blocks, but only the fact that a page that previously had the content-type content still has a template assigned when it is made into a section-header. But of course a section-header cannot use a template, so the template associated with a content item should be deleted when that content item is made to a section header.

Also, the content is kept for that page when it becomes a section header. But that is a very different thing to selecting a different template for a page, as section-header and content are two completely different types of content. I think that a page that is changed from the content-type content to the content-type section header should have its content deleted, like WiseQ writes in his bug report. But to make sure, there should then be a warning saying that content will be deleted when clicking save.

So to me, we talk about two different things and personally I agree with both iNSiPiD and WiseQ ;D
Last edited by westis on Wed Dec 14, 2005 4:07 pm, edited 1 time in total.
westis

Re: content blocks content deleted

Post by westis »

Well, an additional thought, to avoid stuff being kept in the database if not used, is to ask the user if he/she wants to keep the content in the additional content blocks if selecting a template that does not contain a placeholder for it (when saving).

Then the user can select either to delete that content or to keep it for later if changing back to the previous template, alternatively add a placeholder for the content block in the template to accomodate for that content also in that template.
fadum

Re: content blocks content deleted

Post by fadum »

westis wrote: Well, an additional thought, to avoid stuff being kept in the database if not used, is to ask the user if he/she wants to keep the content in the additional content blocks if selecting a template that does not contain a placeholder for it (when saving).

Then the user can select either to delete that content or to keep it for later if changing back to the previous template, alternatively add a placeholder for the content block in the template to accomodate for that content also in that template.
I agree that would be good idea,

As i have it in the mod above i just delete content from the wysiwyg before submitting if i want to delete alltogether
iNSiPiD

Re: content blocks content deleted

Post by iNSiPiD »

"But of course a section-header cannot use a template..."

This is indeed a very handy piece of information to know. I assume it's written down somewhere?

For me it all comes down to safeguards. If an action (even a Delete button) has the capacity to delete or 'lose' content, then a dialog box should appear. Yes, it makes for more bloated code, but it also makes for many more happy campers.

And we all want happy campers, don't we? :)
westis

Re: content blocks content deleted

Post by westis »

iNSiPiD wrote: "But of course a section-header cannot use a template..."

This is indeed a very handy piece of information to know. I assume it's written down somewhere?
Well, I put it that way as I thought I stated the obvious. A template is the layout for the page. But a section header is just some text in the menu, so naturally it is not using a template (and when creating a new content with the content-type header from the beginning, no template is assigned to it).

But sure it's possible to style it using CSS as a section header always has a class. Well, now that I look at it, it does get a class when using bulletmenu (.bullet_sectionheader), but not when using EllNav or CSSMenu...

Hmm... I've actually never used Section Headers myself... Not sure if those are bugs in CSSMenu and EllNav or the section headers simply weren't considered an option when using those menus?!?

And sure we still do lack proper documentation, but it is in the working, be sure! ;D
Post Reply

Return to “General Discussion”