Jump to content
hungryfrank

$OSCOM_Hooks->call('siteWide', 'injectAppTop');

Recommended Posts

Burt said 

$OSCOM_Hooks->register('product');
$OSCOM_Hooks->call('product', 'HelloWorld');
Hook file:

 

 

class hook_shop_product_pi_hooks {
  function listen_HelloWorld() {
    return '<p>Hello World</p>';    
  }  
}

Have at it.

 

 

so I have to say something like this in my hook file.

 

class hook_shop_breadcrumb_hooks {
  function listen_injectAppTop() {
    return '<p>Hello World</p>';    
  }  
}

and can I have some php  instead of hello world?

Edited by hungryfrank

Share this post


Link to post
Share on other sites
<?php
/*
  Copyright (c) 2020, [no association with this code]
  All rights reserved.

  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

class hook_shop_siteWide_breadcrumb {

  function listen_injectAppTop() {
    $crumb_query = tep_db_query("select products_name from " . 'products_description' . " where products_id = '" . (int)$_GET['products_id'] . "' and language_id = '" . $languages_id . "'");
     if (tep_db_num_rows($crumb_query)) {
     $crumb = tep_db_fetch_array($crumb_query);
     $breadcrumb->add($crumb ['products_name'], tep_href_link('product_info.php', 'products_id=' . (int)$_GET['products_id']));
      }

     $this->injectAppTop .= 'breadcruns fixed' . PHP_EOL;

    return $this->injectAppTop;
  }

}

this is my hook and I put it in shop/sitewide/breadcrumb.php

but it docent do nothing.

Edited by burt

Share this post


Link to post
Share on other sites

One problem is that $this->injectAppTop doesn't exist. You need to create a variable like below. But I'm not sure you need to return the change. The code is adding to the breadcrumb so returning that text would cause text to appear on the page. If you are just testing, that is fine but not if it is a live shop.

  function listen_injectAppTop() {
    public $mystr = null;

    $crumb_query = tep_db_query("select products_name from " . 'products_description' . " where products_id = '" . (int)$_GET['products_id'] . "' and language_id = '" . $languages_id . "'");
     if (tep_db_num_rows($crumb_query)) {
     $crumb = tep_db_fetch_array($crumb_query);
     $breadcrumb->add($crumb ['products_name'], tep_href_link('product_info.php', 'products_id=' . (int)$_GET['products_id']));
      }

     $this->mystr .= 'breadcruns fixed' . PHP_EOL;

    return $this->mystr;

 

Share this post


Link to post
Share on other sites

thank you both. I got the hook working. now if I can just remove the model from breadcrumb without just commenting it out 😂😂

class hook_shop_siteWide_breadcrumb {

   function listen_injectAppTop() {
    global $oscTemplate, $breadcrumb,$languages_id;
    
    $crumb_query = tep_db_query("select products_name from " . 'products_description' . " where products_id = '" . (int)$_GET['products_id'] . "' and language_id = '" . $languages_id . "'");
   if (tep_db_num_rows($crumb_query)) {     
     $crumb = tep_db_fetch_array($crumb_query);
     }
  $breadcrumb->add($crumb ['products_name'], tep_href_link('product_info.php', 'products_id=' . (int)$_GET['products_id'])); 
      }
}

 

Share this post


Link to post
Share on other sites
46 minutes ago, hungryfrank said:

if I can just remove the model from breadcrumb without just commenting it out

Showing the model in the breadcrumb is controlled by the modules->Header Tags->Product Title module. Just turn the setting off there to remove it.

Share this post


Link to post
Share on other sites
20 minutes ago, Jack_mcs said:

Showing the model in the breadcrumb is controlled by the modules->Header Tags->Product Title module. Just turn the setting off there to remove it.

no it dose not work. only if my title seo has something then it changes. but cant turn it off. i didn't see anything in the code either

Share this post


Link to post
Share on other sites
29 minutes ago, hungryfrank said:

no it dose not work. only if my title seo has something then it changes. but cant turn it off. i didn't see anything in the code either

You're right. I didn't go through the code previously but have done so now. There seems to be a mistake in the logic of that code since it always adds the model. The code is in includes/application_top.php. You can comment out this line. Although if you are going to do that, I suggest deleting the whole section of code that deals with the model to save a few database calls. 

      $breadcrumb->add($model['products_model'], tep_href_link('product_info.php', 'products_id=' . (int)$_GET['products_id']));


 

Share this post


Link to post
Share on other sites

yes the code has to be changed. that is the easiest way,  and if it gets updated it is not going to break anything.

 

Edited by hungryfrank

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×