dpklt4291 2016-06-30 11:23
浏览 14
已采纳

用OCMOD替换管理员TPL文件

I'm currently teaching myself OpenCart and OCMOD. I have a basic understanding on how the system works with creating an XML mod file and uploading this through the modifications interface or directly adding the XML data into the the XML row of the modifications table.

I can successfully, using XML, search for files and either replace lines of code or insert before or after.. The basics basically. I am still yet to learn the full capabilities of XML.

My question, how can I completely override a file? Like I said, I can find, replace or add code to a file by only search for a single line but as in the example below, when I try to search for the whole file and do a simple replace it will not work.

<!-- admin dashboard overide -->
<file path="admin/view/template/common/dashboard.tpl">
  <operation>
    <!-- search the whole file??? -->
    <search>
      <![CDATA[
        <?php echo $header; ?><?php echo $column_left; ?>
        <div id="content">
          <div class="page-header">
            <div class="container-fluid">
              <h1><?php echo $heading_title; ?></h1>
              <ul class="breadcrumb">
                <?php foreach ($breadcrumbs as $breadcrumb) { ?>
                <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
                <?php } ?>
              </ul>
            </div>
          </div>
          <div class="container-fluid">
            <?php if ($error_install) { ?>
            <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_install; ?>
              <button type="button" class="close" data-dismiss="alert">&times;</button>
            </div>
            <?php } ?>
            <div class="row">
              <div class="col-lg-3 col-md-3 col-sm-6"><?php echo $order; ?></div>
              <div class="col-lg-3 col-md-3 col-sm-6"><?php echo $sale; ?></div>
              <div class="col-lg-3 col-md-3 col-sm-6"><?php echo $customer; ?></div>
              <div class="col-lg-3 col-md-3 col-sm-6"><?php echo $online; ?></div>
            </div>
            <div class="row">
              <div class="col-lg-6 col-md-12 col-sx-12 col-sm-12"><?php echo $map; ?></div>
              <div class="col-lg-6 col-md-12 col-sx-12 col-sm-12"><?php echo $chart; ?></div>
            </div>
            <div class="row">
              <div class="col-lg-4 col-md-12 col-sm-12 col-sx-12"><?php echo $activity; ?></div>
              <div class="col-lg-8 col-md-12 col-sm-12 col-sx-12"> <?php echo $recent; ?> </div>
            </div>
          </div>
        </div>
        <?php echo $footer; ?>
      ]]>
    </search>

    <!-- replace whole file with below -->
    <add position="replace">
      <![CDATA[
        <div class="col-xs-12">OCMOD MODIFIED WORKING????? </div>
      ]]>
    </add>

  </operation>
</file> 
  • 写回答

2条回答 默认 最新

  • dqnek0079 2016-06-30 12:35
    关注

    You can use offset as an attribute for search and number of lines in the file as its value:

    offset="35"
    

    This works for me:

    <file path="admin/view/template/common/dashboard.tpl">
          <operation>
            <search offset="35">
              <![CDATA[<?php echo $header; ?><?php echo $column_left; ?>]]>
            </search>
            <add position="replace">
              <![CDATA[
                <div class="col-xs-12">OCMOD MODIFIED WORKING????? </div>
              ]]>
            </add>
          </operation>
        </file>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 机器学习简单问题解决
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写