Skip to content

Commit

Permalink
fix about us grid
Browse files Browse the repository at this point in the history
  • Loading branch information
psiskova committed Jan 8, 2016
1 parent 432d2da commit 64be0b4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
45 changes: 45 additions & 0 deletions resources/macros/profileGrid.macro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

HTML::macro('profileGrid', function ($profiles) {
$_user = [];
foreach ($profiles as $profile) {
$_user[] = HTML::profilePicture($profile, 125, 125, ['class' => 'img-circle']) .
'<h3>' . $profile->fullname . '</h3>';
}
$count = count($_user);
for ($i = 0; $i < $count; $i++) {
if ($count % 3 == 0) {
$_user[$i] = '<div class="col-md-4">' . $_user[$i] . '</div>';
continue;
}

if ($i >= ($count - ($count % 3))) {

if ($count % 3 == 1) {

$_user[$i] = '<div class="col-md-12">' . $_user[$i] . '</div>';
} else {
if ($i % 3 == 0) {

$_user[$i] = '<div class="col-md-offset-2 col-md-4">' . $_user[$i] . '</div>';
} else {

$_user[$i] = '<div class="col-md-4">' . $_user[$i] . '</div>';
}
}
} else {

$_user[$i] = '<div class="col-md-4">' . $_user[$i] . '</div>';
}
}
$result = '<div class="row">';

$result .= implode('</div><div class="row">', array_map(function ($i) {

return implode("", $i);
}, array_chunk($_user, 3)));

$result = $result . '</div>';

return $result;
});
2 changes: 1 addition & 1 deletion resources/macros/profilePicture.macro.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
$height .= 'px';
}

return '<img ' . $params . ' onerror="this.src=\'' . asset('img/no_profile_pic.png') . '\'" src="' . action('UserController@getProfileImage', ['id' => $user->profileimage]) . '" style="height: ' . $height . '; width: ' . $width . '" alt="' . $user->fullname . '">';
return '<img ' . $params . 'onerror="this.src=\'' . asset('img/no_profile_pic.png') . '\'" src="' . action('UserController@getProfileImage', ['id' => $user->profileimage]) . '" style="height: ' . $height . '; width: ' . $width . '" alt="' . $user->fullname . '">';
});
9 changes: 1 addition & 8 deletions resources/views/aboutus.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@
</div>
</div>
<h2>Naši učitelia</h2>
<div class="row">
@foreach($users as $user)
<div class="col-md-4">
{!! HTML::profilePicture($user, 125, 125, ['class' => 'img-circle']) !!}
<h3>{{ $user->fullname }}</h3>
</div>
@endforeach
</div>
{!! HTML::profileGrid($users) !!}
</div>
</div>
</div>
Expand Down

0 comments on commit 64be0b4

Please sign in to comment.