選項卡
Jump to navigation
Jump to search
Dolibarr選項卡系統
Dolibarr在由多個選項卡組成的視圖中顯示元素(發票、倉庫、用戶等)的信息。
您可以添加自己的選項卡、刪除選項卡或替換現有選項卡。
添加您自己的選項卡
1) 首先,您需要確定要添加、刪除或修改的選項卡所指向的對象類型及其代碼「objectType」。以下是完整清單:
- 'thirdparty' --------- 要在合作方視圖中添加選項卡
- 'intervention' ------ 要在現場服務視圖中添加選項卡
- 'supplier_order' --- 要在供應商訂單視圖中添加選項卡
- 'supplier_invoice' - 要在供應商發票視圖中添加選項卡
- 'invoice' to add a tab in customer invoice view
- 'order' to add a tab in customer order view
- 'product' to add a tab in product view
- 'stock' to add a tab in stock view
- 'propal' to add a tab in propal view
- 'member' to add a tab in fundation member view
- 'contract' to add a tab in contract view
- 'user' to add a tab in user view
- 'group' to add a tab in group view
- 'contact' to add a tab in contact view
- 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
- 'member_stats', 'order_stats', 'supplier_order_stats', 'invoice_stats', 'supplier_invoice_stats', 'trip_stats', 'propal_stats' to add a tab in statistic view of elements.
- 'member_admin', 'company_admin', 'product_admin' for admin pages
2) 然後添加您的選項卡,創建一個新的模塊文件。見 模塊開發 。
3) 然後進入描述符文件,編輯$this->tab,使用以下語法添加選項卡:
$this->tabs = array(
'objecttype:+tabname:TitleOfTab:@mymodule:$conditiontoshowtab:urloftab?id=__ID__'
);
這是一個由5或6個元素組成的字符串(取決於你是否選擇使用$conditiontoshowtab),用;分隔。
這裡:
- objecttype 是您將使用的Tab的名稱。
- +tabname 是一個名稱來標識您的選項卡,前面是動作(+ 添加或 - 刪除,您可以刪除其他選項卡,包括默認的)。
- TitleOfTab 是一個你選擇的標題,它將被翻譯。
- @mymodule 是語言文件,裡面是翻譯條目。 (如: mytitlelang@mymodule 會查找 /htdocs/mymodule/langs/xx_XX/mytitlelang xx_XX 是當前語言如: en_US, fr_FR, etc.).
- $conditiontoshowtab 是否顯示: 是真則顯示,假則不顯示。如: you can use the Dolibarr rights system, eg: $user->rights->product->creer or $user->admin or any other variable you want. 此項是可選項,跳過也是可以的。不要忘記分號也要刪除。
- urloftab?id=__ID__ 是選項卡指向的URL。使用占位符 __ID__ 替代id。如:DOL_DOCUMENT_ROOT.'/mymodule/lib/mytab.php'
例如:
$this->tabs = array(
'product:+tabname1:Title1:@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 in objecttype product (Products/Services)
'product:+tabname2:Title2:@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 in objecttype product (Products/Services)
);
4) 激活模塊
5) 測試新選項卡
刪除現在的選項卡
刪除選項卡的操作與添加選項卡相同,在模塊文件的tabs數組中使用以下語句:
$this->tabs = array(
'objecttype:-tabnametobedeleted'
); // To remove an existing tab identified by code tabnametobedeleted
注意:在這種情況下不需要其他參數。
如何確定你要刪除的選項卡的名稱
- 打開瀏覽器的開發者工具。
- 單擊選擇元素按鈕
- 在窗口中選擇你要刪除的Dolibarr選頂卡。
- 在開發者工具中查看 tab 屬性
要用您的選項卡替換選項卡
只需執行「添加您自己的選項卡」和「刪除現有選項卡」步驟。如果添加的選項卡標題與刪除的選項卡標題相同,則錯覺將是完美的。
將標籤顯示在自己的頁面中 在頁面中顯示選項卡
有關如何在自己的頁面中顯示選項卡的更多信息,請參閱 Module_development#The_tab_management