Markup Tags of magento CMS
来源:互联网 发布:韩国眼中的中国 知乎 编辑:程序博客网 时间:2024/06/05 00:27
* Markup Tags
o What is a template tag?
o Where can I use template tags?
o How do I use template tags?
o Which tags can I use?
+ {{block id='block_id'}}
+ {{block type='module/package_classname' template='path/to/template.phtml'}}
+ {{htmlescape var='' allowed_tags=''}}
+ {{layout handle=''}}
+ {{media url=''}}
+ {{skin url=''}}
+ {{store url=''}}
+ {{store direct_url=''}}
o How do template tags work?
o Further information
o Appendix: Creating a custom block type which can accept arguments
This article details which template tags can be used on CMS pages, in static blocks, and in email templates.
What is a template tag?
A template tag is a bit of text surrounded by double curly braces which has a special meaning to Magento, e.g., de>{{store url=""}}de>.
You might use a template tag to
- link to a page within your store without typing out your domain name
- embed a block within a page without editing layout or template files
Template tags have a variety of uses.
Where can I use template tags?
You can use template tags on CMS pages, in static blocks, and in email templates.
How do I use template tags?
You use template tags by entering them in on
To illustrate, say you wanted to display your company’s “About Us” image on your store’s home page. (You can manage the content of the home page by navigating to CMS > Manage Pages and then clicking on “Home page” in the back end.) You might do this by typing
- <img src="http://www.example.com/skin/frontend/default/default/images/media/about_us_img.jpg" />
but that’s a lot to type. Instead, using a template tag, you could simply say
- <img src="{{skin url='images/media/about_us_img.jpg'}}" />
Which tags can I use?
Note: In the following examples I’m assuming that a working Magento install is set up at de>www.example.comde>.
You can use the following tags:
{{block id='block_id'}}
This tag inserts the static block which has the identifier “de>block_idde>“. (Static blocks can be managed by navigating to CMS > Static Blocks in the back end.)
Example:
- {{block id='footer_links'}}
This co
{{block type='module/package_classname' template='path/to/template.phtml'}}
This inserts a block of the type de>module/package_classnamede> using the template de>path/to/template.phtmlde>. The string de>module/package_classnamede> translates into a class name which is defined in the de>Blockde> directory of de>modulede>. (Thus de>core/text_listde>, for instance, translates intode>Mage_Core_Block_Text_Listde>, which is defined in de>app/co
If the module’s de>Blockde> directory contains no sub directories, the de>package_de> part of the string is omitted. (Thus the string de>tag/popularde> translates into de>Mage_Tag_Block_Popularde>, which is defined in de>app/co
The value of the template attribute should be the path to the template that corresponds to the block, starting from the theme directory (e.g., de>tag/popular.phtmlde>).
Example:
- {{block type='core/template' template='cms/custom_page.phtml'}}
This co
{{htmlescape var='' allowed_tags=''}}
Escapes all HTML tags in the value of the de>varde> attribute, except for those specified in the value of thede>allowed_tagsde> attribute. (The latter expects a comma separated list of allowed HTML tags).
Example:
- {{htmlescape var='<a href="javas
cript:alert(1);">Hello</a>'}}
This will produce the output de><a href=”javas
{{layout handle=''}}
Inserts HTML layout output. The de>handlede> attribute expects the name of a layout handle, e.g. de>defaultde>.
{{media url=''}}
Inserts the URL of the media directory, e.g., de>http://www.example.com/media/de>. Changing the value of thede>urlde> attribute to a non-empty string will cause the string to be appended to this URL.
Example:
- {{media url='catalog/product/l/a/large_phone.jpg'}}
This will produce the output de>http://www.example.com/media/catalog/product/l/a/large_phone.jpgde>.
{{skin url=''}}
Inserts the URL of the current theme’s skin directory, e.g., de>http://www.example.com/skin/frontend/default/default/de>. Changing the value of the de>urlde> attribute to a non-empty string will cause the string to be appended to this URL.
Example:
Assuming you’re using the default theme and the default interface, then
- {{skin url='images/media/about_us_img.jpg'}}
will be converted to de>http://www.example.com/skin/frontend/default/default/images/media/about_us_img.jpgde>.
{{store url=''}}
Inserts the store’s base URL, i.e., the URL of the store’s home page. (Sample output: de>http://www.example.com/de>.) Changing the value of the de>urlde> attribute to a non-empty string will cause the string to be appended to the store’s base URL and a slash (de>/de>) to be tacked on to the end of the resulting URL. This trailing slash makes thede>urlde> attribute suitable for referencing directory-like paths, e.g. de>customer/accountde>.
Example:
- {{store url='about-magento-demo-store'}}
This will be converted to de>http://www.example.com/index.php/about-magento-demo-store/de>. Note the terminating slash in this URL; this is what distinguishes the de>urlde> attribute from the de>direct_urlde> attribute.
{{store direct_url=''}}
Does the same as de>{{store url=''}}de> but without appending a slash to the resulting URL. This is suitable for referencing file-like paths, e.g. de>coffee/kona-fancy-whole-bean.htmlde>.
How do template tags work?
This is roughly what happens when Magento encounters a template tag it understands:
- Magento uses the tag to populate an array with three elements. The first element is the whole tag (e.g., de>{{store url='coffee/test.html'}})de>. The second element is the keyword which follows immediately after the opening curly braces (e.g., de>storede>). The third element is the tag’s keyword=value pair (e.g.,de>url='coffee/test.html'de>).
- Magento passes the array to a method of the de>Mage_Core_Model_Email_Template_Filterde> class. The name of the method depends on the keyword within the tag: if the keyword is de>storede>, for instance, thede>storeDirectivede> method will be called.
- The method returns a value. This value is used instead of the template tag on the front end.
Further information
For more on how template tags work and which parameters they take, see Ivan Weiler’s "Magento CMS syntax – part1".
Appendix: Creating a custom block type which can accept arguments
To learn how you can use a template tag such as
- {{block type='namespace_custom/test' my_param1='value 1' my_param2='value 2'}}
see Moshe’s tutorial on creating a block class which extends Mage_Core_Block_Abstract and overloads the _toHtml() method.
From:http://www.magentocommerce.com/wiki/markup_tags
ref:http://lhdeyx.blog.163.com/blog/static/31819697201001521759600/
- Markup Tags of magento CMS
- Definition of 'Markup'
- MAGENTO中的标签(TAGS)
- magento cms tutorial
- magento cms Widget
- [SilkTest]Overview of tags
- Magento CMS controller override / cms page controller override in magento
- Magento CMS分页功能实现
- Markup
- Where is the best place to put <script> tags in HTML markup?
- magento -- 如何实现多语言的magento cms 页面
- 如何在magento CMS homepage 加上breadcrumbs
- 在magento CMS中的标签变量使用
- 帝国cms文章内容tags关键词设置调用方法以及tags静态化
- 如何让 帝国cms文章内容tags关键词设置调用方法以及tags静态化?
- Run Magento Code Outside of Magento
- Categories of Popular Tags on Flickr
- tags
- mini2440 linux-3.7移植记录(二)
- Linear Sieve Method for Prime Numbers
- 饥渴的程序员
- Timer用法
- C语言算法(一)基础
- Markup Tags of magento CMS
- Servlet第五章、第六章知识点总结——Web应用程序状态管理、对象作用域
- 根据变量值获取变量名
- 如何理解stdlib.h里的_countof()宏
- 点击按钮——网页返回顶部代码
- oracle中exp,imp的使用详解
- java.nio.ByteBuffer 详解 .
- Android实战技巧:如何在ScrollView中嵌套ListView
- 麦芬配方存档