Jump to content

CMS Tutorial - having issues


ben545

Recommended Posts

Hey, I downloaded out of the box the cms tutorial, the new one. Flight CMS. It all works great! Except when you try to save special characters / commas, it won't save to the db, and just deletes everything in the content block. Any guidance?

Link to comment
Share on other sites

Hey Ben,

 

Thanks for the comment. I'll have to take a look at this issue and get back to you. If this is an issue (I'm assuming you are working from my original files, without any modifications?) hopefully the fix will be relatively simple. Since the CMS allows a couple types of content blocks (textarea, one line text input and WYSIWYG field, if I remember correctly) is it all those types that are having issues? Or one specific one?

Link to comment
Share on other sites

OK, I think I've figured out the issue. This is something that makes sense, but I just didn't think to test for it. Basically, when you are using jQuery's Ajax functionality, it passes all of the data along as a string, with an "&" separating each variable in the string. So "&" characters will obviously break things.

 

If you change this line on 14 of app/cms/view/v_edit.php:

 

var content = $('#field').val();

to

 

var content = encodeURIComponent($('#field').val());

that seemed to fix things for me. Can you put this change in place, and let me know if that took care of things? If so, I'll have to add a short video at the end of the series mentioning this bug fix.

 

See http://www.w3schools.com/jsref/jsref_encodeuricomponent.asp for a description of that function.

Link to comment
Share on other sites

  • 4 months later...

Yes, that worked for me Ben.

 

I had the same issue and spend some time researching.

 

There is also another solution.

In ajax call instead of

$.ajax({
      type: "POST",
      url: "<?php echo SITE_PATH;?>/app/cms/edit.php",
      data: dataString,
      cache: false,
      success: function(html) { $('#cboxLoadedContent').html(html); }
});

can be used that:

$.ajax({
      type: "POST",
      url: "<?php echo SITE_PATH;?>/app/cms/edit.php",
      data: {id: id, field: content, type: type},
      cache: false,
      success: function(html) { $('#cboxLoadedContent').html(html); }
});

and content variable gets it's value as usual:

var content = $('#field').val();

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...