Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2009
    Location
    Texas
    Posts
    209
    Plugin Contributions
    2

    Default Help with notifiers

    I've got a simple module that I'd like to release.. but it makes a tiny change in a core file (includes/modules/pages/logoff/header_php.php)

    Code:
    $_SESSION['popup'] = 1;  //Added to keep popup from going off when you logoff.
    
    // This should be last line of the script:
    $zco_notifier->notify('NOTIFY_HEADER_END_LOGOFF');
    ?>
    Now I'm fairly sure I can use that notify thing to launch my one line of code but the instructions listed here:
    http://www.zen-cart.com/wiki/index.p..._API_Tutorials

    Were a little more complicated then what I'm trying to achieve. Can anyone simplify them? Or perhaps point me at a simple module that uses them?

    I looked at my own cart in includes/classes/observers and found the directory empty.. so apparently none of the mods I'm using utilize this feature.

    Thank you,
    Anthony

  2. #2
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Help with notifiers

    What does the module do?
    .

    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.

  3. #3
    Join Date
    Jul 2009
    Location
    Texas
    Posts
    209
    Plugin Contributions
    2

    Default Re: Help with notifiers

    It is a model dialog (aka popup) that is designed to go off only once by setting a session variable. Upon logging off the session is destroyed, causing my popup to go off once again. So I reset the session variable after the session destroy to keep it from appearing.

  4. #4
    Join Date
    Jul 2009
    Location
    Texas
    Posts
    209
    Plugin Contributions
    2

    Default Re: Help with notifiers

    Well I'm not sure if I got it 100% right but it seems to be working.

    I created a new observer class in /includes/classes/observers

    PHP Code:
    <?php
    class popup extends base {
      function 
    popup() {
        
    $this->attach($this, array('NOTIFY_HEADER_END_LOGOFF'));
      }
      function 
    update(&$callingClass$notifier$paramsArray) {
        
    $_SESSION['popup'] = 1;
      }
    }
    ?>
    That part I think I understand. Although I'm unsure what the $callingClass could be used for.

    Next I created an autoloader to load my class in /includes/auto_loaders/config.popup.php

    PHP Code:
    <?php
    $autoLoadConfig
    [10][] = array('autoType'=>'class',
                                  
    'loadFile'=>'observers/class.popup.php');
    $autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
                                  
    'className'=>'popup',
                                  
    'objectName'=>'popup');
    ?>
    I guess what throws me here is the 10 and 90. I suppose these tell zen cart when to load the particular code. I suppose the first line loads the class and then the second line runs the popup() code which hooks it into the notifier.

    I guess for my purposes this really doesn't matter? That is to say none of my code conflicts with anything else really so when it loads up doesn't matter, just a matter of loading it.

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

    Default Re: Help with notifiers

    Another approach you could take, again without modifying core files, is to create a file named header_php_popup.php in the /includes/modules/pages/logoff directory, and include the code there. It will be run after the header_php.php file finishes processing and will provide you the same functionality without the complexity of using a notifier.

 

 

Similar Threads

  1. Stumped on notifiers, help?
    By s_mack in forum General Questions
    Replies: 6
    Last Post: 8 Sep 2006, 11:34 PM
  2. Using notifiers
    By Arasii in forum General Questions
    Replies: 4
    Last Post: 11 Aug 2006, 02:39 AM

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