Sunday, October 19, 2014

Re: Unable to retrieve data in browser from the *.ctp files

Please clarify how you are trying to reach the Posts index view in your browser.

I assume that you are reaching it by using an URL similar to this: "http://localhost/posts/index"

Enjoy, John

On Saturday, 18 October 2014 01:24:30 UTC+3, shesar wrote:
I have added the model, controller and able to retrieve the view files from the browser but the data from the arrays is not being displayed. So I am sure I am missing something here.

If I try to bring up:

I see the following on the browser:
                               Id Title Created

Html->link($post['Post']['title'], array('controller' => 'posts', 'action' => 'view', $post['Post']['id'])); ?>

The php code is not being compiled in index.ctp. What am I missing? 

The code behind index.ctp is what you have in your documentation as follows:
<!-- File: /app/View/Posts/index.ctp -->    <h1>Blog posts</h1>  <table>      <tr>          <th>Id</th>          <th>Title</th>          <th>Created</th>      </tr>        <!-- Here is where we loop through our $posts array, printing out post info -->        <?php foreach ($posts as $post): ?>      <tr>          <td><?php echo $post['Post']['id']; ?></td>          <td>              <?php echo $this->Html->link($post['Post']['title'],  array('controller' => 'posts', 'action' => 'view', $post['Post']['id'])); ?>          </td>          <td><?php echo $post['Post']['created']; ?></td>      </tr>      <?php endforeach; ?>      <?php unset($post); ?>  </table>

--
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 cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: