[ ... SORRY FOR THE LONG POST ... ]

Hello! First off I love CakePHP, I was having issues working with RoR
but CakePHP allows me to actually do something. I have played around
with CakePHP and have learned a lot from my mistakes and the great
people that have put up great examples and answers to peoples
questions.

I am having one problem now that I can't seem to find a right answer
to, maybe I am just not understanding what I am trying to do or just no
one has attempted it(which I highly doubt I am sure it has been done).

What I am trying to do is a simple idea yet it is driving me crazy.

I am trying to create a Notes App for my local work server ... like the
one Fabio Cevasco did @
http://www.sitepoint.com/article/application-development-cakephp but I
want to have categories(or tags even). Simple enough right? Not for me
:-( .

When I go to localhost/notes/ it lists the notes along I even have the
Category matching up with the Notes Post. I go to
localhost/notes/view/1 and again no problem I see the note and the
category in which it is in.

When I visit localhost/categories/ it lists the categories and when I
visit localhost/categories/view/1 (for the first category) I get errors
telling me this "Notice: Undefined index: Note in ...../view.thtml on
line ##".

How would I be able to have the list of Notes show up under the
category it is under?

Here is some of the snips of my code.

Table Setup:

Notes
--------------
id
title
body
created
modified
category_id

Category
----------------
id
title



Notes Model:
----------
    var $name = 'Note';
     var $belongsTo = array ('Category' => array(
        'className' => 'Category',
        'conditions' =>'',
        'order' =>'',
        'foreignKey' => 'category_id')
    );

Category Model:
---------
    var $name = 'Category';
    var $hasMany = array ('Note' => array(
        'className' => 'Note',
        'conditions' =>'',
        'order' =>'',
        'foreignKey' => 'category_id')
    );



Notes Controller:
----------
    var $name = 'Notes';
   // var $scaffold;

        function index()
        {
                $this->set('data', $this->Note->findAll());
        }

        function view($id)
        {
                $this->set('data', $this->Note->read());
        }

Categories Controller
----------
    var $name = 'Categories';
    //var $scaffold;

        function index()
        {
                $this->set('data', $this->Category->findAll());
        }

        function view($id)
        {
                $this->set('data', $this->Category->read());
        }



Categories View.thtml
----------
<div class="title">
    <h4><?php echo $data['Category']['title']; ?></h4>
</div>
<div class="content">
<table border="1">
    <tr>
        <th>Title</th>
        <th>Created</th>
        <th>Actions</th>
    </tr>
    <?php foreach ($data as $row): ?>
    <tr>
        <td>
            <?php echo $html->link($row['Note']['title'],
'/notes/view/'.$row['Note']['id']) ?>
        </td>
        <td>
            <?php echo $row['Note']['created'] ?>
        </td>
        <td>
            <?php echo $html->link('View',
'/notes/view/'.$row['Note']['id']) ?>
            &nbsp;|&nbsp;
            <?php echo $html->link('Edit',
'/notes/edit/'.$row['Note']['id']) ?>
            &nbsp;|&nbsp;
            <?php echo $html->link('Delete',
'/notes/delete/'.$row['Note']['id'], null, 'Are you sure you want to
delete "'.$row['Note']['title'].'"?') ?>
        </td>
    </tr>
    <?php endforeach; ?>
</table>
</div>



Now this all works perfect if I enable Scaffolding but when I comment
out Scaffolding I get the errors.

What am I doing wrong? Please help.


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