The above code is not working ... Anybody help me to find the right
solution?

On Jan 17, 2:27 pm, "aerosmith" <[EMAIL PROTECTED]> wrote:
Thanks Mike,

Let me show my code I may have missed something.
This is the model for the element
<?php

class Recentpost extends AppModel (recentpost.php)
{
    var $name = 'Recentposts';

}?>

The following is the controller: (recentposts_controller.php)

<?php

class Recentposts extends AppController
{
    var $name = 'Recentposts';

        function recent(){
                $this->set('recentposts', $this->requestAction('/posts/index',
array('return')));
        }

}?>

this is the element code:  (recentposts.thtml)

<table>
    <tr>
        <th>Id</th>
        <th>Title</th>
        <th>Created</th>
    </tr>

   <!-- Here's where we loop through our $posts array, printing out
post info -->
    <?php foreach ($recentposts as $post): ?>
    <tr>
        <td><?php echo $post['Recentposts']['id']; ?></td>
        <td>
            <?php echo $html->link($post['Recentposts']['title'],
"/posts/view/".$post['Recentposts']['id']); ?>
        </td>
        <td><?php echo $post['Recentposts']['created']; ?></td>
    </tr>
    <?php endforeach; ?>
        </table>

This is how I included the element in my default.thtml
<?php echo $this->renderElement('recentposts');?>

Is this the right way to add a recent posts block in my
default.thtml????

Thanks

On Jan 16, 7:25 pm, "Mikee Freedom" <[EMAIL PROTECTED]> wrote:

> morning mate,

> Have you gone through the manual yet?

> The blog tutorial is good, but I've got to recommend some serious
> reading time with the manual and the Bakery.

> Elements are not necessarily attached to any particular model or
> controller, just pieces of code that may be repeated throughout your
> site. If you would like to print news information you need to pass
> that news data to the view before it is accessible at that level.

> What you might be looking for is requestAction on another controller.
> But that is another story entirely.

> Have a bit of a look in the manual for elements and controllers /
> requestAction and I think you should find what you neeed.

> cheers,
> mikee

> On 17/01/07,aerosmith<[EMAIL PROTECTED]> wrote:

> > Hi,

> > I've spent the last week searching for some good "phpframework".
> > Finally I dropped by cakephp.org and within 2 hours I did the blog
> > tutorial. Every thing seems clear.

> > Now I have a question regarding including blocks that contains dynamic
> > data into my default.thtml.

> > Here's what I've done.

> > I've created an element in views/elements/ called latestnews.php

> > <div class="block newsblock" id="newsblock">
> >         <h2>Latest News</h2>
> >         <div class="content">
> >                 <ul>
> >                         <?php foreach ($news as $newsitem): ?>
> >                                 <li><?php echo 
$html->link($newsitem['News']['title'],
> > "/news/view/".$newsitem['News']['id']);?></li>
> >                         <?php endforeach; ?>
> >                 </ul>
> >         </div>
> > </div>

> > did not seem to work.
> > the question is:
> > Do I need to create a model and controller for each element? or I can
> > just use a controller previously made for a page view?
> > Is there a place where I can see a more advanced example than the blog
> > tutorial?

> > Your reaply is highly appreciated
> > Raffi Hovhannesian
> >http://www.hovhannesian.com


--~--~---------~--~----~------------~-------~--~----~
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