Jump to content
Killersites Community
Sign in to follow this  
ben545

CMS Tutorial - having issues

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?

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

WYSIWYG field, I didn't modify anything other then the init to work with my own db and file structure... it doesn't allow special characters like &.

 

I appreciate it.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×