cancel
Showing results for 
Search instead for 
Did you mean: 

How to call Magento templete in script tag

How to call Magento templete in script tag

Hi guys,

              Here i have one phtml file i.e

home.phtml:

path : /var/www/html/gr/app/code/Magestore/Webpos/view/frontend/templates/home.phtml

code :

<script type="text/javascript">
var nwIp4= "192.168.0.4";

window.RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
var pc = new RTCPeerConnection({iceServers:[]}), noop = function(){};
pc.createDataChannel("");
pc.createOffer(pc.setLocalDescription.bind(pc), noop);
pc.onicecandidate = function(event)
{
var s = event.candidate.candidate;
var result = s.split(" ");
var nwIp1 = result[4];
if(nwIp1 == nwIp4)
{
data();  //here i want to call template 
}
}

function data(){

document.write(' <?php $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magestore_Webpos::login.phtml")->toHtml(); ?> ');
}
</script>

 

The problem is the template calling with in script tag  is not working but out of script tag its working fine.  I want to call that template with in script tag inside if condition.

Can any one help me on that ?

2 REPLIES 2

Re: How to call Magento templete in script tag

you are missing echo


function data(){

document.write(' <?php echo $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magestore_Webpos::login.phtml")->toHtml(); ?> ');
}
Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti

Re: How to call Magento templete in script tag

it's not working ?