L
L
LoveCode &Coffe2018-08-28 23:21:33
opencart
LoveCode &Coffe, 2018-08-28 23:21:33

How to add a new position in opencart 2.3?

I am making a website, the main one is a landing page in which there are 5 modules that are displayed from the admin panel.
For my purposes, I make markup in home.tpl. I make the markup in this file from several sections, and in the section the standard bootstrap .container. row .col*infinity> well, and their classes. Therefore, for me, the output through the top of the page and the bottom of the page is not suitable. Need more positions. Tried to create my position, copied the controller file from content_top.php to my content_vantage.php. Found all lines with 'top ' replaced with 'vantage'. also, by analogy, created content_vantage.tpl and inserted the code from content_top.tpl into it. Then I created a modifier for home.php and found the line

$data['content_bottom'] = $this->load->controller('common/content_bottom');

and then wrote down
$data['content_vantage'] =  $this->load->controller('common/content_vantage');

further, it was necessary to add this position, for visibility in the admin panel. found file layout_form.tpl and after label
id content-top
эта табличка  позиции "верх страницы" . Вставил, копированием еще одну табличку, <code lang="html">
<!--CASTOM SECTION  BEGIN !-->
                  <table id="module-content-vantage" class="table table-striped table-bordered table-hover">
                    <thead>
                      <tr>
                        <td class="text-center">Вывод секции приемущества</td>
                      </tr>
                    </thead>
                    <tbody>
                      <?php foreach ($layout_modules as $layout_module) { ?>
                      <?php if ($layout_module['position'] == 'content_vantage') { ?>
                      <tr id="module-row<?php echo $module_row; ?>">
                        <td class="text-left"><div class="input-group">
                          <select name="layout_module[<?php echo $module_row; ?>][code]" class="form-control input-sm">
                            <?php foreach ($extensions as $extension) { ?>
                            <optgroup label="<?php echo $extension['name']; ?>">
                              <?php if (!$extension['module']) { ?>
                              <?php if ($extension['code'] == $layout_module['code']) { ?>
                              <option value="<?php echo $extension['code']; ?>" selected="selected"><?php echo $extension['name']; ?></option>
                              <?php } else { ?>
                              <option value="<?php echo $extension['code']; ?>"><?php echo $extension['name']; ?></option>
                              <?php } ?>
                              <?php } else { ?>
                              <?php foreach ($extension['module'] as $module) { ?>
                              <?php if ($module['code'] == $layout_module['code']) { ?>
                              <option value="<?php echo $module['code']; ?>" selected="selected"><?php echo $module['name']; ?></option>
                              <?php } else { ?>
                              <option value="<?php echo $module['code']; ?>"><?php echo $module['name']; ?></option>
                              <?php } ?>
                              <?php } ?>
                              <?php } ?>
                            </optgroup>
                            <?php } ?>
                          </select>
                          <input type="hidden" name="layout_module[<?php echo $module_row; ?>][position]" value="<?php echo $layout_module['position']; ?>" />
                          <input type="hidden" name="layout_module[<?php echo $module_row; ?>][sort_order]" value="<?php echo $layout_module['sort_order']; ?>" />
                          <div class="input-group-btn"> <a href="<?php echo $layout_module['edit']; ?>" type="button" data-toggle="tooltip" title="<?php echo $button_edit; ?>" target="_blank" class="btn btn-primary btn-sm"><i class="fa fa-pencil"></i></a>
                            <button type="button" onclick="$('#module-row<?php echo $module_row; ?>').remove();" data-toggle="tooltip" title="<?php echo $button_remove; ?>" class="btn btn-danger btn-sm"><i class="fa fa fa-minus-circle"></i></button>
                          </div>
                        </div></td>
                      </tr>
                      <?php $module_row++; ?>
                      <?php } ?>
                      <?php } ?>
                    </tbody>
                    <tfoot>
                      <tr>
                        <td class="text-left"><div class="input-group">
                          <select class="form-control input-sm">
                            <?php foreach ($extensions as $extension) { ?>
                            <optgroup label="<?php echo $extension['name']; ?>">
                              <?php if (!$extension['module']) { ?>
                              <option value="<?php echo $extension['code']; ?>"><?php echo $extension['name']; ?></option>
                              <?php } else { ?>
                              <?php foreach ($extension['module'] as $module) { ?>
                              <option value="<?php echo $module['code']; ?>"><?php echo $module['name']; ?></option>
                              <?php } ?>
                              <?php } ?>
                            </optgroup>
                            <?php } ?>
                          </select>
                          <div class="input-group-btn">
                            <button type="button" onclick="addModule('content-vantage');" data-toggle="tooltip" title="<?php echo $button_module_add; ?>" class="btn btn-primary btn-sm"><i class="fa fa-plus-circle"></i></button>
                          </div>
                        </div></td>
                      </tr>
                    </tfoot>
                  </table>
                  <!--CASTOm SECTION   END !-->
</code>


В итоге получил ,то что и хотел<img src="https://habrastorage.org/webt/5b/85/ac/5b85ac239cd46129067653.png" alt="image"/> 
<b>НО</b> при когда добавлю модуль в мою секцию "вывод секции преимущества" Сохраняю пишет ,что все хорошо. Но когда опять захожу в макет все добавленные модули в эту секцию слетают и она становится пустой.
<img src="https://habrastorage.org/webt/5b/85/ad/5b85ad0857f2d386118976.png" alt="image"/>
Может я где-то что то пропустил?. 
<b>А есть более простой способ, выводить модуль напрямую в любом файле , через php echo. не используя позиции?

</b>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Matvey Rumynin, 2018-10-29
@greenkey

exactly the same bug.
everywhere they write that this is enough, but it seems that something else needs to be edited so that the modules are saved

P
Pavel, 2019-09-01
@Asokr

I added the last time here on this article at random - there were no problems ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question