Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Custom Configuration Setting Tutorial?

    Is there anywhere that gives a tutorial on the steps required to make a some simple configuration settings to be added to the configuration menu? I believe it is a case of writing an SQL patch to set it up but have no clue how to format it?

    What I am after is a simple on/off setting to be either added to an existing configuration menu or to be located in a new custom configuration menu.

    If there are any guides or if anyone can show me how to do this id be grateful.

    Cheers
    Phil
    Phil Rogers
    A problem shared is a problem solved.

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

    Default Re: Custom Configuration Setting Tutorial?


  3. #3
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Custom Configuration Setting Tutorial?

    Hey stevesh,

    no I think that is describing how to disply new admin pages. what im after is how to create a patch to add a configuration menu item.

    so for example if i wanted to have an extran menu item in maximum values, with the option 0 or 1 or on of off?
    Phil Rogers
    A problem shared is a problem solved.

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,478
    Plugin Contributions
    88

    Default Re: Custom Configuration Setting Tutorial?

    First, you'll note that when you view Configuration->Maximum Values that it shows a URL like:
    Code:
    http://www.example.com/myadmin/configuration.php?gID=3
    So 3 is the configuration_group_id value and you'll create a SQL script similar to the following which you can copy/paste into Tools->Install SQL Patches:
    Code:
    INSERT INTO configuration ( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function)
    VALUES ( "The title of my new value", "A_UNIQUE_KEY_TO_IDENTIFY_THE_VALUE", "No", "A description of what the value is and what it controls.", 3, 40, NOW(), NULL, "zen_cfg_select_option(array('Yes', 'No'),");

  5. #5
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Custom Configuration Setting Tutorial?

    Ok so breaking it down the following gets inserted. A few questions.

    configuration_title - "The title of my new value" - happy with this
    configuration_key - A_UNIQUE_KEY_TO_IDENTIFY_THE_VALUE - what woud the unique key be what format?
    configuration_value - No - what is this used for?
    configuration_description - A description of what the value is and what it controls. - happy with this
    configuration_group_id - 3 - happy with what this refers to
    sort_order - 40 - happy with this
    date_added - NOW() - happy with this
    use_function - NULL - what is this used for?
    set_function - zen_cfg_select_option(array('Yes', 'No') - assume this sets a yes no option and could be set to what ever values I want?

    Cheers

    Phil
    Phil Rogers
    A problem shared is a problem solved.

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,478
    Plugin Contributions
    88

    Default Re: Custom Configuration Setting Tutorial?

    Quote Originally Posted by philip937 View Post
    Ok so breaking it down the following gets inserted. A few questions.

    configuration_title - "The title of my new value" - happy with this
    configuration_key - A_UNIQUE_KEY_TO_IDENTIFY_THE_VALUE - what woud the unique key be what format?
    configuration_value - No - what is this used for?
    configuration_description - A description of what the value is and what it controls. - happy with this
    configuration_group_id - 3 - happy with what this refers to
    sort_order - 40 - happy with this
    date_added - NOW() - happy with this
    use_function - NULL - what is this used for?
    set_function - zen_cfg_select_option(array('Yes', 'No') - assume this sets a yes no option and could be set to what ever values I want?

    Cheers

    Phil
    Phil, the "unique key" is simply a capitalized, underscore-separated "name" that you'll use to reference the value in your code. If you're placing the value into the Maximum Values group, I'd name the key something MAXIMUM_VALUE_WHATEVER, where WHATEVER describes the value's usage. When you've creating a value with a radio-button (e.g. Yes/No), the use_function has no meaning so its value is set to NULL.

  7. #7
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Custom Configuration Setting Tutorial?

    brill thanks foe the explaination :)

    if I wanted to give these settings their own configuration group what would I need to do to achieve this?
    Phil Rogers
    A problem shared is a problem solved.

  8. #8
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,478
    Plugin Contributions
    88

    Default Re: Custom Configuration Setting Tutorial?

    Here's the installation SQL for the Products Pagination plugin. It creates its own configuration group, has a couple of different types of fields and adds the new page to the admin_pages (v1.5.0 or later):
    Code:
    # 
    # Products pagination install script for Zen Cart v1.5.0x
    #
    # Remove any previous installation
    SELECT (@cgi:=configuration_group_id) as cgi 
    FROM configuration_group
    WHERE configuration_group_title= 'Products Pagination';
    DELETE FROM configuration WHERE configuration_group_id = @cgi AND configuration_group_id != 0;
    DELETE FROM configuration_group WHERE configuration_group_id = @cgi AND configuration_group_id != 0;
    DELETE FROM admin_pages WHERE page_key='configProdPagination';
    
    # Create configuration_group
    INSERT INTO configuration_group (configuration_group_title, configuration_group_description, sort_order, visible) VALUES ('Products Pagination', 'Configure Products Pagination Settings', '1', '1');
    SET @cgi=last_insert_id();
    UPDATE configuration_group SET sort_order = @cgi WHERE configuration_group_id = @cgi;
    
    # Insert Product Pagination settings
    INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added) 
    VALUES ('Products Pagination &mdash; Maximum Links', 'PRODUCTS_PAGINATION_MAX', '10', 'This is the maximum number of product links to be displayed before pagination begins.  This value should be greater than the number of <em>Intermediate Links</em>.<br /><br /><b>Default: 10</b><br />', @cgi, '1', NOW(), NOW());
    
    INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added) 
    VALUES ('Products Pagination &mdash; Intermediate Links', 'PRODUCTS_PAGINATION_MID_RANGE', '7', 'This is the number of intermediate links to be shown when the number of products in the current category is greater than the <em>Maximum Links</em>; the first and last product link is always shown.  The value should be an odd number for link symmetry.<br /><br /><b>Default: 7</b><br />', @cgi, '2', NOW(), NOW());
    
    INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified,  use_function, set_function, date_added) VALUES ('Enable product listing link?', 'PRODUCTS_PAGINATION_LISTING_LINK', 'true', 'If enabled, a &quot;View Product listing&quot; link is shown on the same line as &quot;Viewing product x of y&quot;.<br /><br /><b>Default: true</b>', @cgi, '3', NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''), ', NOW());
    
    INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified,  use_function, set_function, date_added) VALUES ('Enable links on other pages?', 'PRODUCTS_PAGINATION_OTHER', 'true', 'If enabled, the &quot;Other pages to link&quot; will have the pagination links applied.<br /><br /><b>Default: true</b>', @cgi, '4', NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''), ', NOW());
    
    INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added) 
    VALUES ('Other pages to link', 'PRODUCTS_PAGINATION_OTHER_MAIN_PAGES', 'account_history,advanced_search_result,featured_products,index,product_reviews,products_all,products_new,reviews,specials', 'This comma-separated list identifies the &quot;other&quot; pages to which the pagination display should be applied.', @cgi, '5', NOW(), NOW());
    
    INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified,  use_function, set_function, date_added) VALUES ('Include page-select drop-down?', 'PRODUCTS_PAGINATION_DISPLAY_PAGEDROP', 'false', 'If enabled, a drop-down menu is displayed on the <strong>other</strong> pages to allow the customer to go to a specific page number.<br /><b>Default: false</b>', @cgi, '6', NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''), ', NOW());
    
    INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified,  use_function, set_function, date_added) VALUES ('Include item-count drop-down?', 'PRODUCTS_PAGINATION_PRODUCT_COUNT', 'false', 'If enabled, a drop-down menu is displayed to allow the customer to choose the number of items displayed for the <strong>other</strong> pages.  The count choices are contained in &quot;Item Counts&quot; (see below).<br /><b>Default: false</b>', @cgi, '7', NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''), ', NOW());
    
    INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added) 
    VALUES ('Item counts', 'PRODUCTS_PAGINATION_COUNT_VALUES', '10,25,50,100,*', 'This comma-separated list identifies the item-count choices that will be displayed in a drop-down menu to the customer.  The value \'*\' corresponds to <em>All</em> the items being displayed.', @cgi, '8', NOW(), NOW());
    
    # Register the page for Admin Access Control
    INSERT INTO admin_pages (page_key,language_key,main_page,page_params,menu_key,display_on_menu,sort_order)
    VALUES ('configProdPagination','BOX_CONFIGURATION_PRODUCT_PAGINATION','FILENAME_CONFIGURATION',CONCAT('gID=',@cgi),'configuration','Y',@cgi);
    The plugin also includes the file /YOUR_ADMIN/includes/languages/english/extra_definitions/products_pagination.php that contains:
    Code:
    define('BOX_CONFIGURATION_PRODUCT_PAGINATION', 'Product Pagination');

 

 

Similar Threads

  1. Question after following the Custom Sidebox Tutorial in the wiki
    By bobmeetin in forum Templates, Stylesheets, Page Layout
    Replies: 16
    Last Post: 29 Apr 2013, 02:32 PM
  2. Custom shipping module instructions/tutorial/template/framework
    By Dave.T in forum Addon Shipping Modules
    Replies: 1
    Last Post: 30 Nov 2010, 04:27 AM
  3. UK Configuration Tutorial
    By SWUK in forum General Questions
    Replies: 2
    Last Post: 7 Apr 2009, 09:44 AM
  4. Seriously Weird Configuration Setting In Zen Cart?
    By GE3K in forum General Questions
    Replies: 9
    Last Post: 23 Mar 2008, 11:20 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR