Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Posts
    6
    Plugin Contributions
    0

    Default Adding Manufacturer sort order

    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

  2. #2
    Join Date
    Feb 2005
    Location
    Lansing, Michigan USA
    Posts
    20,021
    Plugin Contributions
    3

    Default Re: Adding Manufacturer sort order

    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.

  3. #3
    Join Date
    Aug 2008
    Posts
    6
    Plugin Contributions
    0

    Default Re: Adding Manufacturer sort order

    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.

    1. 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
    2. Then I opened the file admin/manufacturers.php and made the following edits
      Line 20, just after
      Code:
      $manufacturers_name = zen_db_prepare_input($_POST['manufacturers_name'])
      Add
      Code:
      $manufacturers_sort_order = zen_db_prepare_input($_POST['manufacturers_sort_order']);
      Line 22, change
      Code:
      $sql_data_array = array('manufacturers_name' => $manufacturers_name);
      to
      Code:
      $sql_data_array = array('manufacturers_name' => $manufacturers_name, 'manufacturers_sort_order' => $manufacturers_sort_order);
      Line 255, just after
      Code:
      $contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_NAME . '<br>' . zen_draw_input_field('manufacturers_name', '', zen_set_field_length(TABLE_MANUFACTURERS, 'manufacturers_name')));
      Add
      Code:
      $contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_SORT_ORDER . '<br>' . zen_draw_input_field('manufacturers_sort_order', '', 'size="3"'));
      You could add this elsewhere in the form, but I wanted my field to appear under the name when adding or editing the manufacturer.

      Line 287, just after
      Code:
      $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')));
      Add
      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.

  4. #4
    Join Date
    Aug 2008
    Posts
    6
    Plugin Contributions
    0

    Default Re: Adding Manufacturer sort order

    Sorry, one more thing.

    Edit the language file admin/includes/languages/english/manufacturers.php and add the definition

    Code:
    define('TEXT_MANUFACTURERS_SORT_ORDER', 'Manufacturers Sort Order:');
    Cheers

 

 

Similar Threads

  1. v153 Manufacturer sort in default sort drop down
    By vacuumwarlock in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 24 Nov 2014, 02:58 PM
  2. Adding the sort order column to Quick Updates
    By josee225 in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 30 Sep 2011, 08:49 PM
  3. adding a sort order drop down on my site
    By mrtwelvevolts in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 8 Jan 2011, 08:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg