It's pretty simple right now. Upon save, the html will be HTMLTidy'd, and a
stripped copy will be saved to the database alongside html copy.
There's not much else there. In the view, I have TinyMCE enabled currently,
but I've tested with TinyMCE removed, still no HTML showing in the returned
content (both preview and body should have complete html returned)


Controller:

    function edit($id = null)
    {
        if (empty($this->data))
        {
            $this->Content->id = $id;
            $this->data = $this->Content->read();
        }else{
            if ($this->Content->validates($this->data))
            {
                $tidy_installed = phpversion('tidy');
                if($tidy_installed &&
version_compare($tidy_installed,'2.0','>=')
&& TIDY_OUTPUT) {
                    $tidy = new tidy();
                    $tidy_config = array(    'indent' => true,
                    'indent-spaces' => 2,
                    'output-xhtml' => true,
                    'show-body-only' => true,
                    'clean' => true,
                    'wrap' => 200,
                    'drop-proprietary-attributes' => true,
                    'logical-emphasis' => true
                    );
                    $this->data['Content']['body'] =
$tidy->repairString($this->data['Content']['body'], $tidy_config, 'utf8');
                }
                $this->data['Content']['text_body'] =
strip_tags($this->data['Content']['body']);
                $this->Content->save($this->data);
                $this->redirect('/content/contentList');
            } else {
                $this->validateErrors($this->Content);
            }
        }
    }


View:

<?php echo $this->renderElement('tinymce',array('preset' => 'basic')); ?>
<?php echo $html->formTag('/content/create' . $html->tagValue('Content/id'))
?>
<p>Please fill out the form below to create an article.</p>

<p>
<label>Article Title:</label>
<?php echo $html->inputTag('Content/title', array('size' => '60',
'maxlength' => '255')) ?>
<?php echo $error->forField('Content/title') ?>
</p>

<p>
<label>Article Preview:</label>
<?php echo $html->textarea('Content/preview', array('cols'=>'30',
'rows'=>'10')); ?>
<?php echo $error->forField('Content/preview') ?>
</p>

<p>
<label>Article Body:</label>
<?php echo $html->textarea('Content/body', array('cols'=>'60',
'rows'=>'20')); ?>
<?php echo $error->forField('Content/body') ?>
</p>

<?php echo $html->hidden('Create/id')?>
<?php /* echo $html->hidden('create/submitter_id',
$this->controller->Session->read('User.id')) */ ?>
<?php echo $html->submitTag('create') ?>
</form>

On 6/11/07, Ketan Patel <[EMAIL PROTECTED]> wrote:
>
>
> if you could post some code then perhaps could help better.
>
>
> intel352 wrote:
> > I'm building my first Cake application. I've started a controller that
> > is used for creating/editing Content articles, and it saves to the
> > database with a full-html 'teaser', full-html article and a stripped-
> > html article (for cleaner searching), which works perfect.
> >
> > When I am attempting to edit, though, the copy is returned from the
> > database with all html already stripped, which is *not* what I
> > need :-)
> >
> > Any ideas on what's going wrong?
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to