<p>As far as I can tell, you would need to unset all of the native columns and then reset them in the desired order.</p>

<pre><code>public function modifyEntryTableAttributes(&amp;$attributes, $source)
{
    if ($source == 'section:3')
    {
        // unset all column attributes
        unset($attributes['title']);
        unset($attributes['uri']);
        unset($attributes['postDate']);
        unset($attributes['expiryDate']);

        // set column attributes in the desired order
        $attributes['id'] = Craft::t('ID');
        $attributes['title'] = Craft::t('Title');
        $attributes['uri'] = Craft::t('URI');
        $attributes['postDate'] = Craft::t('Post Date');
        $attributes['expiryDate'] = Craft::t('Expiry Date');
    }
}
</code></pre>

CC BY-SA 3.0
2015-02-08T19:48:04.410Z
2015-02-08T19:48:04.410Z
Douglas McDonald
<p>You need to reorder the <code>$attributes</code> array to do this. You can do this in various ways, here is how I would do it depending on the position you wanted for the new column:</p>

<pre class="lang-php prettyprint-override"><code>public function modifyEntryTableAttributes(&amp;$attributes, $source)
{
    if ($source == 'section:3')
    {
        // insert column in first position (using array_merge)
        $attributes = array_merge(array(['id'] =&gt; Craft::t('ID'), $attributes);

        // insert column in fourth position (using array_splice)
        array_splice($attributes, 3, 0, array('id' =&gt; Craft::t('ID')));  
    }
}
</code></pre>

CC BY-SA 3.0
2015-02-09T17:35:01.133Z
2015-07-03T18:05:28.213Z
2015-07-03T18:05:28.213Z
Ben Croker
<p>When adding a custom column to an Entry List view using the <a href="http://buildwithcraft.com/docs/plugins/hooks-reference#modifyEntryTableAttributes" rel="nofollow">modifyEntryTableAttributes</a> hook, how would you also set the display order of columns?</p>

<plugin-development><control-panel><hook>
How to change the display order of columns in Entry List view?
# How to change the display order of columns in Entry List view?

(Asked by: username_0 on 2015-02-08)

When adding a custom column to an Entry List view using the [modifyEntryTableAttributes](http://buildwithcraft.com/docs/plugins/hooks-reference#modifyEntryTableAttributes) hook, how would you also set the display order of columns?

**Tags:** plugin-development, control-panel, hook


---

## 2 answers

### Answer by username_1 on 2015-02-09. Score: 4 | Accepted answer

You need to reorder the $attributes array to do this. You can do this in various ways, here is how I would do it depending on the position you wanted for the new column:
public function modifyEntryTableAttributes(&$attributes, $source)
{
    if ($source == 'section:3')
    {
        // insert column in first position (using array_merge)
        $attributes = array_merge(array(['id'] => Craft::t('ID'), $attributes);

        // insert column in fourth position (using array_splice)
        array_splice($attributes, 3, 0, array('id' => Craft::t('ID')));  
    }
}


---

### Answer by username_0 on 2015-02-08. Score: 2

As far as I can tell, you would need to unset all of the native columns and then reset them in the desired order.
public function modifyEntryTableAttributes(&$attributes, $source)
{
    if ($source == 'section:3')
    {
        // unset all column attributes
        unset($attributes['title']);
        unset($attributes['uri']);
        unset($attributes['postDate']);
        unset($attributes['expiryDate']);

        // set column attributes in the desired order
        $attributes['id'] = Craft::t('ID');
        $attributes['title'] = Craft::t('Title');
        $attributes['uri'] = Craft::t('URI');
        $attributes['postDate'] = Craft::t('Post Date');
        $attributes['expiryDate'] = Craft::t('Expiry Date');
    }
}


---

