TShopping

 找回密碼
 註冊
搜索
查看: 236|回復: 0

[教學] opencart 1.5.X 最新商品可選商品分類 前台秀出

[複製鏈接]
發表於 2014-10-15 09:18:53 | 顯示全部樓層 |閱讀模式
 
Push to Facebook Push to Plurk Push to Twitter 
前台展示
1.png



後台展示
2.png

1 修改admin\controller\module\latest.php
1.1 找到
  1. $this->data['entry_layout'] = $this->language->get('entry_layout');
複製代碼
底下新增
  1. $this->data['entry_category'] = $this->language->get('entry_category');  //module of latest with catagory by woff
複製代碼
1.2 找到
  1. $this->data['layouts'] = $this->model_design_layout->getLayouts();
複製代碼
底下新增
  1.     //module of latest with catagory by woff
  2.     $this->load->model('catalog/category');
  3.     $this->data['categorys'] = $this->model_catalog_category->getCategories();
  4.     //module of latest with catagory by woff
複製代碼

1.3 找到
  1. if (!$this->error) {
複製代碼
上面新增
  1. //module of latest with catagory by woff
  2. if (isset($this->request->post['latest_module'])) {
  3. foreach ($this->request->post['latest_module'] as $key => $value) {
  4. if (!$value['category_id']) {
  5. $this->error['warning'][$key] = $this->language->get('error_category_id');
  6. }
  7. }
  8. }
  9. //module of latest with catagory by woff
複製代碼
(這裡是寫入設定到資料庫,並且若是產生error會顯示錯誤,但是我偷懶沒有加入錯誤訊息...各位可以自行加入)


2 修改admin\view\template\module\latest.tpl

2.1
  1.     <td><?php echo $entry_layout; ?></td>
複製代碼
下面加入
  1. <td><?php echo $entry_category; ?></td>  <!--module of latest with catagory by woff-->
複製代碼
2.2
  1. <option value="<?php echo $layout['layout_id']; ?>"><?php echo $layout['name']; ?></option>
  2.     <?php } ?>
  3.     <?php } ?>
  4.     </select></td>
複製代碼


下面插入

  1. <!--module of latest with catagory by woff-->
  2. <td><select name="latest_module[<?php echo $module_row; ?>][category_id]">
  3. <?php foreach ($categorys as $categories) { ?>
  4. <?php if ($categories['category_id'] == $module['category_id']) { ?>
  5. <option value="<?php echo $categories['category_id']; ?>" selected="selected"><?php echo $categories['name']; ?></option>
  6. <?php } else { ?>
  7. <option value="<?php echo $categories['category_id']; ?>"><?php echo $categories['name']; ?></option>
  8. <?php } ?>
  9. <?php } ?>
  10. </select></td>
  11. <!--module of latest with catagory by woff-->
複製代碼
2.3

  1. <td colspan="6"></td>
複製代碼
這裡把6改為7,因為td從6變成7了.......
2.4 找到
  1. html += '      <option value="<?php echo $layout['layout_id']; ?>"><?php echo addslashes($layout['name']); ?></option>';
  2. <?php } ?>
  3. html += '    </select></td>';
複製代碼
下面新增
  1.     //module of latest with catagory by woff
  2.     html += '    <td><select name="latest_module[' + module_row + '][category_id]">';
  3.     <?php foreach ($categorys as $categories) { ?>
  4.     html += '      <option value="<?php echo $categories['category_id']; ?>"><?php echo addslashes($categories['name']); ?></option>';
  5.     <?php } ?>
  6.     html += '    </select></td>';
  7.     //module of latest with catagory by woff
複製代碼
3 在admin\language\zh-TW\module\latest.php 語系檔裡面新增
  1. $_['entry_category']        = '商品類別:';  //module of latest with catagory by woff
複製代碼
4 catalog\controller\module\atest.php
4.1 找到
  1.     'sort'  => 'p.date_added',
  2.     'order' => 'DESC',
  3.     'start' => 0,
  4.     'limit' => $setting['limit']
複製代碼
上面插入
  1. 'filter_category_id' => $setting['category_id'],  //module of latest with catagory by woff
複製代碼


 

臉書網友討論
您需要登錄後才可以回帖 登錄 | 註冊 |

本版積分規則



Archiver|手機版|小黑屋|免責聲明|TShopping

GMT+8, 2016-12-5 02:26 , Processed in 0.059000 second(s), 25 queries .

本論壇言論純屬發表者個人意見,與 TShopping綜合論壇 立場無關 如有意見侵犯了您的權益 請寫信聯絡我們。

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表