This is a custom module for Magento 2.1.8 the idea is to control the iframes with embedded youtube videos from the Admin panel. Basically to allow - fullscreen, controls, autoplay and so on..
I want this template to load on every possible page on my website
And after all these:
magento setup:upgrade
magento setup:di:compile
magento setup:static-content:deploy
magento cache:clean
magento cache:flush
magento indexer:reindex
I have layouts/default.xml with:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="after.body.start">
<block class="Magento\Framework\View\Element\Template" template="Mycompany_YouTube::youtube_configuration.phtml" name="mycompany.youtube.configuration" after="-" />
</referenceContainer>
</body>
</page>
templates/youtube_configuration.phtml
<?php
$config = [
'youtube_config' => [
"_force" => $this->helper('Mycompany\\Youtube\\Helper\\Data')->getConfig('youtube/general/_force'),
"rel" => $this->helper('Mycompany\\Youtube\\Helper\\Data')->getConfig('youtube/general/rel'),
"fs" => $this->helper('Mycompany\\Youtube\\Helper\\Data')->getConfig('youtube/general/fs'),
"loop" => $this->helper('Mycompany\\Youtube\\Helper\\Data')->getConfig('youtube/general/loop'),
"autoplay" => $this->helper('Mycompany\\Youtube\\Helper\\Data')->getConfig('youtube/general/autoplay'),
"controls" => $this->helper('Mycompany\\Youtube\\Helper\\Data')->getConfig('youtube/general/controls'),
]
];
?>
<div id="Mycompany_YouTube" data-mage-init="<?= json_encode($config) ?>">
<script type="text/javascript">
console.log("Mycompany_YouTube Loaded!");
define(["jquery"], function($) {
"use strict";
return function(config) {
var params = config.youtube_config;
if (params._force) {
delete params._force;
$('iframe[src*="youtube.com/embed"]').each(function(k,v) {
"mycompany";
var url = document.createElement('a');url.href = v.src;
url.search = $.param(params);
$(v).prop('src', url.href)
});
}
}
});
</script>
</div>
The template is not loading whatsoever...
Notes: Using Magento 2.1.8 ( No choice that's the only one I can use at the moment do not ask why )
Also I'm in Developer Mode
Also I have problems ONLY with the Frontend of Magento.. the Admin panel is done and working.
Also keep in mind that I'm creating this with the following tree:
/
|---/app
| |---/code
| | |---/Mycompany
| | | |---/YouTube
| | | | |---registration.php
| | | | |---/etc
| | | | | |---module.xml
| | | | | |---/adminhtml
| | | | | | |---config.xml
| | | | | | |---system.xml
| | | | |---/Helper
| | | | | |---Data.php
| | | | |---/view
| | | | | |---/frontend
| | | | | | |---requirejs-config.js
| | | | | | |---/layout
| | | | | | | |---default.xml
| | | | | | |---/templates
| | | | | | | |---youtube_configuration.phtml
The minimum result I need is that I can see the code from the template in the Inspector when I refresh the page.
The problem was that I had no composer.json which contains the PSR-4 Autoloader.