Can anyone help me with editing post_tags ???

classic Classic list List threaded Threaded
4 messages Options
lil
Reply | Threaded
Open this post in threaded view
|

Can anyone help me with editing post_tags ???

lil
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone help me with editing post_tags ???

Eric Haskins
What are you trying to do??  Example code?
 

Eric 

On Wednesday, June 19, 2013 4:55:49 AM UTC-4, Lilit Bakunts wrote:




--
View this message in context: http://cakephp.1045679.n5.nabble.com/Can-anyone-help-me-with-editing-post-tags-tp5715315.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
lil
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone help me with editing post_tags ???

lil
this is a part of code for adding topic with tags

                    $save = $this->Topic->save($data['Topic']);
                    if($save){
                        $tags = explode(',', $data['Topic']['tags']);
                        foreach($tags as $tag){
                            $tag = strtolower(trim($tag));
                            if($tag){
                                $foundTag = $this->Tag->find(
                                        'first', array(
                                    'conditions' => array(
                                        'Tag.title' => $tag
                                    )
                                        )
                                );
                                if($foundTag){
                                    $topicTags['TopicTag']['tagId'] = $foundTag['Tag']['id'];
                                }else{
                                    $this->Tag->create();
                                    $savedtag = $this->Tag->save(array('Tag' => array('title' => $tag)));
                                    $topicTags['TopicTag']['tagId'] = $savedtag['Tag']['id'];
                                }
                                $topicTags['TopicTag']['topicId'] = $save['Topic']['id'];
                                $this->TopicTag->create();
                                $this->TopicTag->save($topicTags);
                            }
                        }

i have problems with editing,, have to find all tag id before editing and after editing, something like that,
there's three tables
topics, tags and topic_tags with topicId and tagId,
sorry for bad explanation
thanks
lil
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone help me with editing post_tags ???

lil
i forgot the view

Edit Topic

<?php
echo $this->Form->create('Topic', array('type' => 'file'));

echo $this->Form->input('id', array(
    'type'=>'hidden',
    'value' => $topic['Topic']['id']
));

echo $this->Form->input('title', array(
    'type' => 'text',
    'error' => array('class' => 'error-message'),
    'label' => 'Title',
    'value' => $topic['Topic']['title']
));

echo $this->Form->input('description', array(
    'type' => 'textarea',
    'error' => array('class' => 'error-message'),
    'label' => 'Description',
    'value' => $topic['Topic']['description']
));

    $topicTag='';
    foreach($editTags as $editTag){
        $topicTag.=$editTag['Tag']['title'].' ';
    }
echo $this->Form->input('tags', array(
    'type'=>'text',
    'error' => array('class' => 'error-message'),
    'label' => 'Tags',
    'value' => $topicTag
));

so can you help? :(