Welcome Guest, Not a member yet? Register   Sign In
Repetive html with based on dynamic data - view partial vs helper
#1

[eluser]msteudel[/eluser]
Hi All,

I have your table listing out a bunch of items to that can be edited/deleted

e.g.

Name | Actions
Mark | Edit - Delete
Bill | Edit - Delete
etc.

I have the following view:

Code:
<table class="data">
    <tr>
    <th>Id</th>
    <th>District</th>
    <th>State</th>
    <th>Actions</th>
    </tr>
    &lt;?php foreach( $districts as $district ): ?&gt;
    <tr>
    <td>&lt;?php echo $district['id'] ?&gt;</td>
    <td>&lt;?php echo $district['district_name'] ?&gt;</td>
    <td>&lt;?php echo $district['state_name'] ?&gt;</td>
    <td>&lt;?php $this->load->view( 'admin/district/format_actions') ?&gt;</td>
    </tr>
    &lt;?php endforeach ?&gt;
</table>

My thought of how to generate the actions (Edit - Delete) was to either use another view or use a helper. I initially went with the view idea and have this:

Code:
&lt;?php echo anchor( '/admin/district/update/' . $district['id'], 'Edit') ?&gt; |
&lt;?php echo anchor( '/admin/district/delete/' . $district['id'], 'Delete') ?&gt;

But $district isn't available to the format_actions view. I'm not sure if there is an easy way to pass a variable into a "sub-view". If there isn't then I guess I'll go for a helper ...

Any thoughts?

TIA, Mark


Messages In This Thread
Repetive html with based on dynamic data - view partial vs helper - by El Forum - 04-23-2010, 01:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB