Results 1 to 10 of 38

Hybrid View

  1. #1
    Join Date
    Aug 2014
    Location
    Lisbon
    Posts
    594
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    Auto load notifier:
    I had this working loading the config. and init_ files. But since init_canonical it loaded at point 161 and this autoload at 175, would be 2 less files.
    However, I'm not getting this right.
    I've also tried to use function updateNotifyInitCanonicalParamWhitelist(&$class, $eventID,$paramsArray = array()), but that would be for the update function (?)


    two more files , two less files is not the issue, but I would like to understand how this works.

    PHP Code:
    class zcObserverBookxCanonical extends base
    {

        public function 
    __construct()
        {
            
            
    $this->attach($this, array(
                
    'NOTIFY_INIT_CANONICAL_PARAM_WHITELIST',
                
    'NOTIFY_INIT_CANONICAL_DEFAULT'));  
        }
       

        
    //$zco_notifier->notify ('NOTIFY_INIT_CANONICAL_PARAM_WHITELIST', $current_page, $excludeParams, $keepableParams, $includeCPath);
          
        
    function updateNotifyInitCanonicalParamWhitelist(&$class$eventID$current_page, &$excludeParams, &$keepableParams$includeCPath)
        {
            
            global 
    $keepableParams// ??
            
    pr($keepableParams'$paramsArray');
            
    $keepableParams[] = 'bookx_publisher_id';
            
    $keepableParams[] = 'bookx_genre_id';
            
    $keepableParams[] = 'bookx_author_id';
            
    $keepableParams[] = 'bookx_author_type_id';
            
    $keepableParams[] = 'bookx_author_type_id';
            
    $keepableParams[] = 'bookx_imprint_id';
            
    $keepableParams[] = 'bookx_series_id';
        } 
    thanks
    “Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

  2. #2
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by mesnitu View Post
    Auto load notifier:
    I had this working loading the config. and init_ files. But since init_canonical it loaded at point 161 and this autoload at 175, would be 2 less files.
    However, I'm not getting this right.
    I've also tried to use function updateNotifyInitCanonicalParamWhitelist(&$class, $eventID,$paramsArray = array()), but that would be for the update function (?)


    two more files , two less files is not the issue, but I would like to understand how this works.

    PHP Code:
    class zcObserverBookxCanonical extends base
    {

        public function 
    __construct()
        {
            
            
    $this->attach($this, array(
                
    'NOTIFY_INIT_CANONICAL_PARAM_WHITELIST',
                
    'NOTIFY_INIT_CANONICAL_DEFAULT'));  
        }
       

        
    //$zco_notifier->notify ('NOTIFY_INIT_CANONICAL_PARAM_WHITELIST', $current_page, $excludeParams, $keepableParams, $includeCPath);
          
        
    function updateNotifyInitCanonicalParamWhitelist(&$class$eventID$current_page, &$excludeParams, &$keepableParams$includeCPath)
        {
            
            global 
    $keepableParams// ??
            
    pr($keepableParams'$paramsArray');
            
    $keepableParams[] = 'bookx_publisher_id';
            
    $keepableParams[] = 'bookx_genre_id';
            
    $keepableParams[] = 'bookx_author_id';
            
    $keepableParams[] = 'bookx_author_type_id';
            
    $keepableParams[] = 'bookx_author_type_id';
            
    $keepableParams[] = 'bookx_imprint_id';
            
    $keepableParams[] = 'bookx_series_id';
        } 
    thanks
    Couple of things. For your observer to trigger, it needs to be loaded into the workspace before the notifier that would trigger it. So, if your notifier is triggered at load point 161, then somehow your observer needs to be loaded before then. It could possibly loaded at load point 161 if it can be brought in before the core code's loading of the asociated file. Better to just pick something convenient before then and give yourself some expansion room.

    Then because the variable keepableParams is passed as an editable variable, it is not needed to bring the same variable from the global space at least for ZC 1.5.3 and higher. There are some other things that would need to be done to populate that variable in the parameter list if working with an older version of ZC.

    Besides that I assume the function pr is some debug utility that has been added allowing you to retrieve the specified data?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Aug 2014
    Location
    Lisbon
    Posts
    594
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by mc12345678 View Post
    Couple of things. For your observer to trigger, it needs to be loaded into the workspace before the notifier that would trigger it. So, if your notifier is triggered at load point 161
    So, in this case is not going to work ( if I'm understanding right)
    Canonical is loaded at 161
    /**
    * point 161 was selected specifically based on dependancies
    */

    From the init_observers.php:

    * This fires at AutoLoader point 175, so all previously-processed system dependencies are in place.
    * If you need an observer class to fire at a much earlier point so it fires before other system processes, you'll need to add your own auto_loaders/config.yyyyy.php file with relevant rules to load those observers.

    ps: yes, ignore de pr
    “Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

  4. #4
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by mesnitu View Post
    So, in this case is not going to work ( if I'm understanding right)
    Canonical is loaded at 161
    /**
    * point 161 was selected specifically based on dependancies
    */

    From the init_observers.php:

    * This fires at AutoLoader point 175, so all previously-processed system dependencies are in place.
    * If you need an observer class to fire at a much earlier point so it fires before other system processes, you'll need to add your own auto_loaders/config.yyyyy.php file with relevant rules to load those observers.

    ps: yes, ignore de pr
    You are correct, you will need to add an includes/init_includes file that loads your observer before 161 and not be able to use the auto load observer when working with a default ZC store. There are examples in that directory that you could use as a template.

    If you only need one of the notifiers to be picked up early you could split the two from the file. If they need to interact with each other then it may make sense for them both to be loaded early, etc...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Aug 2014
    Location
    Lisbon
    Posts
    594
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    ok! thanks for the reply!
    “Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

 

 

Similar Threads

  1. Can I use notifiers to assist during product edits/updates?
    By vukan71 in forum General Questions
    Replies: 4
    Last Post: 6 Aug 2012, 04:59 PM
  2. How can I use Multiple mods that use same files?
    By sfklaas in forum General Questions
    Replies: 1
    Last Post: 8 May 2009, 10:27 PM

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