Okay so, I'm building a way to show my categories (rubriques) and my
articles.

Here's the model of my rubrique (categorie):
<?php

class Rubrique extends AppModel
{
var $name = 'Rubrique';

//I tried this:
    var $belongsTo = array('Article' =>
                           array('className'  => 'Article',
                                 'conditions' => '',
                                 'order'      => 'Article.id DESC',
                           )
                     );

}

?>
I want to associate the controller Rubriques with two tables: the one
called "rubriques" and the one called "articles".

I'll explain the system: i go to /rubriques and it shows me the
different categories of the website.
I click on one, for example Membres, so i get onto this page:
/rubriques/membres (it works with something like slugs).

On this page I want to get all the articles of this categorie (select *
from articles where slug='membres') (in mysql query) (but i dont know
how to do it with cakephp)...

Here's the Rubriques controller:
<?php

class RubriquesController extends AppController
{
    var $name = 'Rubriques';

function index()
        {
                        $this->set('rubriques', $this->Rubrique->findAll());
        }

function consulter($nom)
        {

                  $this->Rubrique->nom = $nom;
                  $this->set('rubrique', $this->Rubrique->findbynom($nom));

//I'm trying to get the articles, I tried many things, but unhelpful...
                  $this->Rubrique->findbycategorie($nom);


        }
}

?>

The view of index from Rubriques is:
<div id="titre">
        <div class="titre">
                <div class="image">
                        <img src="/img/rubriques/rubriques.png">
                </div>
                <div class="conteneur">
                        <div class="titre">Rubriques</div>
                        <div class="description"><p>Fouillez sti!</p></div>
                </div>
        </div>
</div>

<?php foreach ($rubriques as $rubrique): ?>
<div id="rubrique">
        <div class="image"><img src="<? echo
"/img/rubriques/".$rubrique['Rubrique']['image']; ?>"></div>

        <div class="texte">
                <?php echo $html->link($rubrique['Rubrique']['titre'],
"/rubriques/consulter/".$rubrique['Rubrique']['nom']);
                echo "<p>".$rubrique['Rubrique']['description']."</p>"; ?>
        </div>
</div>
<?php endforeach; ?>

(and it works well).

But the one of consulter (that means consult) (to consult a category
(to see their articles)):
<div id="titre">
        <div class="titre">
                <div class="image">
                        <img src="/img/rubriques/<? echo 
$rubrique['Rubrique']['image'];
?>">
                </div>
                <div class="conteneur">
                        <div class="titre"><? echo 
$rubrique['Rubrique']['titre']; ?></div>
                        <div class="description"><p><? echo
$rubrique['Rubrique']['description']; ?></p></div>
                </div>
        </div>
</div>
Here's is supposed to be something like a foreach showing the
articles... But i dont know how...

I asked on the channel of cakephp, but peoples are a bit rough on n00b
there... :S

So If someone can help me, HELP ME... I dont want flames, only helpful
comments, thanks a lot!


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

Reply via email to