Hello,

Model relationship: Page has many PageSnippet

I have this code:

[code]
$page = $this->Page->find('first', array(
        'conditions' => array('Page.key' => 'home'),
        ));
[/code]

It's outputting this array:

[code]
Array
(
    [Page] => Array
        (
            [id] => 1
            [key] => home
        )

    [PageSnippet] => Array
        (
            [0] => Array
                (
                    [id] => 2
                    [page_id] => 1
                    [key] => big_tagline_body
                    [text] => We deal with the hassles and keep up
with the changes in the timeshare industry. So you don't have to.
                )

            [1] => Array
                (
                    [id] => 1
                    [page_id] => 1
                    [key] => big_tagline_head
                    [text] => Finally!... You can simply take your
family on vacation!
                )
        )

)
[/code]

But I want to access a page snippet using something like this in the
view:

[code]
<?=$page['PageSnippet'][$page_snippet_key]?>
[/code]

So I need an array that looks like this:

[code]
Array
(
    [Page] => Array
        (
            [id] => 1
            [key] => home
        )

    [PageSnippet] => Array
        (
            [big_tagline_body] => Array
                (
                    [id] => 2
                    [page_id] => 1
                    [key] => big_tagline_body
                    [text] => We deal with the hassles and keep up
with the changes in the timeshare industry. So you don't have to.
                )

            [big_tagline_head] => Array
                (
                    [id] => 1
                    [page_id] => 1
                    [key] => big_tagline_head
                    [text] => Finally!... You can simply take your
family on vacation!
                )
        )

)
[/code]

Is this possible?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to