modx资料笔记
时间:2010-03-19 来源:lsstarboy
1、专用术语
chunks:一段可以重复利用的语句,相当于手机中的“范文”,可以用在正文或模板中。典型例子是把姓名、住址等存为一个chunks,然后在模板的不同地方引用它。
引用形式为:{{MyChunk}}
Snippets:有一定输出的小PHP程序片段。在模板、正文、甚至是chunks中被引用并运行。
2、模板要规划好所有的东西,包括页眉和页脚,模板不定义的东西不会显示出来。
3、后台文件树和正文中的分隔线位置是可以调节的,也可以在管理中定义它的大小。
4、文件树中可以用快捷菜单(文件树在英文中称为Manager)。
5、图片文件和pdf(包括其它文本文件,可以定义)文件必须传到/assets/中相应的目录。
6、最左上方有“清除缓存”按钮。
7、在内容方面,modx用tag来简单定义内容。[content]被插入到[document]中的时候,document不用考虑content是如何定义的。(这样便于内容间的相互独立。)
tag示例:
10、Placeholders:占位符,+name+,+title+,可以用在模板的任何位置。
11、常用的文档模板变量,可以用$modx->documentObject['varialbe-name']来显示出来:
13、Template Variables(TVs),常用的有:
15、snippets:
常用来实现一些动态的内容,比如查询数据库、引用session变量等,它的好处是放到模板中不影响模板的布局。
snippets是存储在数据库中的,但是某些复杂的snippets可能会用一些使文件来辅助。这些文件在 /assets/snippets中都有自己专用的目录。但是大多数的snippets都不会出现在文件系统中。
一些snippets在安装系统的时候有个安装提示,如果你选择了安装,那么它们已经可以使用了。
安装snippets也很简单,只要在“资源”中找到“代码片断”,然后把snippets的代码复制到里面就可以了。名称可以随便取,但是你要记住,否则做模板的时候可能会有一些麻烦。对于有辅助文件的snippets,把它上传到/assets/snippets新建的文件夹中,新建的文件夹注意用小写,最好保持最原始的文件夹名。
[[SnippetName]] or [!SnippetName!]的区别:前者是缓存的,后者是不缓存的。例如登录snippet,就必须用不缓存的。
snippets可以用html的参数方式来传递参数:?aa=bb&cc=dd
16、用户相关的几个概念:
Document:modx最基本的元素,是一个资源。
Documnet group:文档组,一个文档可以属于不同的文档组,一个文档组可以与一个或多个用户组相关联。
user:用户仅仅是用户名、密码等集合,用户的活动范围受权限的控制,权限控制通过“角色”来实现。一个用户可以属于不同的“用户组”,但是只能属于一种“角色”。
User group:用户组,需要访问同一个“文档组”的同一类用户,注意“文档组”。一个用户组与一个或多个“文档组”相关联。
“角色”用来控制一个用户的权限,用户组和文档组的组合用来控制用户可以工作于哪些文档。
“角色”决定了用户“可以干什么”,而“用户组”决定了“可以做哪些文档”。用户组可以做的文档,角色用来指定可以进行哪些操作。
17、---- Developer's Guide
18、超强的API文档
chunks:一段可以重复利用的语句,相当于手机中的“范文”,可以用在正文或模板中。典型例子是把姓名、住址等存为一个chunks,然后在模板的不同地方引用它。
引用形式为:{{MyChunk}}
Snippets:有一定输出的小PHP程序片段。在模板、正文、甚至是chunks中被引用并运行。
2、模板要规划好所有的东西,包括页眉和页脚,模板不定义的东西不会显示出来。
3、后台文件树和正文中的分隔线位置是可以调节的,也可以在管理中定义它的大小。
4、文件树中可以用快捷菜单(文件树在英文中称为Manager)。
5、图片文件和pdf(包括其它文本文件,可以定义)文件必须传到/assets/中相应的目录。
6、最左上方有“清除缓存”按钮。
7、在内容方面,modx用tag来简单定义内容。[content]被插入到[document]中的时候,document不用考虑content是如何定义的。(这样便于内容间的相互独立。)
tag示例:
- [[snippet]] or [!snippet!] for non-caching snippets Inserts the output of a snippet named 'snippet' into your page.(这一个也是snippet的引用方式,是不缓存的)。
- [(setting)] Inserts the value of a site-wide setting named 'setting' into your page.
- [*resourceField/TV*] Inserts various blocks of content specific to the page being displayed.
- [^timing^] Shows how long it took to create the current page.
- [~link~] Makes a link to another document in your MODx site.
- chunk Inserts a chunk of HTML into your page.
- [+placeholder+] Acts as a placeholder for content generated by a snippet. Usually used in a chunk specified in an argument of the snippet to format the snippet's output.
There are several timing tags in MODx:
- [^qt^] - Query Time - Shows how long MODx took talking to the database
- [^q^] - Query Count -Shows how many database queries MODx made
- [^p^] - Parse Time - Shows how long MODx took to parse the page
- [^t^] - Total Time - Shows the total time taken to parse/ render the page
- [^s^] - Source - Shows the source of page, whether is database or cache.
10、Placeholders:占位符,+name+,+title+,可以用在模板的任何位置。
11、常用的文档模板变量,可以用$modx->documentObject['varialbe-name']来显示出来:
- id - The document's ID. Can also be obtained with $modx->documentIdentifier.
- type - Whether document, folder or weblink.
- contentType - The content type, such as text/html.
- pagetitle - The title of the page.
- longtitle - The longtitle of the page.
- description - The description of the page.
- alias - The alias of the page. Used in creating Friendly URLs.
- published - [0|1] Whether or not the document is published.
- pub_date- Date the document is to be published. This is not a "normal" date, and must be processed by a script for meaningful output. Example: strftime("%d/%m/%y %H:%M:%S", $value)
- unpub_date - Date the document is to be unpublished. See 'pub_date'.
- parent - The ID of the document's parent.
- isfolder - [0|1] Whether or not the document is a folder.
- introtext - The summary of the document.
- content - The content of the document.
- richtext - [0|1] Whether or not a RichText Editor is to be used when editing the document.
- template - The ID of the template to used for the document.
- menuindex - The order in which the document is to be listed in the menu.
- searchable - [0|1] Whether or not the document is to be searchable.
- cacheable - [0|1] Whether or not the document is to be cached.
- createdby - The user ID of the creator of the document.
- createdon - The date the document was created. See 'pub_date'.
- editedby - The ID of the user who last edited the document.
- editedon - The date the document was last edited. See 'pub_date'.
- deleted - [0|1] Whether or not the document has been deleted (but not yet completely removed from the database by emptying the trash).
- deletedon - The date the document was deleted. See 'pub_date'.
- deletedby - The ID of the user who deleted the document.
- menutitle - The title to be shown in the menu. If empty, the pagetitle is used.
- donthit - [0|1] Disable page hit count for the document.
- haskeywords - [0|1] Whether or not the document has links to keywords.
- hasmetatags - [0|1] Whether or not the document has links to meta tags
- privateweb - [0|1] Whether or not this document has been assigned to a private web document group.
- privatemgr - [0|1] Whether or not this document has been assigned to a private manager document group.
- content_dispo - [0|1] Whether the document's content-disposition is attachment or inline.
- hidemenu - [0|1] Whether or not the document is to be hidden in the menu.
13、Template Variables(TVs),常用的有:
- [*pagetitle*] - the title of the document
- [*longtitle*] - the long title of the document
- [*introtext*] - the summary of the document
- [*content*] - the content of the document
- id - The document's ID. Can also be obtained with $modx->documentIdentifier.
- type - Whether document, folder or weblink.
- contentType - The content type, such as text/html.
- pagetitle - The title of the page.
- longtitle - The longtitle of the page.
- description - The description of the page.
- alias - The alias of the page. Used in creating Friendly URLs.
- link_attributes - The Link Attributes of the page, eg. rel=, target= etc.
- published - [0|1] Whether or not the document is published.
- pub_date- Date the document is to be published. This is not a "normal" date, and must be processed by a script for meaningful output.
- unpub_date - Date the document is to be unpublished. See 'pub_date'.
- parent - The ID of the document's parent.
- isfolder - [0|1] Whether or not the document is a folder.
- introtext - The summary of the document.
- content - The content of the document.
- richtext - [0|1] Whether or not a RichText Editor is to be used when editing the document.
- template - The ID of the template to used for the document.
- menuindex - The order in which the document is to be listed in the menu.
- searchable - [0|1] Whether or not the document is to be searchable.
- cacheable - [0|1] Whether or not the document is to be cached.
- createdby - The user ID of the creator of the document.
- createdon - The date the document was created. See pub_date.
- editedby - The ID of the user who last edited the document.
- editedon - The date the document was last edited. See pub_date.
- deleted - [0|1] Whether or not the document has been deleted (but not yet completely removed from the database by emptying the trash).
- deletedon - The date the document was deleted. See pub_date.
- deletedby - The ID of the user who deleted the document.
- menutitle - The title to be shown in the menu. If empty, the pagetitle is used.
- donthit - [0|1] Disable page hit count for the document.
- haskeywords - [0|1] Whether or not the document has links to keywords.
- hasmetatags - [0|1] Whether or not the document has links to meta tags
- privateweb - [0|1] Whether or not this document has been assigned to a private web document group.
- privatemgr - [0|1] Whether or not this document has been assigned to a private manager document group.
- content_dispo - [0|1] Whether the document's content-disposition is attachment or inline.
- hidemenu - [0|1] Whether or not the document is to be hidden in the menu.
15、snippets:
常用来实现一些动态的内容,比如查询数据库、引用session变量等,它的好处是放到模板中不影响模板的布局。
snippets是存储在数据库中的,但是某些复杂的snippets可能会用一些使文件来辅助。这些文件在 /assets/snippets中都有自己专用的目录。但是大多数的snippets都不会出现在文件系统中。
一些snippets在安装系统的时候有个安装提示,如果你选择了安装,那么它们已经可以使用了。
安装snippets也很简单,只要在“资源”中找到“代码片断”,然后把snippets的代码复制到里面就可以了。名称可以随便取,但是你要记住,否则做模板的时候可能会有一些麻烦。对于有辅助文件的snippets,把它上传到/assets/snippets新建的文件夹中,新建的文件夹注意用小写,最好保持最原始的文件夹名。
[[SnippetName]] or [!SnippetName!]的区别:前者是缓存的,后者是不缓存的。例如登录snippet,就必须用不缓存的。
snippets可以用html的参数方式来传递参数:?aa=bb&cc=dd
16、用户相关的几个概念:
Document:modx最基本的元素,是一个资源。
Documnet group:文档组,一个文档可以属于不同的文档组,一个文档组可以与一个或多个用户组相关联。
user:用户仅仅是用户名、密码等集合,用户的活动范围受权限的控制,权限控制通过“角色”来实现。一个用户可以属于不同的“用户组”,但是只能属于一种“角色”。
User group:用户组,需要访问同一个“文档组”的同一类用户,注意“文档组”。一个用户组与一个或多个“文档组”相关联。
“角色”用来控制一个用户的权限,用户组和文档组的组合用来控制用户可以工作于哪些文档。
“角色”决定了用户“可以干什么”,而“用户组”决定了“可以做哪些文档”。用户组可以做的文档,角色用来指定可以进行哪些操作。
17、---- Developer's Guide
18、超强的API文档
相关阅读 更多 +