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;
Re: Adding a menu item to the v1.5.0 admin
Quote:
Originally Posted by
torvista
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'));
}
Re: Adding a menu item to the v1.5.0 admin
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?
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
Re: Adding a menu item to the v1.5.0 admin
Quote:
Originally Posted by
bristolwebdesigner
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).
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.
Re: Adding a menu item to the v1.5.0 admin
Your new_tool_two.php apparently has spaces either before the initial <?php or after a trailing ?>. Note that it's current PHP programming practice to never end a script with a ?>.
Re: Adding a menu item to the v1.5.0 admin
Hi
Thanks for the rapid reply. That's not it. I'd already tried both ways before posting. I just to be sure.
<?php define('FILENAME_NEW_TOOL_TWO', 'new_tool_two');
Blank screen. Remove the file and my workaround is still operational.
Thanks for trying.
Regards
Andy
Re: Adding a menu item to the v1.5.0 admin
Hi
I take it back. It does work. I did have one line space above. Should've gone to that well advertised opticians.
Thank you for all you elp.
Stay safe.
Regards
Andy