Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2009
    Posts
    86
    Plugin Contributions
    0

    Default Error creating Admin Notifier: headers already sent

    So following the Github project to add notifiers to admin, i created a file under myadmin/incudes/auto_loaders/config.add_forklift.php
    PHP Code:
        $autoLoadConfig[10][] = array('autoType'=>'class',
                                      
    'loadFile'=>'add_forklift.php'); 
    And a new class myadmin/includes/classes/add_forklifts.php
    PHP Code:
    class addForklift {

    // class constructor
        
    function addForklift($products_id$current_category_id) {
            global 
    $zco_notifier;
            
    $this->attach($this, array('NOTIFIER_ADMIN_NEW_PRODUCT_ADDED'));
        }
      } 
    I set define('DEBUG_AUTOLOAD', true); and get this in the list:
    actionPoint=>10 FAILED: include('/home/genetjr/public_html/ojlforklifts.com/includes/classes/add_forklift.php');

    and an error log:
    [28-Jun-2016 13:53:18 UTC] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/genetjr/public_html/ojlforklifts.com/includes/autoload_func.php:189) in /home/genetjr/public_html/ojlforklifts.com/includes/functions/sessions.php on line 113
    [28-Jun-2016 13:53:18 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/genetjr/public_html/ojlforklifts.com/includes/autoload_func.php:189) in /home/genetjr/public_html/ojlforklifts.com/adminurrhtcqq/includes/init_includes/init_templates.php on line 28

    havent made any changes it those files, so not sure whats going on, any help appreciated.
    Jeff

  2. #2
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Admin Notifier

    I think
    PHP Code:
    $autoLoadConfig[10
    should have a higher value, loading it later in the process.
    Try
    PHP Code:
    $autoLoadConfig[999
    to see if it solves the problem.

  3. #3
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: Admin Notifier

    Several issues with the provided code.
    1) the beginning of a php file should include the "open" statement that what follows is php:
    Code:
    <?php
    In this case the content is being pushed to the browser rather than interpreted which is to what the error message is pointing. So will see a similar issue in the second file if not corrected.
    2) In the first file, the path to the class will load from the store side rather than the admin. There is a "trick" to get the admin class to load. I don't recall it off the top of my head, but there is an example at least in Stock By Attributes as offered at: https://github.com/mc12345678/Stock_...butes_Combined in the admin folder's equivalent to the above files.
    3) The second file has a constructor which requires parameters to be passed (no default assignment if they are not provided, though I don't see that the class is instantiated just loaded...
    4) Since one of the earlier PHP 5.x versions, a class could be constructed using __construct instead of the classes name. Starting in PHP 7.0, such a constructor must be used in place of a function having the same name as the class.
    5) and somewhat a matter of taste, if the class extends base, then there is no need to use the global $zco_notifier, instead $this->attach could be used as well as any other class function that extends the base...

    The only other thing to say is in relation to the load point of 10... nothing wrong with it, but I think the guide in the wiki is a little out of date in relation to the load points... good first effort though! And hopefully this post Falls in line with others that have posted since I started writing. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Jun 2009
    Posts
    86
    Plugin Contributions
    0

    Default Re: Admin Notifier

    Changing to 999 did not solve the issue :actionPoint=>999 FAILED: include('/home/genetjr/public_html/ojlforklifts.com/includes/classes/add_forklift.php');

    @mc12345678
    1. sorry forgot to inclue that, but yes, both files start with <?php
    2. yes, i made that change in config file: $zco_notifier->notify('ADMIN_CONFIGURATION_SETTING_CHANGE', $result->fields['configuration_key'], $configuration_value);

    Still throwing the headers already sent.

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,495
    Plugin Contributions
    88

    Default Re: Admin Notifier

    I believe that I see the issue. You're trying to load the file /YOUR_ADMIN/includes/classes/add_forklift.php, so you'll need to use an alternate form in your auto_loader file:
    Code:
    <?php
      $autoLoadConfig[999][] = array('autoType'=>'class',
                                   'loadFile'=>'add_forklift.php',
                                   'classPath'=>DIR_WS_CLASSES);
    Then your observer-class file should look like:
    Code:
    <?php
    class addForklift extends base {
    
    // class constructor
        function __construct () {
             $this->attach($this, array('NOTIFIER_ADMIN_NEW_PRODUCT_ADDED'));
        }
    
        function update (&$class, $eventID, $p1, &$p2, &$p3, &$p4) {
          if ($eventID == 'NOTIFIER_ADMIN_NEW_PRODUCT_ADDED') {
            //-Do your special stuff here.  the $p1-4 values represent the variables included on that notifier.
            //-If you are using "global" variables (like the $db object), remember to declare them as global at the start of this function.
          }
        }
      }

  6. #6
    Join Date
    Jun 2009
    Posts
    86
    Plugin Contributions
    0

    Default Re: Admin Notifier

    Perfect! Thank you very much, no errors and i am on my way Cup of coffee to you sir!

 

 

Similar Threads

  1. headers already sent error with WordPress on Zen Cart
    By lilacsandals in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 28 Oct 2008, 06:52 AM
  2. Error after adding product - headers already sent
    By comimpact in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 8 Feb 2008, 01:13 AM
  3. Headers already sent error
    By e-hol.co.uk in forum General Questions
    Replies: 2
    Last Post: 9 Sep 2007, 04:40 PM
  4. error: headers already sent
    By phat in forum General Questions
    Replies: 20
    Last Post: 5 Aug 2007, 07:23 PM
  5. Headers Already Sent Error !
    By ccn1 in forum General Questions
    Replies: 8
    Last Post: 5 Jun 2006, 03:07 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