Jump to content
Sign in to follow this  
megrel

Родительские и дочерние статьи

Recommended Posts

Искал решение для того, чтобы сделать структуру статей иерархической. Есть пара модулей на офф.сайте, но повезло наткнуться на данное решение через vqmod.

Все бы хорошо. То, что надо. Но один маленький недостаток, который надеюсь поможет кто нибудь решить.

В url отсутствует иерархия, т.е. выводит просто - site.ru/subinformation. В идеале было бы классно так - site.ru/information/subinformation.

Вот vqmod:

<modification>
    <id>Information Pages Hierarchy</id>
    <version>1.0.0</version>
    <vqmver>2.1</vqmver>
    <author><![CDATA[<a href="http://teslitsky.info">Dmitry Teslitsky</a>]]></author>
    <file name="admin/language/russian/catalog/information.php">
        <operation>
            <search position="before"><![CDATA[$_['entry_layout']]]></search>
            <add><![CDATA[$_['entry_position_header'] = 'Отображать в хедере:';$_['entry_parent'] = 'Родительская статья:';]]></add>
        </operation>
    </file>
    <file name="admin/language/english/catalog/information.php">
        <operation>
            <search position="before"><![CDATA[$_['entry_layout']]]></search>
            <add><![CDATA[$_['entry_position_header'] = 'Show in header:';$_['entry_parent'] = 'Parent page:';]]></add>
        </operation>
    </file>
    <file name="admin/view/template/catalog/information_form.tpl">
        <operation>
            <search position="before"><![CDATA[<td><?php echo $entry_keyword; ?></td>]]></search>
            <add><![CDATA[
            <td><?php echo $entry_parent; ?></td>
            <td>
                <select name="parent">
                    <option></option>
                    <?php foreach ($parents as $parent): ?>
                    <?php if ((int) $information_id === (int) $parent['id']) continue; ?>
                    <?php if ((int) $parent_id === (int) $parent['id']) : ?>
                    <option value="<?php echo $parent['id']; ?>" selected="selected"><?php echo $parent['name']; ?></option>
                    <?php else : ?>
                    <option value="<?php echo $parent['id']; ?>"><?php echo $parent['name']; ?></option>
                    <?php endif; ?>
                    <?php endforeach; ?>
                </select>
            </td></tr><tr>
            ]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[<td><?php echo $entry_bottom; ?></td>]]></search>
            <add><![CDATA[
            <td><?php echo $entry_position_header; ?></td>
            <td><?php if ($position_header) { ?>
                <input type="checkbox" name="position_header" value="1" checked="checked" />
                <?php } else { ?>
                <input type="checkbox" name="position_header" value="1" />
                <?php } ?></td></tr><tr>
            ]]></add>
        </operation>
    </file>
    <file name="admin/controller/catalog/information.php">
        <operation>
            <search position="after"><![CDATA[$this->data['entry_layout'] = $this->language->get('entry_layout');]]></search>
            <add><![CDATA[$this->data['entry_position_header'] = $this->language->get('entry_position_header');$this->data['entry_parent'] = $this->language->get('entry_parent');]]></add>
        </operation>
        <operation>
            <search position="after"><![CDATA[$this->data['action'] = $this->url->link('catalog/information/update', 'token=' . $this->session->data['token'] . '&information_id=' . $this->request->get['information_id'] . $url, 'SSL');]]></search>
            <add><![CDATA[$this->data['information_id'] = (int) $this->request->get['information_id'];]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[if (isset($this->request->post['bottom'])) {]]></search>
            <add><![CDATA[
            if (isset($this->request->post['position_header'])) {
    		    $this->data['position_header'] = $this->request->post['position_header'];
            } elseif (!empty($information_info)) {
			    $this->data['position_header'] = $information_info['position_header'];
		    } else {
			    $this->data['position_header'] = 0;
		    }
		    if (isset($this->request->post['parent'])) {
			    $this->data['parent_id'] = $this->request->post['parent'];
            } elseif (!empty($information_info)) {
			    $this->data['parent_id'] = $information_info['parent_id'];
		    } else {
			    $this->data['parent_id'] = 0;
		    }
            ]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[$this->data['layouts'] = $this->model_design_layout->getLayouts();]]></search>
            <add><![CDATA[
                $parents = array();
                $informations = $this->model_catalog_information->getInformations();
                foreach ($informations as $information) {
                    $parents[] = array(
                        'id' => (int) $information['information_id'],
                        'name' => $information['title'],
                        'parent_id' => $information['parent_id'],
                    );
                }
                $this->data['parents'] = $parents;
            ]]></add>
        </operation>
    </file>
    <file name="admin/model/catalog/information.php">
        <operation>
            <search position="replace"><![CDATA[sort_order = '" . (int)$data['sort_order'] . "']]></search>
            <add><![CDATA[sort_order = '" . (int)$data['sort_order'] . "', parent_id = '" . (int)$data['parent'] . "', position_header = '" . (isset($data['position_header']) ? (int)$data['position_header'] : 0) . "']]></add>
        </operation>
    </file>
    <file name="catalog/model/catalog/information.php">
        <operation>
            <search position="before"><![CDATA[public function getInformation($information_id)]]></search>
            <add><![CDATA[
                public function getInfoTree($information_id) {
                    $informations = $this->getInformations();
                    $nodes = array();
                    foreach ($informations as $information) {
                        $nodes[(int)$information['information_id']] = $information;
                    }

                    $result = array();

                    do {
                        $result[] = $nodes[$information_id];
                        $information_id = $nodes[$information_id]['parent_id'];
                    } while ($information_id);

                    return array_reverse($result);
                }
            ]]></add>
        </operation>
    </file>
    <file name="catalog/controller/information/information.php">
        <operation>
            <search position="before" offset="2"><![CDATA['text'      => $information_info['title']]]></search>
            <add><![CDATA[
                $information_tree = $this->model_catalog_information->getInfoTree($information_id);
                foreach ($information_tree as $node) {
            ]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[$this->url->link('information/information', 'information_id=' .  $information_id)]]></search>
            <add><![CDATA[$this->url->link('information/information', 'information_id=' .  $node['information_id'])]]></add>
        </operation>
        <operation>
            <search position="after" offset="4"><![CDATA['text'      => $information_info['title']]]></search>
            <add><![CDATA[}]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA['text'      => $information_info['title']]]></search>
            <add><![CDATA['text'      => $node['title']]]></add>
        </operation>
    </file>
</modification>

Share this post


Link to post
Share on other sites

Нужно SEO контроллеры (seo_url, seo_pro) переписывать. 

Share this post


Link to post
Share on other sites

Как раз на днях читал на твоем сайте про то, как сделать наоборот, для категорий, убрать пару строк из seo_url, seo_pro.

Может не надо их переписывать, а добавить несколько строчек, я просто не знаю. Или много чего надо добавлять?

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Может быть кто то платно согласится сделать иерархическую структуру для статтей с сохранением иерархии в ЧПУ? Думаю многим надо, не только мне

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.