Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Posts
    607
    Plugin Contributions
    0

    Default Re: Adding a menu item to the v1.5.0 admin

    By using this method, new menu items gets added to different parts of the admin; specifically to “zen_admin_pages” table in the database?

    1. Once added do you leave the “/YOUR_ADMIN/includes/functions/extra_functions/init_new_tool.php” file, or do delete it?

    2. If you want to change the sort order of this file, would the change be done from this file “/YOUR_ADMIN/includes/functions/extra_functions/init_new_tool.php” or you would have to it from change “zen_admin_pages” table?

    3. Is “zen_admin_pages” table, the only table getting effected by creating “/YOUR_ADMIN/includes/functions/extra_functions/init_new_tool.php” file?

    4. If you make a mistake, where can correct your mistake, in the “zen_admin_pages” table or “/YOUR_ADMIN/includes/functions/extra_functions/init_new_tool.php” file?

    I went ahead and added the following to the admin menu,
    Quote Originally Posted by Kevin205 View Post
    How do you add the following to the admin? Ann admin menu item with and ID.
    Code:
    http://www.YourDomain.com/shop/admin/configuration.php?gID=33
    Ofsource the menu is not seen under the configuration menu!

    And I saw what I did wrong “zen_admin_pages” table.

    Question, can I fix this in SQL or is there another way of doing it?
    Last edited by Kevin205; 4 Feb 2013 at 07:18 PM.
    Using Zen Cart 1.5.1

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,873
    Plugin Contributions
    96

    Default Re: Adding a menu item to the v1.5.0 admin

    Quote Originally Posted by Kevin205 View Post
    Does this work with Zen Cart 1.5.1 also?
    Yes, it does.

    Quote Originally Posted by Kevin205 View Post
    I added a plugin to the admin menu for 1.5.1.

    How do you add the following to the admin? Ann admin menu item with and ID.
    Code:
    http://www.YourDomain.com/shop/admin/configuration.php?gID=33
    You need to upload (via FTP) a file named /YOUR_ADMIN/includes/languages/english/extra_definitions/your_menu_item.php. That file needs to contain a definition:
    Code:
    define('BOX_YOUR_MENU_ITEM', 'My Menu Item');
    Once that file's uploaded, you can use your admin's Admin Access Management->Admin Page Registration and enter:
    Page Key Name ... myMenuItemConfiguration
    Page Name ........... BOX_YOUR_MENU_ITEM
    Page File Name ..... FILENAME_CONFIGURATION
    Page Parameters .. gID=33
    Menu ..................... Configuration
    Display on Menu? .. checked
    Sort Order ............. nn

    Then click "Insert".

    Quote Originally Posted by Kevin205 View Post
    By using this method, new menu items gets added to different parts of the admin; specifically to “zen_admin_pages” table in the database?

    1. Once added do you leave the “/YOUR_ADMIN/includes/functions/extra_functions/init_new_tool.php” file, or do delete it?

    2. If you want to change the sort order of this file, would the change be done from this file “/YOUR_ADMIN/includes/functions/extra_functions/init_new_tool.php” or you would have to it from change “zen_admin_pages” table?

    3. Is “zen_admin_pages” table, the only table getting effected by creating “/YOUR_ADMIN/includes/functions/extra_functions/init_new_tool.php” file?

    4. If you make a mistake, where can correct your mistake, in the “zen_admin_pages” table or “/YOUR_ADMIN/includes/functions/extra_functions/init_new_tool.php” file?

    I went ahead and added the following to the admin menu,

    Ofsource the menu is not seen under the configuration menu!

    And I saw what I did wrong “zen_admin_pages” table.

    Question, can I fix this in SQL or is there another way of doing it?
    1. Your choice, you can either leave it or delete it.
    2. The easiest way to change the sort order is to use phpMyAdmin and change the sort order in your DB_PREFIX . admin_pages entry.
    3. Yes. It's the admin_pages table with your DB_PREFIX value prepended.
    4. If you make a mistake, your can delete the item you created using the following SQL patch (run from your admin's Tools->Install SQL Patches:
    Code:
    DELETE FROM admin_pages WHERE page_key='myMenuItemConfiguration';
    Note that if you're testing out a plugin that you're creating you should be creating a backup of your database that you can restore to in the event that your modification doesn't work "quite right".

  3. #3
    Join Date
    Dec 2012
    Posts
    607
    Plugin Contributions
    0

    Default Re: Adding a menu item to the v1.5.0 admin

    Thank you for a very detailed set of instructions. I will give it try tomorrow.
    Using Zen Cart 1.5.1

  4. #4
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,826
    Plugin Contributions
    31

    Default Re: Adding a menu item to the v1.5.0 admin

    In the interests of anal neatness I usually add this to get a real number for the sort order before calling the function.

    It could/should be included in the zen_register_admin_page as a default if no sort order is defined.

    $sql = "SELECT MAX(sort_order) AS sort_order_max FROM " . TABLE_ADMIN_PAGES . " WHERE menu_key = 'tools'";
    $result = $db->Execute($sql);
    $sort_order = $result->fields['sort_order_max']+1;
    Steve
    github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,873
    Plugin Contributions
    96

    Default Re: Adding a menu item to the v1.5.0 admin

    Quote Originally Posted by torvista View Post
    In the interests of anal neatness I usually add this to get a real number for the sort order before calling the function.

    It could/should be included in the zen_register_admin_page as a default if no sort order is defined.

    $sql = "SELECT MAX(sort_order) AS sort_order_max FROM " . TABLE_ADMIN_PAGES . " WHERE menu_key = 'tools'";
    $result = $db->Execute($sql);
    $sort_order = $result->fields['sort_order_max']+1;
    Agreed. In (most of) my plugins where an admin-page registration is required, I include a function similar to this (for the xxxx plugin):
    Code:
    function init_xxxx_next_sort ($menu_key) 
    {
        global $db;
        $next_sort = $db->Execute('SELECT MAX(sort_order) as max_sort FROM ' . TABLE_ADMIN_PAGES . " WHERE menu_key='$menu_key'");
        return $next_sort->fields['max_sort'] + 1;
    }
    and then use it like:
    Code:
    if (!zen_page_key_exists ('configDbIo')) {
        zen_register_admin_page('configDbIo', 'BOX_CONFIGURATION_DBIO', 'FILENAME_CONFIGURATION', "gID=$cgi", 'configuration', 'Y', init_xxxx_next_sort ('configuration'));
      
    }

  6. #6
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Adding a menu item to the v1.5.0 admin

    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Sep 2019
    Location
    Bristol
    Posts
    5
    Plugin Contributions
    0

    Default Re: Adding a menu item to the v1.5.0 admin

    Hi

    I have a 1.5.6c installation. I have followed the instructions and installed the menu items and associated and target files. All works as it should. Until, I logout. Then I log in to a blank page. All I can do to get around this is remove the extra_datafiles, login and then FTP the removed files to the site. Then I can see them, until I logout again.

    Has anyone else experienced this?

  8. #8
    Join Date
    Sep 2019
    Location
    Bristol
    Posts
    5
    Plugin Contributions
    0

    Default Re: Adding a menu item to the v1.5.0 admin

    I have a 1.5.6c installation.

    After installation I see my new menu items, they link to the pages I have created. But, if I close the browser/open and try to log back in I get a blank screen. I have to remove the files eg. new_tool_filenames.php to get back in. Then I have to upload the new_tool_filename.php again to see it in the menu.

    Clearly the files are written correctly otherwise it wouldn't install.

    I have tried many ways. By removing the autoloaders and the init files but this makes no difference. I realise I am missing something, can anyone assist me in this matter.

    Regards

  9. #9
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,873
    Plugin Contributions
    96

    Default Re: Adding a menu item to the v1.5.0 admin

    Quote Originally Posted by bristolwebdesigner View Post
    I have a 1.5.6c installation.

    After installation I see my new menu items, they link to the pages I have created. But, if I close the browser/open and try to log back in I get a blank screen. I have to remove the files eg. new_tool_filenames.php to get back in. Then I have to upload the new_tool_filename.php again to see it in the menu.

    Clearly the files are written correctly otherwise it wouldn't install.

    I have tried many ways. By removing the autoloaders and the init files but this makes no difference. I realise I am missing something, can anyone assist me in this matter.

    Regards
    When you get that blank-screen, that's PHP's (and Zen Cart's) way of telling you to go look in your site's /logs directory. You'll see file(s) named myDEBUG-adm-*.log created on/around the time you tried to log back in.

    Let us know the contents of the log, remembering to xxx-out your admin's directory name and post the information using 'CODE' tags (that big # in the menu-bar when you're writing your response).

  10. #10
    Join Date
    Sep 2019
    Location
    Bristol
    Posts
    5
    Plugin Contributions
    0

    Default Re: Adding a menu item to the v1.5.0 admin

    [14-May-2020 11:37:42 Europe/London] Request URI: /test/ADMIN/new_tool_two.php?products_filter_name_model=2020-04-22, IP address: 62.64.204.255
    #1 header() called at [/home/DIR/public_html/test/ADMIN/includes/init_includes/init_gzip.php:34]
    #2 require(/home/DIR/public_html/test/ADMIN/includes/init_includes/init_gzip.php) called at [/home/DIR/public_html/test/includes/autoload_func.php:48]
    #3 require(/home/DIR/public_html/test/includes/autoload_func.php) called at [/home/DIR/public_html/test/ADMIN/includes/application_top.php:171]
    #4 require(/home/DIR/public_html/test/ADMIN/includes/application_top.php) called at [/home/DIR/public_html/test/ADMIN/new_tool_two.php:18]
    --
    --> PHP Warning: Cannot modify header information - headers already sent by (output started at /home/DIR/public_html/test/ADMIN/new_tool_two.php:7) in /home/DIR/public_html/test/ADMIN/includes/init_includes/init_gzip.php on line 34.

    The contents of the log entry above.

    I fould a workaround. I removed the files and added the 'define(FILENAME etc. to an existing file. I chose clone_template_filenames.php. Worked immediately.

    If anyone else has had a similar problem or can show me a better way, as this file could be over-written on upgrade, please let me know.

    I really appreciate your help.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. How do i add an item to the admin menu
    By tcarden in forum General Questions
    Replies: 1
    Last Post: 17 Apr 2013, 11:12 PM
  2. back to the admin homepage after adding item
    By fonzie in forum Basic Configuration
    Replies: 2
    Last Post: 20 Feb 2013, 01:22 PM
  3. Adding a link to the Admin Menu
    By MartynG in forum Basic Configuration
    Replies: 3
    Last Post: 10 Dec 2010, 11:11 AM
  4. Replies: 9
    Last Post: 9 Mar 2009, 08:31 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