M
M
Maybe_V2016-07-08 16:36:48
PHP
Maybe_V, 2016-07-08 16:36:48

How to download the template correctly?

Need to load and render page after template! The page loads but the template content is not displayed. (Magento Full Release - ver 1.9.2.4)
First I create in /app/design/frontend/my directory newsin it newsthemeand in it /layout/vitaliydev_news.xml:

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <vitaliydevnews_index_index>
        <reference name="content">
            <block type="core/template" template="vitaliydev_news/index.phtml"/>
        </reference>
    </vitaliydevnews_index_index>
</layout>

Then in
/app/design/frontend/newstheme/template/vitaliydev_news/index.phtml
:
<h1>Template ews/index.phtml</h1>
Part of the config where I connect layout:
<layout>
        <updates>
            <vitaliydevnews>
                <file>vitaliydev_news.xml</file>
            </vitaliydevnews>
        </updates>
    </layout>

And actionin the Controller:
public function indexAction()
    {
       $this->loadLayout();
        $this->renderLayout();
    }

The page is loading but the template content is not displayed!
What am I doing wrong ? If possible, please advise!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2016-07-08
@ZAnatoly

This may be a simple typo, but the theme path is incorrect:
Check if you have the template enabled in the settings System - Configuration - General - Design (or System - Design)
Way # 2: Try loading the page template through the module.
The process of loading a page according to a template can be decomposed into several points:
1. Connection in the module settings (config.xml):

<config>
  <global>
  <!-- тут блоки, модели, хелперы -->
  </global>
  <frontend>
        <routers>
            <уникальный_нод>
                <use>standard</use>
                <args>
                    <module>Название_Модуля</module>
                    <frontName>ссылка_для_загрузки</frontName>
          <!-- домен/язык_если_есть/ссылка_для_загрузки/контроллер-->
          <!-- в вашем примере домен/vitaliydevnews/index, или просто домен/vitaliydevnews/-->
                </args>
            </уникальный_нод>
        </routers>
        <layout>
            <updates>
                <уникальный_нод>
                    <file>файл обновления макета в шаблоне.xml</file>
                </уникальный_нод>
            </updates>
        </layout>
    </frontend>	
</config>

2. Adding a controller to app/code/local/Namespace/Module_name/controllers/IndexController.php
public function indexAction()
    {
       $this->loadLayout();
      $this->renderLayout();
    }

3. Add template for layout in app/design/frontend/Package/Name_of_your_theme/layout/update_layout_file_in_template.xml
<!-- судя по всему у вас должно быть так: app/design/frontend/news/newstheme/layout/vitaliydev_news.xml	-->
<?xml version="1.0" encoding="UTF-8"?>
<layout>	
  <уникальный_нод_index_index> <!-- использовался в настройках модуля  config.xml-->       
    <reference name="root">
      <action method="setTemplate"><template>vitaliydev_news/index.phtml</template></action>
      <!-- путь к шаблону  app/design/frontend/news/newstheme/template/vitaliydev_news/index.phtml -->
    </reference>
    </уникальный_нод_index_index>
</layout>

4. Adding the template
5. Including the module in app/etc/modules/
6. Clearing the cache
7. Updating indexes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question