Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-08T19:48:04.410Z
Answers.LastActivityDate: 2015-02-08T19:48:04.410Z
Answers.UserDisplayName: Douglas McDonald
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-09T17:35:01.133Z
Answers.LastActivityDate: 2015-07-03T18:05:28.213Z
Answers.LastEditDate: 2015-07-03T18:05:28.213Z
Answers.UserDisplayName: Ben Croker
Body: <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>
  
Tags: <plugin-development><control-panel><hook>
Title: How to change the display order of columns in Entry List view?
ThreadText: # 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:
  
  ```php
  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');
      }
  }
  
  ```
  
  
  ---
  
  