Skip to content

Instantly share code, notes, and snippets.

@venomjke
Last active December 28, 2015 06:09
Show Gist options
  • Save venomjke/7454875 to your computer and use it in GitHub Desktop.
Save venomjke/7454875 to your computer and use it in GitHub Desktop.
generation table with columns
<div class="editprofile-content shop-categories">
<table>
<?php if (count($products_categories) > 0): ?>
<tr>
<td>
<?php $i = 0; ?>
<?php foreach($products_categories as $category): ?>
<?php if ($i != 0 && $i % (count($products_categories)/2) == 0): ?>
</td>
<td>
<?php endif ?>
<div class="editprofile-item">
<div data-category-id="<?php echo $category->id; ?>" data-edit-category-url="<?php echo site_url('company/edit/shop/' . $company->id . '/edit/category/' . $category->id); ?>" data-delete-category-url="<?php echo site_url('company/edit/shop/' . $company->id . '/del/category/'); ?>" class="editprofile-controls">
<a href="#" class="" onclick="return company.shop.editCategory($(this).parent());">
<img src="/assets/site/images/icon16/edit.png" alt="Редактировать категорию" title="Редактировать категорию">
</a>
<a href="#" class="" onclick="return company.shop.delCategory($(this).parent());">
<img src="/assets/site/images/icon16/cross.png" alt="" title="Удалить категорию">
</a>
</div>
<input id="del-category-<?php echo $category->id; ?>" type="checkbox" class="del-categories" value="<?php echo $category->id; ?>">
<label for="del-category-<?php echo $category->id; ?>"><?php echo $category->name; ?></label>
</div>
<?php ++$i; ?>
<?php
endforeach; ?>
</td>
</tr>
<?php else: ?>
<tr>
<td>Пока не добавлено ни одной категории.</td>
</tr>
<?php endif; ?>
</table>
<script type="text/javascript">
$(function(){
var width = 100;
var countItems = $('.shop-categories > table tr > td').length;
$('.shop-categories > table tr > td').each(function(){
$(this).css('width', width / countItems + '%');
});
});
</script>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment