1) To create a new template page, you can follow this
2) To set a layout for some pages, you have to add this in : app/design/frontend/{package}/{theme}/layout/local.xml
<your_layout_handle> //<catalog_category_default> for category page for exemple
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action> // 2columns-left.phtml for exemple
</reference>
</your_layout_handle>`
or
<your_layout_handle> //<catalog_category_default> for category page for exemple
<action method="setTemplate" block="root">
<template>page/2columns-left.phtml</template> // 2columns-left.phtml for exemple
</action>
</your_layout_handle>
For this first you have to create a block file as below:
<?php
class Customclass{
protected $_currency;
public function __construct(
\Magento\Directory\Model\Currency $currency,
){
$this->_currency = $currency;
}
public function getStoreCurrencySymbol(){
return $this->_currency->getCurrencySymbol();
}
}
In it's template you need to call above function and pass the value to your js file as below:
<script>
window.getCurrency = {
"getCurrencySymbol":<?php /* @noEscape */ echo $block->getStoreCurrencySymbol(); ?>
};
</script>
<div class="my-class">
<div id="my-id" data-bind="scope: 'curency-symbol'">
<!-- ko template: getTemplate() --><!-- /ko -->
<script type="text/x-magento-init">
{
"#decoration-tier-price": {
"Magento_Ui/js/core/app": <?php /* @escapeNotVerified */ echo $block->getJsLayout(); ?>
}
}
</script>
</div>
</div>
create your js file as below where you will get your current currency symbol.
define([
'jquery',
'ko',
'uiComponent'
], function ($, ko, component) {
'use strict';
return component.extend({
initialize: function () {
this._super();
this._render();
},
_render: function () {
var self = this;
var getCurency = window.getCurrency;
console.log(getCurency.getCurrencySymbol)
},
defaults: {
template: 'namespace_modulename/template/path',
},
});
});
Best Answer
Add this code in your custom theme or module in default.xml:
app/design/frontend/Namespace/Themename/Magento_Theme/layout/default.xml
you can also place it in your module:
app/code/Vendor/Module/view/frontend/layout/default.xml
In this case the template must be saved under app/code/Vendor/Module/view/frontend/templates/html/custom.phtml