發表於 2:07:00 pm
此篇是對應筆記3的1.5+版本, 在1.5之前要新增一個form 真係話難唔難但係話易又真係唔算易的, 因為入面包括了很多的html code 及頁面上的設定, 但來到1.5 就真係變得容易了很多呢...
public function renderForm(){
$prod = new Product($this->last_pid);
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Fast Get Discount Setting')
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Product name').":",
'disabled' => true,
'name' => 'product_name'
),
array(
'type' => 'hidden',
'name' => 'id_product'
),
array(
'type' => 'text',
'label' => $this->l('No. of Sold').":",
'name' => 'position',
'size' => 25,
'required' => true,
'hint' => sprintf($this->l('Allowed number only'))
),
array(
'type' => 'text',
'label' => $this->l('Reduction').":",
'name' => 'reduction',
'size' => 25,
'required' => true,
'hint' => sprintf($this->l('Input the Amount/Percentage you want to discount.').$this->l('Allowed number only'))
),
array(
'type' => 'select',
'label' => $this->l('Reduction Type').":",
'name' => 'reduction_type',
'options' => array(
'query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))),
'id' => 'reduction_type',
'name' => 'name'
)
),
array(
'type' => 'date',
'label' => $this->l('From').":",
'name' => 'from',
'size' => 20,
'class' => 'timepicker',
'desc' => sprintf($this->l('Leave blank to clear the time'))
),
array(
'type' => 'date',
'label' => $this->l('To').":",
'name' => 'to',
'size' => 20,
'class' => 'timepicker',
'desc' => sprintf($this->l('Leave blank to clear the time'))
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'button'
)
);
$this->fields_value = array(
'product_name' => $prod->name[$this->context->language->id]
);
return parent::renderForm();
}
'legend' => array(
'title' => $this->l('Fast Get Discount Setting')
),
![]() |
| 設定後的效果 |
array(
'type' => 'text',
'label' => $this->l('Product name').":",
'disabled' => true,
'name' => 'product_name'
),
array(
'type' => 'hidden',
'name' => 'id_product'
),
array(
'type' => 'text',
'label' => $this->l('No. of Sold').":",
'name' => 'position',
'size' => 25,
'required' => true,
'hint' => sprintf($this->l('Allowed number only'))
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'button'
)
由於第一個item(product_name),不是直接由database中取出來的(頁面所設定的className), 所以它的內容要透過fields_value來設定
$this->fields_value = array( 'product_name' => $prod->name[$this->context->language->id] );最後,當然要call 番parent的renderform, 如果唔係可是會出現白頁的情況呢!
return parent::renderForm();
Category: php, prestashop, programming 0 回應
Friday, 23 November 2012 發表於 12:31:00 am
由於之前的遊戲難道設定得有點難(卡了在act 2 呢), 再加上WoW expansion 的推出後更加沒有點玩這個diablo, 所以一直也未能完成inferno 級的diablo 呢...
不過最近終於在佢多次nerf後,總算是完成了這個inferno 的diablo 了, 不過佢nerf完之後真係好似易打左好多呢
Tuesday, 6 November 2012 發表於 2:51:00 pm
之前講到prestashop升級至1.5.x後它的backoffice 改動很太,所以基本上admin tab 也是要重新寫過的呢,如果看看它的change log, 基本上v1.5.0.1把之前的admintab 也換了是controller 呢,所以寫法上也會有一點點的出入,所以之前的筆記2及3是不太適用於1.5+呢
class AdminFastGetDiscountSettingControllerCore extends AdminController{
...
}
public function __construct()
{
$this->table = 'product_fast_get_discount';
$this->className = 'FastGetDiscount';
$this->lang = false;
$this->identifier = "id_pfgd";
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->fields_list = array(
'id_pfgd' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25
),
'product_name' => array(
'title' => $this->l('Name'),
'align' => 'left',
'orderby' => false,
'filter' => false,
'search' => false
),
'position' => array(
'title' => $this->l('No. of Sold'),
'align' => 'center',
'width' => 90
),
'reduction' => array(
'title' => $this->l('Reduction'),
'align' => 'right',
'width' => 100
)
);
parent::__construct();
}
// 之前在AdminTab 時用$this->edit=true;
$this->addRowAction('edit');
// 之前在AdminTab 時用$this->delete=true;
$this->addRowAction('delete');
$this->bulk_actions = array(
'delete' => array(
'text' => $this->l('Delete selected'),
'confirm' => $this->l('Delete selected items?'))
);
| 加入批量的效果 |
Category: php, prestashop, programming 0 回應
文章總數:
回應總數:
最近更新日期:
最近回應日期:
本站建立日數:
繼上次幫部HP換電後,今次再次為notebook 加ram同換harddisk 來延長它的壽命 不過可惜部機不能support MVNE只能support NGFF, 所以只好買NGFF 的,現在買NGFF選擇真的不多,所以感覺上比起買隻MVNE來都有點貴,由於選擇不多,仲...