Welcome Guest, Not a member yet? Register   Sign In
Save content with CI and TinyMCE
#1

[eluser]Alex91[/eluser]
How can I save the data with CI and TinyMCE?
Without ruining the make-up of the text?

This is how the data get's stored and showed:
Code:
<p> Here the text. </p>

This is how I use it atm.

Model:
Code:
function edit($id, $data)
        {
                $this->db->query("UPDATE `pages` SET `title` = ".$this->db->escape($data['title']).", `content` = ".$this->db->escape($data['content']).", `slug` = ".$this->db->escape($data['slug'])." WHERE `id` = '$id'");
        }

Controller:
Code:
function edit($id)
        {

                $this->load->helper(array('form', 'url'));

                $this->load->library('form_validation');

                $this->form_validation->set_rules('title', 'Page Title', 'required');
                $this->form_validation->set_rules('content', 'Content', 'required');

                if($this->form_validation->run() == FALSE)
                {
                        $data = $this->pages->pages($id);

                        $this->auth->view('pages/edit', $data[0]);
                }
                else
                {
                        $data['title'] = set_value('title');
                        $data['content'] = set_value('content');
                        $data['slug'] = url_title($data['title'], 'underscore', TRUE);

                        $this->pages->edit($id, $data);

                        $this->auth->view('pages/edit_success');
                }
        }

View:
Code:
<?php echo set_value('content', $content); ?>
#2

[eluser]umefarooq[/eluser]
hi you to do some settings in tinymce init

Code:
force_p_newlines : false,
force_br_newlines : true,
valid_elements : 'b/strong,i/em,u,strike,br'
it will not add p tag and it will allow only valid HTML elements
#3

[eluser]Alex91[/eluser]
That doesn't work.
I gues that the problem is @ the model.

Where all data get's escaped.
But how to not escape that?
#4

[eluser]thinkbliss[/eluser]
I'm responding because I'm having a very similar problem and I'd like to see if someone can solve it.. Before I thought I needed to encode the HTML in the view but that didn't work either. Depending on which method I use, I either end up with the tags outputting at text as in <p>Word</p> or as the non entity &lgt;Word&rgt;. I'm using the form_validation library as well which I thought might be the issue but upon further testing, removing didn't work either. Not sure what the problem is but I thought integrating tinymce with CI was supposedly easy and I'm sure it is. Hope someone has idea for a solution.
#5

[eluser]jjmax[/eluser]
Hi,

I had a problem similar to this yesterday.
I think I found a solution - Have a look at this thread - http://ellislab.com/forums/viewthread/141495/
#6

[eluser]thinkbliss[/eluser]
Wow jjmax. I had a clue that the form helper may be the cause of the issue. Setting up my forms without it was on my list of troubleshooting tasks. Thank you. I'll give it a try.




Theme © iAndrew 2016 - Forum software by © MyBB