选项卡

Revision as of 13:21, 23 July 2019 by PolyglotBot (talk | contribs) (Import interlang links (links to translated versions of this page in other languages) from origin English page "Tabs_system".)

Dolibarr选项卡

Dolibarr通过选项卡来显示元素的信息。

可以添加、删除或替换现存的选项卡

添加选项卡

1) 首先, 必须标识选项卡所涉及的对象类型及其对象类型代码。这是完整的列表:

  • 'thirdparty' to add a tab in third party view
  • 'intervention' to add a tab in intervention view
  • 'supplier_order' to add a tab in supplier order view
  • 'supplier_invoice' to add a tab in supplier invoice view
  • '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