Jump to content
Sign in to follow this  
LeeFoster

Can I HOOK?

Recommended Posts

Hi all,

Can I Hook in the way below or is it not possible?

switch ($page) {

	case 'checkout_confirmation' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_checkout_confirmation.php');
      break;

    case 'checkout_payment' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_checkout_payment.php');
      break;

    case 'checkout_payment_address' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_checkout_payment_address.php');
      break;

    case 'checkout_shipping' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_checkout_shipping.php');
      break;

    case 'checkout_shipping_address' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_checkout_shipping_address.php');
      break;

    case 'create_account' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_create_account.php');
      break; 

    case 'shopping_cart' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_add_2_cart.php');
      break;
	  
echo $OSCOM_Hooks->call('siteWide', 'injectCSPage');

  }

And the content I'm trying to hook in

class hook_shop_siteWide_csTicketPage {
  var $version = '1.0.0';
  
  function listen_injectCSPage() {
    
    $csPage =  'case "ticket" : include ("includes/modules/header_tags/customer_service/modules/page/cs_ticket.php");
      break;'; 

    return $csPage;
  }


}

 

Share this post


Link to post
Share on other sites

No. 

You can't inject PHP via hooks.  You can only generate HTML.  So

    $csPage =  'case "ticket" : include ("includes/modules/header_tags/customer_service/modules/page/cs_ticket.php");
      break;';

won't work. 

I have code for doing something similar that I just haven't released yet.  No time right now, but I could post it later.  It would basically make the hook call look like

foreach ($OSCOM_Hooks->generate('siteWide', 'injectCSPage', [ 'page' => $page ]) as $include) {
  include $include;
}

 


Always back up before making changes.

Share this post


Link to post
Share on other sites
8 minutes ago, ecartz said:

No. 

You can't inject PHP via hooks.  You can only generate HTML.  So


    $csPage =  'case "ticket" : include ("includes/modules/header_tags/customer_service/modules/page/cs_ticket.php");
      break;';

won't work. 

I have code for doing something similar that I just haven't released yet.  No time right now, but I could post it later.  It would basically make the hook call look like


foreach ($OSCOM_Hooks->generate('siteWide', 'injectCSPage', [ 'page' => $page ]) as $include) {
  include $include;
}

 

Thanks, I had another way to do it but wanted to know if this would work first.

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
Sign in to follow this  

×