$i = 0;
foreach ($articles as $article):

  if ($article['Article']['section_id'] != 1) continue;

  $class = null;
  if ($i++ % 2 == 0) {
      $class = ' class="altrow"';
  }

But it'd be better to filter on section_id in the controller to begin with.

FWIW, I prefer to do row-striping like so:

$cnt = 2;
foreach(...):
?>
...
<tr class="Row<?= ++$cnt % 2 ?>">
...

and have CSS classes Row1 & Row2.



On Mon, Feb 25, 2008 at 12:32 PM, Darkman_dd <[EMAIL PROTECTED]> wrote:
>
>  Hello. The code below is in my index View. I use it to place into a
>  table all the articles (from all sections) of my database. How can i
>  alter it to show only articles from a specific section (e.g.
>  section_id=1)?
>
>
>
>  $i = 0;
>  foreach ($articles as $article):
>    $class = null;
>    if ($i++ % 2 == 0) {
>        $class = ' class="altrow"';
>    }
>
>  echo $html->link($article['Article']['title'], array('controller'=>
>  'articles', 'action'=>'view', $article['Article']['id']));
>
>  endforeach;
>
>
>
>  Thanks in advance!
>
>  >
>

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