Re: combine multiple foreach statements

2012-11-28 Thread lowpass
On Wed, Nov 28, 2012 at 12:30 AM, Chris  wrote:
> I don't think it's possible to do that,... each Model has its own
> comments,... and there is not only Blogs and Photos, there are Groups,
> Videos, Dba, etc,...

Comment:

public $belongsTo = array(
'User',
'Blog' => array(
'className'  => 'Blog',
'conditions' => array(
'Comment.foreign_key' => 'Blog.id',
'Comment.model' => 'Blog'
),
'foreignKey' => false
),
'Photo' => array(
'className'  => 'Photo',
'conditions' => array(
'Comment.foreign_key' => 'Photo.id',
'Comment.model' => 'Photo'
),
'foreignKey' => false
),
...
);

Blog:

public $hasMany = array(
'Comment' => array(
'className' => 'Comment',
'foreignKey' => 'foreign_key',
'conditions' => array('Comment.model' => 'Blog'),
'dependent' => true
)
);

etc.


> and I need to display them on Home page on first come
> first served bases

Then you would only need to order them by created date.

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




Re: combine multiple foreach statements

2012-11-27 Thread Chris
I don't think it's possible to do that,... each Model has its own 
comments,... and there is not only Blogs and Photos, there are Groups, 
Videos, Dba, etc,... and I need to display them on Home page on first come 
first served bases,... it's kind of a Social Network site I'm rebuilding 
from 1.2 to 1.3,... thanks for typo notice,... lol 


On Tuesday, November 27, 2012 2:50:37 PM UTC-8, cricket wrote:
>
> On Tue, Nov 27, 2012 at 5:20 PM, Chris > 
> wrote: 
> > 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,... 
>
> So you want to mix them together? Why not merge the two arrays and 
> sort by created then? 
>
> If they should be mixed, but have a maximum of 12 comments, what I 
> would do is create a Comment model that belongs to both Photo and Blog 
> (each of which hasMany Comment). In the comments table include columns 
> model and foreign_key. 
>
> BTW, you have a typo: __('commnets', true) 
>
> And if you're running 2.x you don't need to include the second parameter. 
>
> I still don't see where you're making use of $i in this code. 
>

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




Re: combine multiple foreach statements

2012-11-27 Thread lowpass
On Tue, Nov 27, 2012 at 5:20 PM, Chris  wrote:
> 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,...

So you want to mix them together? Why not merge the two arrays and
sort by created then?

If they should be mixed, but have a maximum of 12 comments, what I
would do is create a Comment model that belongs to both Photo and Blog
(each of which hasMany Comment). In the comments table include columns
model and foreign_key.

BTW, you have a typo: __('commnets', true)

And if you're running 2.x you don't need to include the second parameter.

I still don't see where you're making use of $i in this code.

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




Re: combine multiple foreach statements

2012-11-27 Thread Chris
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): 

  

  



   

   
  link($profileShow->buddy($photo_comment, 
array('style' => 'border: 1px solid #2F2E2F;')), '/profile/' . 
$photo_comment['User']['username'], array('escape'=>false, 'style' => 
'float: left;')) ?>



  

  
  : 
  link($application->cut($photo_comment['User']['firstname'] . ' ' . 
$photo_comment['User']['lastname'], 25), '/profile/' . 
$photo_comment['User']['username'], array('style' => 'color: #000;')) ?>

  : 
  link($application->cut($photo_comment['PhotoUser']['firstname'] . ' 
' . $photo_comment['PhotoUser']['lastname'], 25), '/profile/' . 
$photo_comment['PhotoUser']['username'], array('style' => 'color: #000;')) 
?>
  





  link($photoShow->medium($photo_comment, 
array('style' => 'border: 1px solid #2F2E2F;')), '/photos/show/' . 
$photo_comment['Photo']['id'], array('escape'=>false)) ?>





  link(ucfirst(__('commnets', true)) . ' - ' . 
$photo_comment['Photo']['comments'], '/photos/show/' . 
$photo_comment['Photo']['id'], array('class' => 'comments16px')) ?> 
  
link(__('report/spam', true), '/report/photo/' . 
 $photo_comment['Photo']['id'], array('class' => 'report')) ?>
  
   timeAgo($time, $photo_comment['PhotoComment']['created']) 
?>
  



  
replaceByIcon(nl2br($application->cut($photo_comment['PhotoComment']['content'],
 
125))) ?>




  
   
   

  

  
  

  

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


  





  

  
  link($profileShow->buddy($blog_comment, 
array('style' => 'border: 1px solid #2F2E2F;')), '/profile/' . 
$blog_comment['User']['username'], array('escape'=>false, 'style' => 
'float: left;')) ?>



  

  
  : 
  link($application->cut($blog_comment['User']['firstname'] . ' ' . 
$blog_comment['User']['lastname'], 25), '/profile/' . 
$blog_comment['User']['username'], array('style' => 'color: #000;')) ?>


   
   

  : 
  link($application->cut($blog_comment['BlogUser']['firstname'] . ' ' 
. $blog_comment['BlogUser']['lastname'], 25), '/profile/' . 
$blog_comment['BlogUser']['username'], array('style' => 'color: #000;')) ?>
  
  






:   
link($application->cut($blog_comment['Blog']['name'], 
65), '/blogs/show/' . $blog_comment['Blog']['id']) ?>





  
replaceByIcon(nl2br($application->cut($blog_comment['BlogComment']['content'],
 
110))) ?>
link(ucfirst(__('read more', true)) . ' ' . '>>', 
'/blogs/show/' . $blog_comment['Blog']['id'], array('style' => 'color: 
#F62D0A;')) ?>




  link(ucfirst(__('commnets', true)) . ' - ' . 
$blog_comment['Blog']['comments'], '/blogs/show/' . 
$blog_comment['Blog']['id'], array('class' => 'comments16px')) ?> 
  
link(__('report/spam', true), '/report/blog/' . 
 $blog_comment['Blog']['id'], array('class' => 'report')) ?>
  
   timeAgo($time, $blog_comment['BlogComment']['created']) 
?>
  



  
   
   

  

  
  

  


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




Re: combine multiple foreach statements

2012-11-27 Thread lowpass
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  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,... ?
>
>   
>   
> [code]
>
>   
>
>
> 
> [code]
> 
>   
>
> 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 cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> 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 cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




combine multiple foreach statements

2012-11-27 Thread Chris
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,... ? 

  
  
[code]
   
  

   

[code]

  

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