Support » Plugins » Mage enabler phtml inclusion variable scope

  • Resolved wcrain

    (@wcrain)


    Referencing magento phtml files in a static fashion from WordPress instance works fine but looking to keep the variable scope intact (e.g., showing the cart phtml within WordPress and retaining the values for cart count, etc..).

    In the cart phtml:

    $_cartQty = $this->getSummaryCount()

    Is there a way to keep $_cartQty and the rest of the variables used within the phtml intact when called into WordPress? Or is the best/only option to access those values via Mage::getSingleton/Mage::helper and re-declaring those same variables in order to recreate the needed phtml files in WordPress? The goal is to avoid maintaining two virtually identical cart header pieces.

Viewing 1 replies (of 1 total)
  • just needed to use the following – phtml and all variables including cart qty now showing as expected:

    $mycartBlock = $app->getLayout()->getBlockSingleton( 'checkout/cart_sidebar')->setTemplate("checkout/cart/cartheader.phtml")->toHtml();

Viewing 1 replies (of 1 total)
  • The topic ‘Mage enabler phtml inclusion variable scope’ is closed to new replies.