OK SO I am making a custom module for our magento 2 store.
I have created a module which displays a " Download Product PDF Link " on every product page. But I need to make the link open a new page in a new tab when it is clicked.
My Layout XML located : Modzinc/dynamicpdf/View/frontend/layout/catalogue_product_view.xml
<?xml version="1.0"?>
<body>
<referenceContainer name="product.info.social">
<block class="Modzinc\Productpdf\Block\Product\View\Link"
name="modzinc.dynamicpdf.link"
template="Modzinc_Productpdf::product/view/link.phtml"
after="-">
</block>
</referenceContainer>
</body>
MY Template File located at :
<?php
$linkTitle = $this->helper('Modzinc\Productpdf\Helper\Data')->getConfig('dynamicpdf/general/linkText');
$linkTextColor = $this->helper('Modzinc\Productpdf\Helper\Data')->getConfig('dynamicpdf/general/linkTextColor');
$linkBGColor = $this->helper('Modzinc\Productpdf\Helper\Data')->getConfig('dynamicpdf/general/linkBGColor');
$linkImage = $this->helper('Modzinc\Productpdf\Helper\Data')->getConfig('dynamicpdf/general/linkImage');
###TODO make this more dynmic
$linkImage = "http://www.modzinc.co.uk/pub/media/modzinc/dynamicpdf/" .$linkImage;
##style the link and image properly
echo "<a class='action primary' style='background-color:$linkBGColor;color:$linkTextColor;'>";
if($linkImage!='') {
echo "<img src='$linkImage'/>";
}
echo "$linkTitle </a>";
This all works great and produces the following in the following link as shown here :
Now this is where I am stuck. I need to create a new page opens as "target_blank" in the browser and then I will use my custom code to generate a nice dynamic pdf for the product details.
If this was just a pure PHP application I would do something like this
"Download Product PDF";
And then I would generate the PDF on the pdfMaker.php page .
So I guess my question is how can I make my link open a new page in magento and also install this page when my module is uploaded.
Any pointers will be greatly appreciated