0

I try to override Magento_Cms::browser/content/files.phtml but when i test , the block is dont display , and i dont know why

i have the next extructure

<Vendor>_<Module>
├── <Stuff>/
│   ├── etc/
│   │   ├── module.xml
│   ├── view/
│   │   ├── adminhtml/
│   │   │   ├── layout
│   │   │   │   ├── cms_wysiwyg_images_contents.xml
│   │   │   ├── templates   
│   │   │   │   ├── browser
│   │   │   │   │   ├── content
│   │   │   │   │   │   ├── files.phtml
│   │   │   ├── web 
│   │   │   │   ├── images  
│   │   │   │   │   ├── icon
│   │   │   │   │   │   ├── pdf.png
│   ├── registration.php/

cms_wysiwyg_images_content.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
    <container name="root">
        <referenceBlock name="wysiwyg_images.files">
            <arguments>
                <argument name="template" xsi:type="string">Vendor_Stuff::browser/content/files.phtml</argument>
            </arguments>
        </referenceBlock>
    </container>
</layout>

files.phtml

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

 /** @var $block \Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content\Files */

$_width  = $block->getImagesWidth();
$_height = $block->getImagesHeight();

?>
<?php if ($block->getFilesCount() > 0): ?>
    <?php foreach ($block->getFiles() as $file): ?>
    <div data-row="file" class="filecnt" id="<?= $block->escapeHtmlAttr($block->getFileId($file)) ?>">
        <p class="nm" style="height:<?= $block->escapeHtmlAttr($_height) ?>px;width:<?= $block->escapeHtmlAttr($_width) ?>px;">
        <?php if ($block->getFileThumbUrl($file)):?>
            <img src="<?= $block->escapeHtmlAttr($block->getFileThumbUrl($file)) ?>" alt="<?= $block->escapeHtmlAttr($block->getFileName($file)) ?>"/>
        <?php endif; ?>
        </p>
        <?php if ($block->getFileWidth($file)): ?>
            <small><?= $block->escapeHtml($block->getFileWidth($file)) ?>x<?= $block->escapeHtml($block->getFileHeight($file)) ?> <?= $block->escapeHtml(__('px.')) ?></small><br/>
        <?php endif; ?>
        <small><?= $block->escapeHtml($block->getFileShortName($file)) ?></small>
    </div>
    <?php endforeach; ?>
<?php else: ?>
    <div class="empty"><?= $block->escapeHtml(__('No files found')) ?></div>
<?php endif; ?>

i use "magento/product-community-edition": "2.2.6"

any suggestion ?

2
+50

Your cms_wysiwyg_images_contents.xml should be:


<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
    <referenceBlock name="wysiwyg_images.files" template="Vendor_Stuff::browser/content/files.phtml"/>
</layout>

  • it dosen't work , i mean if you do this the system take the original and show the default config, thanks btw for the answer – Jose Luis Esparza Jan 14 at 13:51
  • This is working fine here. Not sure why not working for you. – Sohel Rana Jan 14 at 13:52
  • I came to work and try it more calmly, and its work, thank you, you deserve the reward – Jose Luis Esparza Jan 14 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.