We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Custom add-on with a table sort order

How Do I?

ronh's avatar
ronh
10 posts
2 years ago
ronh's avatar ronh

Custom add-on with a table in EE6. Trying to get the thing to sort by ID descending (so starting with the newest items), but just can’t figure it out.

$table = ee('CP/Table', [
    'autosearch' => true,
    'sort_col' => 'addon_widget_id'
    'sort_dir' => 'desc'
])

The sort_dir param is not being caught. It keeps sorting ascending.

       
ronh's avatar
ronh
10 posts
2 years ago
ronh's avatar ronh

Works for some reason this way:

$sort_col = ee()->input->get('sort_col') ? ee()->input->get('sort_col') : 'addon_widget_id';
$sort_dir = ee()->input->get('sort_dir') ? ee()->input->get('sort_dir') : 'desc';

$table = ee('CP/Table', [
    'sort_col' => $sort_col,
    'sort_dir' => $sort_dir
]);
       
DuBose Web's avatar
DuBose Web
10 posts
2 years ago
DuBose Web's avatar DuBose Web

In the broken example you might be missing a comma after 'sort_col' => 'addon_widget_id'.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.