hi cricket,... 
the codes are simple, displaying photo comments and blog comments with 
limit to 12 from controller, and they works when each one is called 
separately in home page view ... I want to combine them in ONE array on 
first come first served bases.... (some user post on Blog,... and some user 
post on Photo),... 
$i is used for how many to display in a view,... e.g. $i++ up to 12, setup 
from controller,... 

this is for photo comments (in home page): 

  <?php $i = 0 ?>

  <?php foreach($friends_photo_comments as $photo_comment): ?>

<div style="float: left; margin: 5px 0 15px 5px; width: 485px; 
 border-bottom: 1px dotted #aaa; display: block; overflow: hidden;">

       <div style="float: left; width: 480px; margin: 10px 0 5px 0;">

       <div style="float: left; width: 50px; margin: 0 0 5px 0; ">
      <?php echo $html->link($profileShow->buddy($photo_comment, 
array('style' => 'border: 1px solid #2F2E2F;')), '/profile/' . 
$photo_comment['User']['username'], array('escape'=>false, 'style' => 
'float: left;')) ?>
</div>


      <div style="float: left; width: 425px; ">

      <div style="float: left; width: 400px; margin: 5px 0 5px 10px; 
font-size: 12px; display: block; overflow: hidden; ">
  <?php echo ucfirst(__('by', true)) ?>: 
      <?php echo 
$html->link($application->cut($photo_comment['User']['firstname'] . ' ' . 
$photo_comment['User']['lastname'], 25), '/profile/' . 
$photo_comment['User']['username'], array('style' => 'color: #000;')) ?>
    <div class="clr"></div>
  <?php echo ucfirst(__('comment on', true)) ?>: 
      <?php echo 
$html->link($application->cut($photo_comment['PhotoUser']['firstname'] . ' 
' . $photo_comment['PhotoUser']['lastname'], 25), '/profile/' . 
$photo_comment['PhotoUser']['username'], array('style' => 'color: #000;')) 
?>
  <?php echo (__('photo', true)) ?>
</div>

    <div class="clr"></div>

<div style="float: left; margin: 5px 0 0 10px; width: 400px; text-align: 
center;">
      <?php echo $html->link($photoShow->medium($photo_comment, 
array('style' => 'border: 1px solid #2F2E2F;')), '/photos/show/' . 
$photo_comment['Photo']['id'], array('escape'=>false)) ?>
</div>

    <div class="clr"></div>

<div style="float: left; margin: 2px 0 0 10px; width: 400px; text-align: 
center; font-size: 11px;">
      <?php echo $html->link(ucfirst(__('commnets', true)) . ' - ' . 
$photo_comment['Photo']['comments'], '/photos/show/' . 
$photo_comment['Photo']['id'], array('class' => 'comments16px')) ?> 
  
<?php echo $html->link(__('report/spam', true), '/report/photo/' . 
 $photo_comment['Photo']['id'], array('class' => 'report')) ?>
  
      <span class="comment"></span> <span style="color: #aaa;"><?php echo 
$application->timeAgo($time, $photo_comment['PhotoComment']['created']) 
?></span>
      </div>

    <div class="clr"></div>

      <div style="float: left; margin: 10px 0 10px 10px; width: 400px; 
font-size: 1.1em; font-weight: normal; display: block; overflow: hidden; ">
<?php echo 
$smile->replaceByIcon(nl2br($application->cut($photo_comment['PhotoComment']['content'],
 
125))) ?>
</div>

    <div class="clr"></div>

      </div>
       </div>
   </div>

  <div class="clr"></div>

  <?php $i++ ?>
  <?php endforeach ?>

  <div class="clr"></div>

and this is for blog comments (in home page as well): 


  <?php $i = 0 ?>

<?php foreach($friends_blog_comments as $blog_comment): ?>

<div style="float: left; margin: 5px 0 15px 5px; width: 485px; 
 border-bottom: 1px dotted #aaa; display: block; overflow: hidden;">

      <div style="float: left; width: 480px; margin: 10px 0 5px 0;">

      <div style="float: left; width: 50px; margin: 0 0 5px 0; ">
      <?php echo $html->link($profileShow->buddy($blog_comment, 
array('style' => 'border: 1px solid #2F2E2F;')), '/profile/' . 
$blog_comment['User']['username'], array('escape'=>false, 'style' => 
'float: left;')) ?>
</div>


      <div style="float: left; width: 425px; ">

      <div style="float: left; width: 400px; margin: 5px 0 5px 10px; 
font-size: 12px; display: block; overflow: hidden; ">
  <?php echo ucfirst(__('by', true)) ?>: 
      <?php echo 
$html->link($application->cut($blog_comment['User']['firstname'] . ' ' . 
$blog_comment['User']['lastname'], 25), '/profile/' . 
$blog_comment['User']['username'], array('style' => 'color: #000;')) ?>
    <div class="clr"></div>

  <?php if(($blog_comment['User']['id']==$blog_comment['BlogUser']['id'])): 
?> 
  <?php echo ucfirst(__('comment on own', true)) ?> 
    <?php else: ?>
  <?php echo ucfirst(__('comment on', true)) ?>: 
      <?php echo 
$html->link($application->cut($blog_comment['BlogUser']['firstname'] . ' ' 
. $blog_comment['BlogUser']['lastname'], 25), '/profile/' . 
$blog_comment['BlogUser']['username'], array('style' => 'color: #000;')) ?>
  <?php endif ?>
  <?php echo (__('blog', true)) ?>
</div>

    <div class="clr"></div>

<div style="float: left; margin: 5px 0 0 10px; width: 400px; text-align: 
left;">

<strong><?php echo ucfirst(__('title', true)) ?>:  </strong> 
<?php echo $html->link($application->cut($blog_comment['Blog']['name'], 
65), '/blogs/show/' . $blog_comment['Blog']['id']) ?>

</div>

    <div class="clr"></div>

      <div style="float: left; margin: 5px 0 10px 10px; width: 400px; 
font-size: 1.1em; font-weight: normal; display: block; overflow: hidden; ">
<?php echo 
$smile->replaceByIcon(nl2br($application->cut($blog_comment['BlogComment']['content'],
 
110))) ?>
<?php echo $html->link(ucfirst(__('read more', true)) . ' ' . '>>', 
'/blogs/show/' . $blog_comment['Blog']['id'], array('style' => 'color: 
#F62D0A;')) ?>
</div>


<div style="float: left; margin: 5px 0 10px 10px; width: 400px; text-align: 
left; font-size: 11px;">
      <?php echo $html->link(ucfirst(__('commnets', true)) . ' - ' . 
$blog_comment['Blog']['comments'], '/blogs/show/' . 
$blog_comment['Blog']['id'], array('class' => 'comments16px')) ?> 
  
<?php echo $html->link(__('report/spam', true), '/report/blog/' . 
 $blog_comment['Blog']['id'], array('class' => 'report')) ?>
  
      <span class="comment"></span> <span style="color: #aaa;"><?php echo 
$application->timeAgo($time, $blog_comment['BlogComment']['created']) 
?></span>
      </div>

    <div class="clr"></div>

      </div>
       </div>
   </div>

  <div class="clr"></div>

  <?php $i++ ?>
  <?php endforeach ?>

  <div class="clr"></div>


On Tuesday, November 27, 2012 1:11:39 PM UTC-8, cricket wrote:
>
> It's not clear what it is you want to do. Perhaps if you showed us the 
> code in between. Specifically, what is $i used for? 
>
> On Tue, Nov 27, 2012 at 5:15 AM, Chris <[email protected] <javascript:>> 
> wrote: 
> > hi guys,... can anyone help please,... 
> > I have 2 foreach statements in my view,... 
> > 
> > how can I combine two or more foreach statements to one,... ? 
> > 
> >   <?php $i = 0 ?> 
> >   <?php foreach($friends_photo_comments as $photo_comment): ?> 
> > [code].... 
> >    <?php $i++ ?> 
> >   <?php endforeach ?> 
> > 
> >    <?php $i = 0 ?> 
> > <?php foreach($friends_blog_comments as $blog_comment): ?> 
> > [code].... 
> > <?php $i++ ?> 
> >   <?php endforeach ?> 
> > 
> > thanks in advance, 
> > chris 
> > 
> > -- 
> > 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 post to this group, send email to [email protected]<javascript:>. 
>
> > To unsubscribe from this group, send email to 
> > [email protected] <javascript:>. 
> > Visit this group at http://groups.google.com/group/cake-php?hl=en. 
> > 
> > 
>

-- 
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to