1

试图在 OpenCart 后台的类别页面中添加一个简短的描述字段。让多个 VQmod XML 实例在控制器和模型中正常工作,但尝试使用以下内容将字段添加到类别页面似乎根本没有做任何事情。category_form.tpl 中根本没有添加/替换任何内容。

<!-- This adds the short description field to the admin category page -->
<file name="admin/view/template/catalog/category_form.tpl">
    <operation>
        <search position="replace"><![CDATA[              <tr>
                <td><?php echo $entry_description; ?></td>
                <td><textarea name="category_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description'] : ''; ?></textarea></td>
              </tr>]]></search>
        <add><![CDATA[              <tr>
                <td><?php echo $entry_short_description; ?></td>
                <td><textarea name="category_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description'] : ''; ?></textarea></td>
              </tr>           
              <tr>
                <td><?php echo $entry_description; ?></td>
                <td><textarea name="category_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description'] : ''; ?></textarea></td>
              </tr>]]></add>
    </operation>
</file>

显然有更好的方法,因为我认为我不应该尝试在这里替换所有这些代码,但是如果我有人可以检查该代码并指出我哪里出错了,那就太好了。谢谢。

更新

顺便说一句,我的 XML 代码被包装<modification> </modification>了......

我曾尝试使用偏移量并参考了 VQmod 文档,但仍然无法正确处理...

我努力了:-

<file name="admin/view/template/catalog/category_form.tpl">
    <operation>
        <search position="replace" offset="1"><![CDATA[<td><?php echo $entry_description; ?></td>]]></search>
        <add><![CDATA[              <tr>
                <td><?php echo $entry_short_description; ?></td>
                <td><textarea name="category_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description'] : ''; ?></textarea></td>
              </tr>
              <tr>
                <td><?php echo $entry_description; ?></td>
                <td><textarea name="category_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description'] : ''; ?></textarea></td>
              </tr>]]></add>  
    </operation>
</file>
4

1 回答 1

1

首先整个代码应该被包裹在

<modification>
    <file ...>
        ....
    </file>
</modification>

其次你不能搜索多行你可以搜索特定的行然后使用offset属性

供您使用

<search position="replace" offset="1"><![CDATA[ <td><?php echo $entry_description; ?></td>]]></search>

请参阅vQmod 文档

于 2013-04-09T17:33:32.867 回答