.. You may want to use the usual include line. Uncomment and adjust the path. .. include:: ../Includes.txt =================== Auto-parse Template =================== :Author: Jigal van Hemert :Created: 2009-06-16T23:48:17 :Changed by: Jigal van Hemert :Changed: 2013-05-04T14:47:43.010000000 :Classification: automaketemplate :Description: The keywords help with categorizing and tagging of the manuals. You can combine two or more keywords and add additional keywords yourself. Please use at least one keyword from both lists. If your manual is NOT in english, see next tab "language" ---- forEditors (use this for editors / german "Redakteure") forAdmins (use this for Administrators) forDevelopers (use this for Developers) forBeginners (manuals covering TYPO3 basics) forIntermediates (manuals going into more depth) forAdvanced (covering the most advanced TYPO3 topics) see more: http://wiki.typo3.org/doc_template#tags ---- :Keywords: forEditors, forAdmins, forBeginners, forIntermediates :Author: Kasper Skårhøj :Email: kasper@typo3.com :Info 4: :Language: en |img-1| |img-2| Auto-parse Template - automaketemplate .. _Auto-parse-Template: Auto-parse Template =================== Extension Key: automaketemplate Language: en Keywords: forEditors, forAdmins, forBeginners, forIntermediates Copyright 2000-2009, Kasper Skårhøj, Update: 2009-2013, Jigal van Hemert, This document is published under the Open Content License available from http://www.opencontent.org/opl.shtml The content of this document is related to TYPO3 \- a GNU/GPL CMS/Framework available from www.typo3.org .. _Table-of-Contents: Table of Contents ----------------- `Auto-parse Template 1 <#1.Auto-parse%20Template|outline>`_ **`Introduction 3 <#1.1.Introduction|outline>`_** **`Configuration 4 <#1.2.Configuration|outline>`_** `Base properties: 4 <#1.2.1.Base%20properties:|outline>`_ `->element: 4 <#1.2.2.-%3Eelement:|outline>`_ `->single: 5 <#1.2.3.-%3Esingle:|outline>`_ `Using this to build a site: 8 <#1.2.4.Using%20this%20to%20build%20a%20site:|outline>`_ .. _Introduction: Introduction ------------ This plugin can be used to read an HTML file, then automatically insert subpart-markers around parts with certain classes/ID's. There are these objectives: - Allow an CSS based HTML-file including file-references, existing somewhere in fileadmin/.../ to be used directly as template by TYPO3. - Keeping the original template file totally free of HTML-comments (which some editors might filter out by accident) and totally viewable with all references intact. This extension is `demonstrated in the tutorial “Modern Template Building, Part 1” `_ . .. _Configuration: Configuration ------------- .. _Base-properties: Base properties: ^^^^^^^^^^^^^^^^ .. ### BEGIN~OF~TABLE ### .. _content: content """"""" .. container:: table-row Property content Data type cObject Description This delivers the content for the parser. Probably a FILE cObject. Default .. _elements-tag-all: elements.[tag].all """""""""""""""""" .. container:: table-row Property elements.[tag].all elements.[tag].id.[value] elements.[tag].class.[value] Data type ->element Description Defines an HTML-element to be wrapped. [tag] name in upper case! All tags defined here should be tags with both open AND closing tags (eg. “A”: ...., or “TABLE”: ....
) .id takes precedence over .class which in turn takes precedence over all. Default .. _elements-tag-rmTagSections: elements.[tag].rmTagSections """""""""""""""""""""""""""" .. container:: table-row Property elements.[tag].rmTagSections elements.[tag].rmSingleTags Data type list of tags Description A list of tags (in lowercase) which will be removed (with content) from the section. See example with the HEAD tag. Use "rmTagSections" only for tags which have an ending tag as well. Use "rmSingleTags" only for tags which does NOT have ending tags (br,hr,img,input,meta,area,embed etc.) Default .. _elements-tag-str-replace-key-value: elements.[tag].str\_replace.[key].value """"""""""""""""""""""""""""""""""""""" .. container:: table-row Property elements.[tag].str\_replace.[key].value elements.[tag].str\_replace.[key].replaceWith elements.[tag].str\_replace.[key].useRPFunc Data type Description Replace strings in block. [key] is any string, number etc, just used to allow multiple str/replace operations. **Example:** :: elements.TD.str_replace.10 { value = #996633 replaceWith = blue } This example replaces the color “#996633” in all table cells with “blue” To use a the “preg\_replace” function instead, just set :: elements.TD.str_replace.10.useRPFunc = preg_replace Note that ereg\* functions are deprecated in PHP 5.3! Use preg\_replace instead. ereg\_replace support is removed in the current version of automaketemplate. Default .. _single-tag-all: single.[tag].all """""""""""""""" .. container:: table-row Property single.[tag].all single.[tag].id.[value] single.[tag].class.[value] Data type ->single Description Defines an HTML-tag to be wrapped. [tag] name is in uppercase. All tags defined here should be tags WITHOUT closing tags, eg. “” or similar. “.single” corresponds to “.elements” but deals only with “single”-tags (like or
or
) as opposed to “.elements” which deals with blocks (like ....
). Default .. _relPathPrefix: relPathPrefix """"""""""""" .. container:: table-row Property relPathPrefix relPathPrefix.[tag] Data type string Description Prefix to all relative paths in the file. If the .[tag] (uppercase) is specified, then this value will define an alternative path for those tags. **Example:** :: relPathPrefix = fileadmin/html/ relPathPrefix.IMG = fileadmin/html/imageset_2/ (so another set of images in the folder “imageset\_2” will be used while all other references are kept.) Default .. _getBodyTag: getBodyTag """""""""" .. container:: table-row Property getBodyTag Data type boolean Description If set, then body tag is returned from the content, if found. Default .. ###### END~OF~TABLE ###### .. _element: ->element: ^^^^^^^^^^ .. ### BEGIN~OF~TABLE ### .. _includeWrappingTag: includeWrappingTag """""""""""""""""" .. container:: table-row Property includeWrappingTag Data type Description If set, the wrapping will occur on the outside of the tag instead of the inside. Default .. _subpartMarker: subpartMarker """"""""""""" .. container:: table-row Property subpartMarker Data type string Description Alternative subpart marker. Default is the id/class attribute value wrapped in triple-# Default .. _doubleWrap: doubleWrap """""""""" .. container:: table-row Property doubleWrap Data type boolean Description If set, the tag is wrapped both inside and outside. Inside is default. The outside wrap will be prefixed “\_PRE”. Default .. ###### END~OF~TABLE ###### .. _single: ->single: ^^^^^^^^^ .. ### BEGIN~OF~TABLE ### .. _subpartMarker: subpartMarker """"""""""""" .. container:: table-row Property subpartMarker Data type string Description Alternative subpart marker. Default is the id/class attribute value wrapped in triple-# Default .. ###### END~OF~TABLE ###### .. _Example: Example """"""" Say you have this TypoScript configuration of the plugin in a template record: :: # Plugin configuration: plugin.tx_automaketemplate_pi1 { content = FILE # Filename to template file: (1) content.file = fileadmin/html/index.html elements { # (2) BODY.all = 1 BODY.all.subpartMarker = DOCUMENT_BODY # (3) HEAD.all = 1 HEAD.all.subpartMarker = DOCUMENT_HEADER HEAD.rmTagSections = title # (4) SPAN.class.sitepath = 1 # (5) TABLE.all = 1 TABLE.all.includeWrappingTag = 1 # (6) TABLE.class.mainTable_class = 1 TABLE.id.mainTable_id = 1 TABLE.id.mainTable_id.doubleWrap = 1 # (7) TD.id.header = 1 TD.class.content_column = 1 # (8) DIV.all = 1 } # (9) relPathPrefix = fileadmin/html/ } This configures the plugin to do the following: - (1) Read the file “fileadmin/html/index.html” - (2) Wrap the (all...) :code:`` -tag with the subpart marker :code:`` - (3) Wrap the :code:`` -tag with the subpart marker :code:`` and remove any title-tag + content found herein. - (4) If a :code:`` -tag with the class-attribute's value set to “sitepath”, then wrap the content with the default subpart-marker (which is :code:`` ) - (5) All :code:`` tags with either class or id attribute set should be wrapped in markers - (6) If a particular :code:`
` -tag has the class attribute set to “mainTable\_class” then wrap it with :code:`` . The same if a :code:`
` -tag has the id attribute set to “mainTable\_id”, but in this case the table- tag will be wrapped both inside and outside (default is inside). Furthermore if a :code:`
` -tag has both the id and class attributes set to these values the id will take precedence. - (7) If a :code:`
` -cell is found with id attribute set to “header”, then wrap it.If a :code:`` -cell is found with the class attribute set to “content\_column”, then wrap it as well. - (8) All :code:`
` -tags with either class or id attribute set will be wrapped on the inside. - (9) All relative paths found in the file will be prefixed with “fileadmin/html/” So lets look at a real world example. This is the “fileadmin/html/index.html” file: *(All green parts are displaying the interesting parts. All writing in red is my comments here, not a part of the output!)* :: Template title You are here: First level > Second level > Third level
Nothing in this table.
This table has the class, "my-class", and the id, "my-id"
This table has the class, "mainTable_class"
This table has the id, "mainTable_id"
This table has the id, "mainTable_id" AND the class "mainTable_class"
Content here... Content here... Content here... Content here...

This is a header

In principio creavit Deus caelum et terram terra autem erat inanis et vacua et tenebrae super faciem abyssi et spiritus Dei ferebatur super aquas dixitque Deus fiat lux et facta est lux et vidit Deus lucem quod esset bona et divisit lucem ac...

**Output:** And this is the output from the plugin after parsing the file based on the configuration above: *(My comments in red)* :: As expected the -tag was wrapped on the inside with ###DOCUMENT_HEADER###. Notice that the -tag has been removed as well. Typo3 sets the title-tag (along with a lot of additional header-information as needed.) <head><!--###DOCUMENT_HEADER### begin --> <style> BODY {font-size:12px; font-family: verdana;} .sitepath {color: blue;} </style> <!--###DOCUMENT_HEADER### end --></HEAD> The <BODY>-tag has also been wrapped: <body bgcolor="#eeeeee"><!--###DOCUMENT_BODY### begin --> <SPAN>-tags with the class-attribute value set to “sitepath” was configured to be wrapped with the default subpartmarker (which is the value itself surrounded by triple-# marks) thus it has happend. You are here: <span class="sitepath"><!--###sitepath### begin -->First level > Second level > Third level<!--###sitepath### end --></SPAN><br> *Any <DIV> tag having either id or class attribute set should be wrapped as well:* :: <DIV class="allTheTables"><!--###allTheTables### begin --> *Just for the record: This <TABLE>-tag has NOT been wrapped in anything because it didn't provide neither id nor class attributes. Therefore no action is taken.* :: <table> <tr><td>Nothing in this table.</TD></tr> </TABLE> *But here something happens. Looking at the TypoScript configuration the values for class and id does NOT match any of the explicitly configured values (which are “mainTable\_id” and “mainTable\_class”). However <TABLE>-tags in general are instructed to be wrapped if one of these values exists (TABLE.all = 1). In this cas both class AND id exists and therefore the id-attribute takes precedence and so the table is wrapped in ###my-id### markers.* Finally notice that the <TABLE>-tags are wrapped on the OUTSIDE. This is because of the TS configuration “TABLE.all.includeWrappingTag = 1” :: <!--###my-id### begin --><table class="my-class" id="my-id"> <tr><td>This table has the class, "my-class", and the id, "my-id"</TD></tr> </TABLE><!--###my-id### end --> Now the class attribute matches the specifically configured value “mainTable\_class” and is wrapped on the INSIDE (default) accordingly :: <table class="mainTable_class"><!--###mainTable_class### begin --> <tr><td>This table has the class, "mainTable_class"</TD></tr> <!--###mainTable_class### end --></TABLE> In this case the id attribute matches the configured value “mainTable\_id”. Because “mainTable\_id” was configured in TS like this: “TABLE.id.mainTable\_id.doubleWrap = 1” the <TABLE>-tags are wrapped both on the inside AND the outside. The outside-wrap is prefixed “\_PRE” :: <!--###mainTable_id_PRE### begin --><table id="mainTable_id"><!--###mainTable_id### begin --> <tr><td>This table has the id, "mainTable_id"</TD></tr> <!--###mainTable_id### end --></TABLE><!--###mainTable_id_PRE### end --> In this case the exact same thing happens as above. The interesting part is that now the class-attribute did also exist, but we see once again that the id-attribute takes precedence in cases with both values existing. :: <!--###mainTable_id_PRE### begin --><table class="mainTable_class" id="mainTable_id"><!--###mainTable_id### begin --> <tr><td>This table has the id, "mainTable_id" AND the class "mainTable_class"</TD></tr> <!--###mainTable_id### end --></TABLE><!--###mainTable_id_PRE### end --> <table> <tr> Looking at the TS configuration we see that <TD>-tags are wrapped in case the id attribute matches “header” OR the class attribute matches “content\_column”. In these cases only the second <TD> tag from the top matches and is wrapped. :: <td class="header">Content here...</TD> <td id="header"><!--###header### begin -->Content here...<!--###header### end --></TD> <td class="another_header">Content here...</TD> <td id="another_header">Content here...</TD> <td>Content here...</TD> </tr> </TABLE> *A most interesting feature is that this images was in the original file references as “images/apache\_pb.gif”. Now the file - being a relative reference - is prefixed with “fileadmin/html”. Thus viewing the template file directly with a browser or HTML-editor from the path fileadmin/html/index.html will STILL show the correct image as when the file is used as template for the actual Typo3 page which is viewed from the site root.* :: <IMG src="fileadmin/html/images/apache_pb.gif" width="259" height="32" border="0" alt=""> <!--###allTheTables### end --></DIV> <table> <tr> *This is a real world example where we have a table on a page with a cell for a menu and a cell for page content. Probably we intended both columns to be wrapped on the inside with subpart markers, but only the “content\_column” has been wrapped. The obvious error is that in the TS configuration of the plugin, we should have added “TD.class.menu\_column = 1” in order to get the menu column wrapped as well. Another option - for the lazy - is to configured TD like this “TD.all=1” - so all TD cells with an id or class attribute would be wrapped.* :: <td class="menu_column"> Menu item 1<br> Menu itme 2<br> Menu item 3<br> </TD> <td class="content_column"><!--###content_column### begin --> <H3>This is a header</H3> <P>In principio creavit Deus caelum et terram terra autem erat inanis et vacua et tenebrae super faciem abyssi et spiritus Dei ferebatur super aquas dixitque Deus fiat lux et facta est lux et vidit Deus lucem quod esset bona et divisit lucem ac...</P> <!--###content_column### end --></TD> </tr> </TABLE> *Finally the action-attribute of the <FORM>-tags are just like the src-attribute of image tags analysed for relative paths. In this case the template file might simply refer to the CORRECT search page in Typo3 from it's position in fileadmin/html/. Thus in the original file “../../index.php?....” would be the correct, working path to any Typo3 page, but when parsed, this path would be prefixed as usual with “fileadmin/html/” so that it works from the site-root out-of-the box.* :: <FORM action="fileadmin/html/../../index.php?id=search_result_page"> <input type="text" name="search_word"> <input type="submit" value="Search now!"> </form> <!--###DOCUMENT_BODY### end --></BODY> </html> .. _Using-this-to-build-a-site: Using this to build a site: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ This TypoScript configuration of a page object will *in addition* to the plugin configuration listed above make use of some of the subpart markers in the output of the plugin. *(My comments in red, italics)* :: # Default PAGE object: page = PAGE page.typeNum = 0 *This retrieves the <BODY>-tag from the template:* :: # Getting body tag from template page.bodyTagCObject =< plugin.tx_automaketemplate_pi1 page.bodyTagCObject.getBodyTag=1 *Inserting the <HEAD> section (###DOCUMENT\_HEAD### subpart) from the template (without <TITLE>-tag...). Thus all header information in the template file is preserved, including any stylesheet.* :: # Getting header data from template, but excluding title-tag (see object configuration) page.headerData.10 = TEMPLATE page.headerData.10.template =< plugin.tx_automaketemplate_pi1 page.headerData.10.workOnSubpart = DOCUMENT_HEADER *Finally the page content is fetched from the template (###DOCUMENT\_BODY### subpart)* :: # Page content: page.20 = TEMPLATE page.20.template =< plugin.tx_automaketemplate_pi1 page.20.workOnSubpart = DOCUMENT_BODY page.20.subparts { *Here the content of the subpart markers <!-- ###sitepath### --> is substituted with a menu showing the “path” to the current page.* *Originally it looked like this:You are here: <span class="sitepath">First level > Second level > Third level</span><br>After the parsing of this plugin, it would look like this (markers added):You are here: <span class="sitepath"><!--###sitepath### begin -->First level > Second level > Third level<!--###sitepath### end --></SPAN>Now it looks like this (for the rootpage) (subpart section substituted with menu):You are here: <span class="sitepath"><A HREF="index.php?id=1130" onFocus="blurLink(this);">Auto Template </A></SPAN><br>* :: sitepath = HMENU sitepath.special = rootline sitepath.1 = TMENU sitepath.1.NO.linkWrap = | >  |*||*| | *Here the dummy-content of the table cell with class “content\_column” is substituted with the true content of the page:* :: content_column < styles.content.get } 9 .. ######CUTTER_MARK_IMAGES###### .. |img-1| image:: img-1.png .. :align: left .. |img-2| image:: img-2.png .. :border: 0 .. :height: 21 .. :hspace: 9 .. :id: Grafik2 .. :name: Grafik2 .. :width: 87