Jump to content

ibnclaudius

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ibnclaudius's Achievements

Member

Member (2/5)

0

Reputation

  1. It's a function to format the bloomp (post).
  2. Is there a better way to do this? $formatted_bloomp = '<div data-id="' . $bloomp['id'] . '" class="bloomp invisible">'; if ($bloomp['image_id']) { $formatted_bloomp .= '<div class="media image">'; $formatted_bloomp .= '<img src="' . base_url('upload/image/' . $bloomp['image_id']) . '">'; $formatted_bloomp .= '</div>'; } elseif ($bloomp['video_id'] && $bloomp['video_provider']) { $formatted_bloomp .= '<div class="media video">'; if ($bloomp['video_provider'] == 'youtube') { $formatted_bloomp .= '<iframe width="310" height="233" src="http://www.youtube.com/embed/' . $bloomp['video_id'] . '?rel=0&wmode=transparent&iv_load_policy=3&color=white" frameborder="0" allowfullscreen></iframe>'; } if ($bloomp['video_provider'] == 'vimeo') { $formatted_bloomp .= '<iframe src="http://player.vimeo.com/video/' . $bloomp['video_id'] . '?color=#ffffff" width="310" height="233" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; } $formatted_bloomp .= '</div>'; } $formatted_bloomp .= '<span class="text">' . $bloomp['text'] . '</span>'; $formatted_bloomp .= '<div class="info">'; $formatted_bloomp .= '<span>'; $formatted_bloomp .= '<a class="author" href="#">'; $formatted_bloomp .= '<img src="' . base_url('upload/picture/' . $bloomp['author_picture']) . '">'; $formatted_bloomp .= '<span class="name">' . $bloomp['author_name'] . '</span>'; $formatted_bloomp .= '</a>'; $formatted_bloomp .= '</span>'; $formatted_bloomp .= '<span>' . $bloomp['likes_number'] . ' curtidas</span>'; $formatted_bloomp .= '<span>' . $bloomp['comments_number'] . ' coment?rios</span>'; $formatted_bloomp .= '</div>'; if ($bloomp['comments_number'] > 0) { $formatted_bloomp .= '<div class="comments">'; foreach ($this->_CI->quickstart_model->read_comments(3, $bloomp['id']) as $comment) { $formatted_bloomp .= '<div data-id="' . $comment['id'] . '" class="comment clearfix">'; $formatted_bloomp .= '<a href="#"><img class="float-left" src="' . base_url('upload/picture/'. $comment['author_picture']) . '"></a>'; $formatted_bloomp .= '<span class="float-right">'; $formatted_bloomp .= '<a href="#">' . $comment['author_name'] . '</a> ' . $comment['text']; $formatted_bloomp .= '</span>'; $formatted_bloomp .= '</div>'; } if ($bloomp['comments_number'] > 3) { $formatted_bloomp .= '<div class="comment all">'; $formatted_bloomp .= '<a href="#">Todos os ' . $bloomp['comments_number'] . ' coment?rios...</a>'; $formatted_bloomp .= '</div>'; } $formatted_bloomp .= '</div>'; } $formatted_bloomp .= '</div>'; return $formatted_bloomp;
  3. First I get all posts, then, with a foreach, I get the comments. Is it possible to get everything with only one query?
  4. Is there a better way to do this? $i = 0; foreach ($posts as $post) { $posts[$i]['function_return'] = function($post['function_param']); $i++; }
  5. I want to vertical align the label with the input no matter the label size. Here's my code and what it output: <div class="form-item"> <div class="form-label strong left">Nome:</div> <div class="form-input-wrapper left"> <input class="form-input" type="text"> </div> </div> <div class="form-item"> <div class="form-label strong left">Email:</div> <div class="form-input-wrapper left"> <input class="form-input" type="text"> </div> </div> <div class="form-item"> <div class="form-label strong left">Email novamenteEEEEEEEEEEEEEE:</div> <div class="form-input-wrapper left"> <input class="form-input" type="text"> </div> </div> .form-item { border-bottom:1px solid #eee; overflow:hidden; padding:15px 20px } .form-label { color:#666; position:absolute; text-align:right; width:100px; } .form-input { display:block; width:232px; }
  6. Fixed: if ($count_school_update_likes >= 1) Thanks, all!
  7. Thanks, all! I made some changes, almost everything is correct now, the only problem is when there's only one user that liked, his name or you do not output. if ($count_school_update_likes > 0) { $likers = array(); if ($count_school_update_likes > 1) { $i = 0; if ($count_school_update_liked == 1) { $likers[] = 'VocĂȘ'; $i = 1; } if ($get_school_update_likes) { foreach ($get_school_update_likes->result_array() as $liker) { $likers[] = '<a id="' . $liker['user_id'] . '" href="' . $liker['user_id'] . '">' . $liker['user_name'] . '</a>'; $i++; if ($i == 3) { $count_school_update_likes = $count_school_update_likes - 3; if ($count_school_update_likes > 0) { $likers[] = 'mais <a id="stream-updates-item-likes-view" href="#">' . $count_school_update_likes . '</a> '; } break; } } } } $last_liker = count($likers) > 1 ? ' e ' . array_pop($likers) . ' curtiram' : ' curtiu'; $likers = implode(', ', $likers) . $last_liker . ' isto'; echo $likers; }
  8. And when more than one user liked, returned this: fixed with: $likers[] = '<a id="' . $liker['user_id'] . '" href="' . $liker['user_id'] . '">' . $liker['user_name'] . '</a>';
  9. jcbones, I liked that you keep the format But there's some little bugs. when only the user likers, returned this: Fixed with: $last_likers = count($likers) > 1 ? ' and ' . array_pop($likers) : ''; And when more than one user liked, returned this:
  10. A preg_replace like this would also work: if ($count_school_update_likes == '1') { //remove last comma from $likers } else if ($count_school_update_likes > '1') { //remove last comma from $likers and replace the second last comma for "and" } Or something that work on both cases...
  11. When i ran: $likers = $get_school_update_likes->result_array(); $lastLiker = count($likers) > 1 ? ' and ' . array_pop($likers) : ''; $likers = implode(', ', $likers); echo $likers . $lastLiker . ' like this.'; i got this: A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: libraries/action.php Line Number: 230 Array and Array like this And: print_r($likers) outputs something like this: Array ( [0] => Array ( [user_id] => 3 [user_name] => Derp ) [1] => Array ( [user_id] => 4 [user_name] => Derpina ) )
  12. No, but how am I going to do the "and 999 others like this"?
  13. Here's my code: if ($count_school_update_likes > '0') { $likers = ''; if ($count_school_update_liked == "1") { $likers .= 'You, '; } if ($count_school_update_likes > '1') { $i = 0; foreach ($get_school_update_likes->result_array() as $liker) { $likers .= '<a id="' . $liker['user_id'] . '" href="' . $liker['user_id'] . '">' . $liker['user_name'] . '</a>, '; $i++; if ($i == 2) { $count_school_update_likes = $count_school_update_likes - 3; if ($count_school_update_likes > "0") { $likers .= ' and <a id="stream-updates-item-likes-view" href="#">' . $count_school_update_likes . ' others</a> '; } break; } } } $likers .= ' like this.'; echo preg_replace("/,([^,]*)$/", " $1", $likers); //is not working correctly } Here is all the possibles outputs I would like to have: You, like this => You like this You, Derp, like this => You and Derp like this You, Derp, Derpina, like this => You, Derp and Derpina like this You, Derp, Derpina, Derpson1, Derpson2, Derpson3, Derpson4, like this => You, Derp, Derpina and other 4 like this Derp, like this => Derp like this Derp, Derpina, like this => Derp and Derpina like this Derp, Derpina, Derpson, like this => Derp, Derpina and Derpson like this Derp, Derpina, Derpson1, Derpson2, Derpson3, Derpson4, like this => Derp, Derpina, Derpson1 and other 3 like this
  14. How can I replace the comma from a string like this: You, like this => You like this You, Derp, like this => You and Derp like this You, Derp, Derpina, like this => You, Derp and Derpina like this You, Derp, Derpina, Derpson, like this => You, Derp, Derpina and Derpison like this
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.