This will give you a comma-separated list of tags:
<?php
foreach($data as $note) {
// ...
echo implode(', ', Set::extract($note['Tag'], '{n}.tag'));
// ...
}
?>
hth
grigri
On Jan 7, 2:48 pm, romel <[email protected]> wrote:
> Hello everyone!
> I am just an unskilled beginner to CakePHP and trying to build my
> simple blog application. I've already implemented some basic features
> like authentification, profile editing, adding new entries and more.
>
> But I'm stuck at Tagging feature.
>
> A bit more:
>
> I want to display a full list of comma separated tags related for each
> of my Notes when running Index() function on it's controller. The
> HABTM relationship between models is successfully configured
> (following this
> article:http://bakery.cakephp.org/articles/view/simple-tagging-behavior)
> and I am getting correct array. It looks like this:
>
> Array
> (
> [0] => Array
> (
> [Note] => Array
> (
> [id] => 89
> [name] => Note's name
> [created] => 2009-01-07 03:29:40
> [modified] => 2009-01-07 03:29:40
> [content] => Note's content
> [user_id] => 1
> [note_comment_count] => 0
> [tags] => Tag1, Tag2, Tag3
> )
>
> [User] => Array
> (
> [id] => 1
> [username] => romel
> [email] => [email protected]
> [password] =>
> 8cebc1f50a8299998ff3aec7e02597e53f4a529d
> [group_id] => 2
> )
>
> [NoteComment] => Array
> (
> )
>
> [Tag] => Array
> (
> [0] => Array
> (
> [id] => 6
> [tag] => Tag1
> [NotesTag] => Array
> (
> [id] => 20
> [note_id] => 89
> [tag_id] => 6
> )
>
> )
>
> [1] => Array
> (
> [id] => 7
> [tag] => Tag2
> [NotesTag] => Array
> (
> [id] => 21
> [note_id] => 89
> [tag_id] => 7
> )
>
> )
>
> [2] => Array
> (
> [id] => 8
> [tag] => Tag3
> [NotesTag] => Array
> (
> [id] => 22
> [note_id] => 89
> [tag_id] => 8
> )
>
> )
>
> )
>
> )
> )
>
> May be it looks stupid, but I have no idea how to display it in my
> view. That's the problem.
>
> Here is a simplified piece of my notes/index.ctp:
>
> <?php foreach ($data as $note): ?>
> <h1><?=$html->link($note['Note']['name'],'/notes/view/'.$note['Note']
> ['id'], array('class'=>'notehead'));?></h1>
> <p><?=$note['Note']['content']; ?></p>
> <p>Author: <?=$html->link($note['User']['username'], array
> ('controller'=>'users', 'action'=>'profile', $note['User']['id'])); ?></p>
>
> <p>Created: <?=russian_date('j F Y, G:i',strtotime($note['Note']
> ['created'])); ?></p>
> <p><?php if($note['Note']['note_comment_count'] == null){echo
> $html->link('0','/notes/view/'.$note['Note']['id'].'#comments');} else {echo
>
> $html->link($note['Note']['note_comment_count'],'/notes/view/'.$note
> ['Note']['id'].'#comments');}; ?></p>
> <?php endforeach; ?>
>
> Give me an advice please how to make it work, please!
>
> Sincerely your, Roman Korzh.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---