|
|
| Line 2: |
Line 2: |
| {{Template用户手册}} | | {{Template用户手册}} |
| {{TemplateMainPageZh}} | | {{TemplateMainPageZh}} |
|
| |
| 画布是替换屏幕显示的开发功能。 | | 画布是替换屏幕显示的开发功能。 |
|
| |
|
| Line 33: |
Line 32: |
|
| |
|
| 在这里: | | 在这里: |
| * '''mymodule''' 目录能找到画布参数的mymodule模块名(您选择此值并创建具有相同值的目录。使用小写值). | | * '''mymodule''' 能找到画布参数的mymodule模块的目录名(您选择此值并创建具有相同值的目录。使用小写值). |
| * '''mycanvas''' is value mycanvas found into canvas parameter (you choose this value and create directory with same value. use lower case value). | | * '''mycanvas''' 画布参数的名称 (您选择此值并创建具有相同值的目录。使用小写值). |
| * '''tabname''' 存储初始表单的选项卡的名称。在大多数情况下,它是价值的“card”。 | | * '''tabname''' 存储初始表单的选项卡的名称。在大多数情况下,它是价值的“card”。 |
|
| |
|
| For example, we will use value "'''company@societe'''" for canvas parameter. This is a value of an already coded demo canvas template for third parties, not used in a standard usage of Dolibarr but provided as "demo". So URL to create a third party using this alternative template is now:
| | 例如,用值 "'''company@societe'''" 作为画布参数. 这个值,已经为第三方编写了演示模板。 不在Dolibarr的标准库中,而是做为"Demo"。使用这个替代模板创建URL是: |
|
| |
|
| '''http://mydomain/societe/soc.php?action=create&leftmenu=customers&canvas=societe@company''' | | '''http://mydomain/societe/soc.php?action=create&leftmenu=customers&canvas=societe@company''' |
|
| |
|
| This means the form to create the third party will be found into template file:
| | 这意味着创建第三方的表单将载入模板文件: |
|
| |
|
| '''/societe/canvas/company/tpl/card_create.tpl''' | | '''/societe/canvas/company/tpl/card_create.tpl''' |
|
| |
|
| So to use you own template, just choose a value for '''mymodule''', '''mycanvas''', copy and paste a demo template found into Dolibarr directories with new directory and new file name and then edit the template like you want. Template contains all the part under the top menu and at right of left menu. You can change look, field order, add your javascript controls, remove or add your own fields. The only requirement is to keep mandatory fields with same name to avoid errors when you will submit the page. Fields removed will be filled with null or 0 into database. New fields for the moment are ignored. We will see later how we can add code to save them.
| | 使用自定义模板,只需选择值'''mymodule''', '''mycanvas''', 复制/粘贴一个Demo模板,新建目录,将粘贴的模板改名,然后修改模板内容。 |
| | |
| | 模板包含了水平菜单以下,左侧菜单以右的所有部分。 可以改变显示,字段顺序,增加javescript控制,移除或增加自定义字段。 唯一的要求是在提交页面时保留强制字段的名字以避免错误。不在模板中的字段将会填充为Null 或 0。新字段被忽略。稍后会学习增加代码以保存新字段。 |
|
| |
|
| Once this is done, you must now add the new create URL into Dolibarr menus or replace the existing one with new one. For this take a look at page [[Menus_system]].
| | 完成修改模板后,接下来将新的'创建URL'添加到Dolibarr菜单中,或者用新的菜单替换现有的URL。见 [[Menus_system]]. |
|
| |
|
| Note that when a record is saved using a canvas, the canvas name '''mycanvas@mymodule''' is also stored into database. This is important because this means, Dolibarr will be able to know that this record is a canvas and not the other so it will be able to them suggest a view or edit form dedicated for this record only and keep using standard forms for other records. See next chapters.
| | 注意,当使用画布保存记录时,画布名 '''mycanvas@mymodule''' 会存储于数据库中。因为,Dolibarr将能够知道这条记录是一个画布而不是另一个,因此,系统将只为这个记录使用专用的‘视图’或‘编辑’表单,并继续为其他记录使用标准表单。请参阅下一章。 |
|
| |
|
| = Replace an edit form with your own template = | | = 用自定义模板替换编辑表单 = |
| Using your own edit form for a record saved using your own create form is as simple as adding a file called
| | 使用自己的‘编辑’表单来编辑记录(使用自己的‘创建’表单保存的记录)只需添加一个文件: |
|
| |
|
| '''/mymodule/canvas/mycanvas/tpl/tabname_edit.tpl''' | | '''/mymodule/canvas/mycanvas/tpl/tabname_edit.tpl''' |
|
| |
|
| where
| | 这里: |
| * '''mymodule''' directory is value mymodule you used as canvas parameter to create record (see previous chapter). | | * '''mymodule''' 能找到画布参数的mymodule模块的目录名 (见前章). |
| * '''mycanvas''' is value mycanvas you used as canvas parameter to create record (see previous chapter). | | * '''mycanvas''' 画布参数的名称(见前章). |
| * '''tabname''' is name of tab or page to edit record. In most cases it is value "card". | | * '''tabname''' 编辑记录的选项卡名称,大多数为 "card". |
|
| |
|
| With our canvas demo societe@company, edit template will be into file
| | 以演示画布 societe@company 为例, 编辑模板在文件: |
| | | |
| '''/societe/canvas/company/tpl/card_edit.tpl''' | | '''/societe/canvas/company/tpl/card_edit.tpl''' |
|
| |
|
| Note that for edit, changing URL is not necessarly required. Dolibarr can detect your record is a personalized canvas record and automatically scan for this template file to show it if found. If not, standard form will be used. So all you have to do to use your own edit template is copy and paste an existing demo edit template file and rename it with correct value of mymodule and mycanvas and edit it to match your need.
| | 注意,对于编辑不需要更改URL。 |
| Like for creation, all mandatory fields must be kept to avoid errors when submitting the form to save change.
| | |
| | Dolibarr可以检测你的记录是一个自定义的画布记录,并自动扫描这个模板文件来显示。如果没有发现模板,将使用标准模板。 |
| | |
| | 因此,使用自己的编辑模板所需做的就是复制和粘贴现有的演示编辑模板文件,并用mymodule和mycanvas的正确值重命名它并编辑它以满足您的需要。 |
| | 与创建一样,当提交表单以保存更改时,必须保留所有强制字段以避免错误。 |
|
| |
|
| = Replace a view form with your own template = | | = 用自定义模板替换‘显示’窗体 = |
| Using your own view form for a record saved using your own create form is as simple as adding a file called
| | 使用自定义的‘显示’窗体来显示记录(使用自己的创建窗体保存的记录),只需添加文件: |
|
| |
|
| '''/mymodule/canvas/mycanvas/tpl/tabname_view.tpl''' | | '''/mymodule/canvas/mycanvas/tpl/tabname_view.tpl''' |
| Line 78: |
Line 83: |
| * '''tabname''' is name of tab or page to edit record. In most cases it is value "card". | | * '''tabname''' is name of tab or page to edit record. In most cases it is value "card". |
|
| |
|
| With our canvas demo societe@company, view template will be into file
| | 以演示画布 societe@company 为例, 显示模板在文件: |
| | | |
| '''/societe/canvas/company/tpl/card_view.tpl''' | | '''/societe/canvas/company/tpl/card_view.tpl''' |
|
| |
|
| Note that for view, changing URL is not necessarly required. Dolibarr can detect your record is a personalized canvas record and automatically scan for this template file to show it if found. If not, standard form will be used. So all you have to do to use your own view template is copy and paste an existing demo view template file and rename it with correct value of mymodule and mycanvas and edit it to match your need.
| | 注意,对于'显示',不需要更改URL。Dolibarr可以检测你的记录是一个自定义的画布记录,并自动扫描这个模板文件来显示记录。如果没有,将使用标准模板。因此,使用你自己的视图模板所要做的就是复制和粘贴一个现有的演示视图模板文件,并用mymodule和mycanvas的正确值重命名它并编辑它以满足您的需要。 |
|
| |
|
| = Add code to manage new fields = | | = 添加代码管理新字段 = |
| {{ToComplete}} | | {{ToComplete}} |
| Example into external module cabinetmed. | | Example into external module cabinetmed. |