Hi,

Originally Posted by
gjh42
There is also a critical bit of information not addressed at all in this thread: you need to define a constant (in /admin/includes/extra_datafiles/) for this (adjusted to your situation) in order for your item to display in the dropdown
Yes, I noticed this too when I couldn't get a menu item to appear, at the time not having any idea that the language define being missing was the cause of the problem, regardless of the fact that the page had indeed been successfully registered in the admin pages database table.
I have written new admin page registration functionality for all new versions of Ceon's modules (have a load of module updates ready to go and they all include it).
Frustratingly my attempts to put handy sanity checks in for BOTH a missing language define and a filename define were unsuccessful as the language defines aren't loaded by the initsystem until after this registration functionality runs.
The filename sanity check can run though, so at least that's something.
Subsequently, so the user has the easiest time installing the software, all Ceon's new modules that need to register an admin page use a file in admin/includes/functions/extra_functions that autoruns, with content similar to the following:
PHP Code:
<?php
/**
* Ceon Back In Stock Notifications Admin Page Registration.
*
* Attempts to create a link to the Ceon Back In Stock Notifications admin utility in the Zen Cart
* admin menu in Zen Cart 1.5+. After running successfully once, this file deletes itself as it is
* never needed again!
*
* @package ceon_back_in_stock_notifications
* @author Conor Kerr <zen-cart.back-in-stock-notifications@dev.ceon.net>
* @copyright Copyright 2004-2012 Ceon
* @copyright Portions Copyright 2008 RubikIntegration team @ RubikIntegration.com
* @copyright Portions Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @link http://dev.ceon.net/web/zen-cart/back-in-stock-notifications
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: back_in_stock_notifications_admin_page_reg.php 936 2012-02-08 11:13:57Z conor $
*/
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
// This file should normally only need to be run once, but if the user hasn't installed the software
// properly it may need to be run again. Flag tracks the situation
$can_autodelete = true;
if (function_exists('zen_register_admin_page')) {
if (!zen_page_key_exists('ceon_bisn')) {
// Register the Ceon Back In Stock Notifications Admin Utility with the Zen Cart admin
// Quick sanity check in case user hasn't uploaded a necessary file on which this depends
$error_messages = array();
if (!defined('FILENAME_CEON_BACK_IN_STOCK_NOTIFICATIONS')) {
$error_messages[] = 'The Back In Stock Notifications filename define is missing.' .
' Please check that the file ' . DIR_WS_INCLUDES . 'extra_datafiles/' .
'back_in_stock_notifications_filenames.php has been uploaded.';
$can_autodelete = false;
}
if (sizeof($error_messages) > 0) {
// Let the user know that there are problem(s) with the installation
foreach ($error_messages as $error_message) {
print '<p style="background: #fcc; border: 1px solid #f00; margin: 1em;' .
' padding: 0.4em;">Error: ' . $error_message . "</p>\n";
}
} else {
// Necessary files are in place so can register the admin page and have the menu item
// created
zen_register_admin_page('ceon_bisn', 'BOX_CEON_BACK_IN_STOCK_NOTIFICATIONS',
'FILENAME_CEON_BACK_IN_STOCK_NOTIFICATIONS', '', 'catalog', 'Y', 40);
}
}
}
if ($can_autodelete) {
// Either the admin utility file has been registered, or it doesn't need to be. Can stop the
// wasteful process of having this script run again by having it delete itself
@unlink(DIR_WS_INCLUDES .
'functions/extra_functions/back_in_stock_notifications_admin_page_reg.php');
}
?>
I hope this example file is of use to other developers.
It automatically deletes itself after registering a page with the admin.. but doesn't do this if the user has forgotten to upload the file containing the page's filename define.
As I said, I had to remove the check for a missing language define, which is a pity, but something's better than nothing! :)
All the best...
Conor
ceon
Bookmarks