如何在 Magento 2.1.8 中显示自定义模块的模板 - 不工作

How to show template of custom module in Magento 2.1.8 - Not Working

这是 Magento 2.1.8 的自定义模块,其想法是通过管理面板控制带有嵌入式 youtube 视频的 iframe。基本上允许 - 全屏、控件、自动播放等..

我希望此模板加载到我网站上的每个可能的页面

在所有这些之后:

magento setup:upgrade
magento setup:di:compile
magento setup:static-content:deploy
magento cache:clean
magento cache:flush
magento indexer:reindex

我有 layouts/default.xml 和:

<?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>

模板没有加载...

备注: 使用 Magento 2.1.8(没有选择,这是我目前唯一可以使用的,不要问为什么)

我也处于开发者模式

我也有问题 只有 Frontend[= Magento 的 47=].. 管理面板已完成并正在运行。

另外请记住,我正在使用 以下树:

创建它
/
|---/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

我需要的最低结果是当我刷新页面时,我可以在检查器中看到模板中的代码。

问题是我没有包含 PSR-4 Autoloader 的 composer.json。