If this is your first visit, check our documentation. To post, register or login.

Help with notifiers

Locked

Started by llynix on 18 May 2010, 9:33 PM · Views: 1,776

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
18 May 2010, 9:33 PM
#1
llynix avatar

llynix

Zen Follower

Join Date:
Jul 2009
Location:
Texas
Posts:
210
Plugin Contributions:
0

Post #1 by llynix

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)

$_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.php/Developers_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

DentalPlanet Designed/Administrated by Falls Geek

18 May 2010, 10:13 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #2 by drbyte

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.

18 May 2010, 11:52 PM
#3
llynix avatar

llynix

Zen Follower

Join Date:
Jul 2009
Location:
Texas
Posts:
210
Plugin Contributions:
0

Post #3 by llynix

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.

DentalPlanet Designed/Administrated by Falls Geek

19 May 2010, 1:47 PM
#4
llynix avatar

llynix

Zen Follower

Join Date:
Jul 2009
Location:
Texas
Posts:
210
Plugin Contributions:
0

Post #4 by llynix

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
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
$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.

DentalPlanet Designed/Administrated by Falls Geek

19 May 2010, 2:13 PM
#5
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,146
Plugin Contributions:
56

Post #5 by lat9

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.