Welcome Guest, Not a member yet? Register   Sign In
[Solved] View Table Layout Question
#7

(09-22-2015, 02:50 AM)sintakonte Wrote: you can use both
i use it in cases where i have nested loops because its more clear in my opinion Wink


i think in your case its debatable to use more than one view for simplification
for example:

your main view

PHP Code:
<div class="panel-body">

<
table class="table table-striped table-bordered table-hover">
<
thead>
<
tr>
<
td>Category Name</td>
<
td class="text-right">Action</td>
</
tr>
</
thead>
<
tbody>


<?
php foreach($categories as $category) { ?>

    $arrViewData = array("category" => $category);
    $this->load->view("category-list-view", $arrViewData);
}
?>
</tbody>
</table>
</div> 

the category-list-view.php should look like


PHP Code:
<tr>
 
   <td><?php echo $category['name']; ?></td>
    <td class="text-right"><a href="<?php echo base_url('admin/catalog/category/edit/' $category['category_id']);?>">Edit</a></td>
</tr>

<?php 
foreach($category['sub_categories'] as $subcategory) { ?>
    <tr>
        <td><?php echo $subcategory['name']; ?></td>
        <td class="text-right"><a href="<?php echo base_url('admin/catalog/category/edit/' $subcategory['category_id']);?>">Edit</a></td>
    </tr>
<?php
}
?>

it looks much more clearer and you shifted away from your nested foreach approach in one view


Thanks will keep this in mind thanks
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
RE: View Table Layout Question - by PaulD - 09-22-2015, 01:06 AM
RE: View Table Layout Question - by wolfgang1983 - 09-22-2015, 02:13 AM
RE: View Table Layout Question - by sintakonte - 09-22-2015, 02:23 AM
RE: View Table Layout Question - by wolfgang1983 - 09-22-2015, 02:29 AM
RE: View Table Layout Question - by sintakonte - 09-22-2015, 02:50 AM
RE: View Table Layout Question - by wolfgang1983 - 09-22-2015, 03:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB