My client wants to be able to set the order in which the manufacturers are displayed. So I would like to put a sort order in the admin area where you name the manufacturer.
Is this easy and can someone help me out?
Thanks
My client wants to be able to set the order in which the manufacturers are displayed. So I would like to put a sort order in the admin area where you name the manufacturer.
Is this easy and can someone help me out?
Thanks
It's probably fairly easy for someone fluent in PHP, but not for the rest of us. I have a site that could use this functionality too, and have fiddled with the code trying to make it happen, but no luck. You'll (we'll) probably need paid help.
Hi Stevesh and anyone else reading this thread who needs this option.
After a little bit of code crawling I found out how to do this. First off I will say that I am not a php master, just have a reasonable understanding of basic php and coding, so there may be a better way to do this. Please feel free to join in if you can improve this.
The usual disclaimer applies about backing up your database and file before making the changes so you can go back if it doesn't work of breaks something.
BTW I am using version 1.5.1, the line numbers below may be different to yours but they should be close.
- First I went in through phpMyAdmin and added a field to the manufacturers table called manufacturers_sort_order with a type of INT(11), default 0, NOT NULL
- Then I opened the file admin/manufacturers.php and made the following edits
Line 20, just after
AddCode:$manufacturers_name = zen_db_prepare_input($_POST['manufacturers_name'])
Line 22, changeCode:$manufacturers_sort_order = zen_db_prepare_input($_POST['manufacturers_sort_order']);
toCode:$sql_data_array = array('manufacturers_name' => $manufacturers_name);
Line 255, just afterCode:$sql_data_array = array('manufacturers_name' => $manufacturers_name, 'manufacturers_sort_order' => $manufacturers_sort_order);
AddCode:$contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_NAME . '<br>' . zen_draw_input_field('manufacturers_name', '', zen_set_field_length(TABLE_MANUFACTURERS, 'manufacturers_name')));
You could add this elsewhere in the form, but I wanted my field to appear under the name when adding or editing the manufacturer.Code:$contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_SORT_ORDER . '<br>' . zen_draw_input_field('manufacturers_sort_order', '', 'size="3"'));
Line 287, just after
AddCode:$contents[] = array('text' => '<br />' . TEXT_MANUFACTURERS_NAME . '<br>' . zen_draw_input_field('manufacturers_name', htmlspecialchars($mInfo->manufacturers_name, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_MANUFACTURERS, 'manufacturers_name')));
Code:$contents[] = array('text' => '<br />' . TEXT_MANUFACTURERS_SORT_ORDER . '<br>' . zen_draw_input_field('manufacturers_sort_order', $mInfo->manufacturers_sort_order, 'size="3"'));
That worked for me, and I suppose you can adapt this to add whatever fields you want.
I hope this helps someone else out there now, or in the future.
Sorry, one more thing.
Edit the language file admin/includes/languages/english/manufacturers.php and add the definition
CheersCode:define('TEXT_MANUFACTURERS_SORT_ORDER', 'Manufacturers Sort Order:');