├── LICENSE ├── README.md ├── t4Query.js └── t4Query.min.js /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 userexec 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![t4_query](https://cloud.githubusercontent.com/assets/5970137/8856790/a6c554d6-3132-11e5-869b-70784d9b26f7.png) 2 | 3 | 4 | ### TERMINALFOUR JavaScript layout processor superset 5 | 6 | t4Query is a language superset for the [TERMINALFOUR](http://www.terminalfour.com/) JavaScript layout processor intended to simplify the inclusion of data in your content and page layouts. By pasting it into the top of your layout, you unlock easy access to all of your data normally included via t4 tags without needing extensive knowledge of the objects and methods available in the processor. 7 | 8 | Including an image path turns from this: 9 | 10 | ```javascript 11 | importClass(com.terminalfour.publish.utils.BrokerUtils); 12 | BrokerUtils.processT4Tags(dbStatement, publishCache, section, content, language, isPreview, ''); 13 | ``` 14 | 15 | Into this: 16 | 17 | ```javascript 18 | $('Media Field').formatter('path/*') 19 | ``` 20 | 21 | Determining if a checkbox is checked turns from this: 22 | 23 | ```javascript 24 | if (!content.get('Checkbox Field').publish().isEmpty()) ... 25 | ``` 26 | 27 | Into this: 28 | 29 | ```javascript 30 | if ($('Checkbox Field').checked()) ... 31 | ``` 32 | 33 | t4Query focuses on making a human-readable content layout by sharing the vocabulary of the t4 tags you're already used to and providing simple, semantic methods that do what you'd expect. No installation or additional access necessary. 34 | 35 | ## Preparation 36 | 37 | Open a content or page layout (e.g. text/html), switch to the JavaScript layout processor, then paste the contents of either [t4Query.js](https://github.com/userexec/t4Query/blob/master/t4Query.js) or [t4Query.min.js](https://github.com/userexec/t4Query/blob/master/t4Query.min.js) into the top of the input box. Create your content layout below the included code. 38 | 39 | ## Usage 40 | 41 | t4Query uses a "selector-modifiers(s)" pattern for the majority of its use cases. You begin by selecting a field from your content type's element list, then apply any modifiers that would normally be applied in a t4 tag to retrieve the desired output. This pattern will generally appear within a `document.write` statement in order to output content to the page. 42 | 43 | Selector | Modifier | Modifier ... 44 | ------------ | ------------- | ------------- 45 | $('*field name*') | .*t4-tag-attribute*('*value*') | .*t4-tag-attribute*('*value*') ... 46 | 47 | Some exceptions to this pattern exist, such as retrieving section and page metadata or including navigation objects. 48 | 49 | In some uncommon cases in which \[object Object\] is returned, the pattern will require the `insert` method to be chained onto the end to resolve its content (e.g. `$('Field').modifiers('striptags').insert()`). This is generally used when string coercion will not occur automatically (such as when you need to compare against the value of a field in a conditional instead of just printing it in a `document.write` statement). The `valueOf` and `toString` methods of every t4Query object are linked to its insert method, so insertion will occur automatically in most use cases. Read more about how this works at [Medium](https://medium.com/@kevincennis/object-object-things-you-didn-t-know-about-valueof-38f2a88dfb33) for a better understanding of when `insert` may need to be appended. 50 | 51 | - [Inserting Content](#inserting) 52 | - [Selective Output](#selective) 53 | - [Modifiers, Formatters, and Other Attributes](#modifiers) 54 | - [Retrieving Metadata](#metadata) 55 | - [Navigation Objects](#navigation) 56 | - [Checking Page Information](#pageinfo) 57 | - [Using Plain t4 Tags](#tags) 58 | - [document.write Shortcut](#write) 59 | - [Direct Edit Automatic Class Preservation](#directEdit) 60 | 61 | ### Inserting Content 62 | 63 | To insert content into your page, first open a `document.write` and then select the field you wish to include using the selector-modifier(s) syntax. 64 | 65 | ```javascript 66 | document.write('The secret message is: ' + $('Secret Message') + '...'); 67 | ``` 68 | 69 | ### Selective Output 70 | 71 | To check if a field has content, select it and use the `hasContent` method. Combining this with an if statement emulates selective output. 72 | 73 | ```javascript 74 | if ($('Email Address').hasContent()) { 75 | document.write('
  • Email user
  • '); 76 | } 77 | ``` 78 | 79 | This method can be used for checkboxes as well, or you can use the more semantic `checked` method: 80 | 81 | ```javascript 82 | if ($('Hide Buttons').checked()) { 83 | document.write(''); 84 | } 85 | ``` 86 | 87 | ### Modifiers, Formatters, and Other Attributes 88 | 89 | t4Query's selector function is designed to be transformed via chaining methods. Each of the most common attributes you would include on a t4 tag can be applied to your selected field before its insertion, allowing you to transform the data that will be returned. 90 | 91 | Get an image path: 92 | 93 | ```javascript 94 | document.write('Path: ' + $('Media Field').formatter('path/*')); 95 | ``` 96 | 97 | Strip HTML tags and convert special characters: 98 | 99 | ```javascript 100 | document.write('Plain text: ' + $('Mixed Field').modifiers('striptags, htmlentities')); 101 | ``` 102 | 103 | Use a special output format: 104 | 105 | ```javascript 106 | document.write('Image (image output): ' + $('Image Field').output('image')); 107 | ``` 108 | 109 | Any number of the following methods can be chained between the selector and the insertion: 110 | 111 | - `action` 112 | - `after` 113 | - `appendContent` 114 | - `appendElement` 115 | - `before` 116 | - `dateFormat` 117 | - `delimiter` 118 | - `disableDirectEdit` (no argument needed) 119 | - `displayField` 120 | - `element` 121 | - `format` 122 | - `formatModifiers` 123 | - `formatter` 124 | - `id` 125 | - `locale` 126 | - `localeEs` 127 | - `meta` 128 | - `method` 129 | - `modifiers` 130 | - `name` 131 | - `output` 132 | - `outputSheetName` 133 | - `processFormat` 134 | - `text` 135 | - `textualNameSeparator` 136 | - `type` 137 | - `url` 138 | 139 | If you need to specify an uncommon attribute for the content to be included, use the general purpose `attr` method with a key-value pair: 140 | 141 | ```javascript 142 | document.write('Uncommon format: ' + $('Field').attr('uncommon', 'true')); 143 | ``` 144 | 145 | ### Retrieving Metadata 146 | 147 | To retrieve metadata, you'll use a slightly different syntax. Pass the name of any metadata field to the `meta` method without specifying a selector: 148 | 149 | ```javascript 150 | document.write('Last Modified: ' + $.meta('last_modified')); 151 | ``` 152 | 153 | Supported metadata fields: 154 | - content_id 155 | - expiry_date 156 | - html_anchor 157 | - last_modified 158 | - last_modified_by_fullname 159 | - last_modified_by_username 160 | - publish_date 161 | - recently_modified 162 | - version 163 | - filesize (see below) 164 | 165 | The filesize metadata requires a modifier since it needs to know which element to examine. You can use the `attr` method with a key-value pair to specify the element. 166 | 167 | ```javascript 168 | document.write('Last Modified: ' + $.meta('filesize').attr('name', 'Text Field')); 169 | ``` 170 | 171 | 172 | ### Navigation Objects 173 | 174 | Including a navigation object is as simple as finding its ID, then using the following pattern to insert it onto the page: 175 | 176 | ```javascript 177 | document.write('Nav object #104: ' + $.nav(104)); 178 | ``` 179 | 180 | ### Checking Page Information 181 | 182 | Page information is not a primary focus of t4Query, but some page information can assist in layouts. Currently t4Query has the ability to check the section, channel, and microchannel IDs and names, the section's path, and the page layout of the section the content item appears in. These can be *extremely* useful for outputting different HTML structures for different page layouts that must all support the text/html content layout, or for displaying content items differently depending on their channel/microchannel. Note that if the content item is pulled through a navigation tag, it will report information for the page on which it originally resides, not the page it's being pulled onto. 183 | 184 | Supported pageInfo properties: 185 | 186 | - (int) `layout` 187 | - (string) `path` 188 | - (int) `section` 189 | - (string) `sectionName` 190 | - (int) `channel` 191 | - (string) `channelName` 192 | - (int) `microChannel` 193 | - (string) `microChannelName` 194 | 195 | To find the page layout ID, use the following pattern: 196 | 197 | ```javascript 198 | if ($.pageInfo('layout') == 121) { 199 | document.write('This is HTML for layout A'); 200 | } else if ($.pageInfo('layout') == 125) { 201 | document.write('This is HTML for layout B'); 202 | } else { 203 | document.write('This is compatible HTML for old templates'); 204 | } 205 | ``` 206 | 207 | ### Using Plain t4 Tags 208 | 209 | Maybe all of this new-fangled stuff isn't for you. Maybe you just want the comfort of pasting in a t4 tag from the tag builder. That's okay--there's something for you here, too: 210 | 211 | ```javascript 212 | document.write('Plain text: ' + $.t4('')); 213 | ``` 214 | 215 | ### document.write Shortcut 216 | 217 | In the spirit of speed, t4Query provides a shortcut to `document.write` that will automatically insert a new line after each call. It will also take an argument for how many tabs you would like inserted before that line. While unnecessary, this can help to keep the source code clean so that "view source" isn't always immediately followed by a trip to the prettifier. 218 | 219 | To use the shortcut, call $.w(string, indents) with *indents* as an integer specifying the number of tab characters you would like placed before the line. 220 | 221 | ```javascript 222 | $.w('This is a line with four tabs before it, and a new line after.', 4); 223 | // Outputs: This is a line with four tabs before it... 224 | ``` 225 | 226 | ### Direct Edit Automatic Class Preservation 227 | 228 | Thanks to the lovely line 3942 of t4dedit.js in Site Manager 7, elements in content type layouts that contain a class but no ID automatically have their classes stripped off for seemingly no reason. Since t4Query assumes you don't have access to modify the core files, it instead adds a randomized ID to all output elements with classes but no ID when you use the `$.w('')` document.write shortcut. This means you no longer have to remember to place your own throwaway ID onto every element that requires classes, meaning quicker markup with better readability. 229 | 230 | This feature can be easily toggled off (or back on) with `$.toggleDirectEditPreserve()`. 231 | 232 | ---------------------- 233 | 234 | 235 | Logo by [RYJASM](http://ryjasm.com/) 236 | -------------------------------------------------------------------------------- /t4Query.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | ///// t4Query - T4 JavaScript Preprocessor superset /////////////////////////// 3 | ///// v1.2 /////////////////////////// 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | /* global document, content, publishCache, dbStatement, section, language, isPreview, importClass, com, BrokerUtils */ 7 | /* jshint evil: true */ 8 | /* jshint strict: false */ 9 | 10 | if (typeof $ == 'undefined') { 11 | // Import Broker Utilities 12 | importClass(com.terminalfour.publish.utils.BrokerUtils); 13 | 14 | // Define the common content selector function 15 | var $ = function(field) { 16 | var t4Obj; 17 | if (content.get(field).publish() !== null) { 18 | t4Obj = $.createObject({ 19 | name: field, 20 | type: 'content', 21 | output: 'normal' 22 | }); 23 | 24 | if (content.get(field).publish().isEmpty()) { 25 | t4Obj.empty = true; 26 | t4Obj.toString = function() { return ''; }; 27 | t4Obj.valueOf = function() { return ''; }; 28 | } 29 | 30 | return t4Obj; 31 | } else { 32 | // Element is null. Create a dummy t4 object for a silent fail of chained actions. 33 | t4Obj = $.createObject({ 34 | name: field, 35 | type: 'content', 36 | output: 'normal' 37 | }); 38 | 39 | // Include a flag so that insert() can avoid sending this object to the broker utils 40 | t4Obj.fail = true; 41 | 42 | // Tag this object as empty 43 | t4Obj.empty = true; 44 | t4Obj.toString = function() { return ''; }; 45 | t4Obj.valueOf = function() { return ''; }; 46 | 47 | return t4Obj; 48 | } 49 | }; 50 | 51 | // Provide a random number utility 52 | $.random = function() { 53 | return Math.floor(Math.random() * 10000000); 54 | }; 55 | 56 | // Provide a toggle for Direct Edit class preservation 57 | // I'm eyeing you, line 3942 of t4dedit.js, you evil thing. 58 | $.directEditPreserve = true; 59 | $.toggleDirectEditPreserve = function() { 60 | if ($.directEditPreserve) { 61 | $.directEditPreserve = false; 62 | } else { 63 | $.directEditPreserve = true; 64 | } 65 | }; 66 | 67 | // Provide a shortcut with newline to document.write 68 | $.w = function(str, indent) { 69 | // Indent the line so that "view source" is clean 70 | var tabs = ''; 71 | if (typeof indent == 'number') { 72 | for (var i = 0; i < Math.floor(indent); i++) { 73 | tabs += '\t'; 74 | } 75 | } 76 | 77 | // If class preservation is requested, insert a unique ID into all HTML tags with classes but no ID 78 | if ($.directEditPreserve && typeof str === 'string') { 79 | str = str.replace(/(<[a-zA-Z1-6]*)((?=[^>]*class=(['"]).*?['"])(?![^>]*id=['"].*?['"]).*?>)/g, '$1 id=$3' + $.meta('content_id') + '_' + $.random() + '$3$2'); 80 | } 81 | 82 | // Write the line 83 | document.write(tabs + str + '\n'); 84 | }; 85 | 86 | // Provide mechanism for processing T4 tags 87 | $.t4 = function(tag) { 88 | return BrokerUtils.processT4Tags(dbStatement, publishCache, section, content, language, isPreview, tag); 89 | }; 90 | 91 | // Provide helper mechanism for creating generic t4Query objects 92 | $.createObject = function(keyValuePairs) { 93 | // Create a new t4Query object 94 | var element = new $.Functions(); 95 | 96 | // Load the tag object with the requested key-value pairs 97 | element.tag = {}; 98 | for (var key in keyValuePairs) { 99 | element.tag[key] = keyValuePairs[key]; 100 | } 101 | element.empty = false; 102 | element.fail = false; 103 | 104 | return element; 105 | }; 106 | 107 | // Provide mechanism for outputting metadata 108 | $.meta = function(prop) { 109 | return $.createObject({ 110 | meta: prop, 111 | type: 'meta' 112 | }); 113 | }; 114 | 115 | // Provide mechanism for outputting navigation 116 | $.nav = function(id) { 117 | return $.createObject({ 118 | id: id + '', 119 | type: 'navigation' 120 | }); 121 | }; 122 | 123 | // Provide mechanism for outputting page info 124 | $.pageInfo = function(prop) { 125 | if (typeof $.pageInfo[prop] == 'function') { 126 | return $.pageInfo[prop](); 127 | } 128 | }; 129 | 130 | $.pageInfo.section = function() { 131 | return parseInt(section.getID()); 132 | }; 133 | 134 | $.pageInfo.sectionName = function() { 135 | var thisSection = com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(), section, section.getID(), language); 136 | return "" + thisSection.getName(language); 137 | }; 138 | 139 | $.pageInfo.channel = function() { 140 | var channel = publishCache.getChannel(); 141 | return parseInt(channel.getID()); 142 | }; 143 | 144 | $.pageInfo.channelName = function() { 145 | var channel = publishCache.getChannel(); 146 | return "" + channel.getName(); 147 | }; 148 | 149 | $.pageInfo.microChannel = function() { 150 | var sectionID = section.getID(); 151 | var thisSection = com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(), section, sectionID, language); 152 | var microChannel = publishCache.getMicroSiteFromChild(thisSection); 153 | if (!microChannel) { return false; } 154 | return parseInt(microChannel.getID()); 155 | }; 156 | 157 | $.pageInfo.microChannelName = function() { 158 | var sectionID = section.getID(); 159 | var thisSection = com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(), section, sectionID, language); 160 | var microChannel = publishCache.getMicroSiteFromChild(thisSection); 161 | if (!microChannel) { return false; } 162 | return "" + microChannel.getName(); 163 | }; 164 | 165 | $.pageInfo.layout = function() { 166 | var channel = publishCache.getChannel(); 167 | // Return the style of the section (channel object required for lookup) 168 | return section.getStyle(channel); 169 | }; 170 | 171 | $.pageInfo.path = function() { 172 | var thisSection = com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(), section, section.getID(), language); 173 | var linkObject = com.terminalfour.publish.PathBuilder.getLink(dbStatement, section, thisSection, publishCache, language, false); 174 | return "" + linkObject.getLink(); 175 | }; 176 | 177 | // Define standard library of tag-forming functions 178 | $.Functions = function() { 179 | this.valueOf = function() { 180 | return this.insert(); 181 | }; 182 | this.toString = function() { 183 | return this.insert(); 184 | }; 185 | }; 186 | 187 | // Static prototypal methods for t4Query objects 188 | $.Functions.prototype.action = function(str) { 189 | return this.attr('action', str); 190 | }; 191 | $.Functions.prototype.after = function(str) { 192 | return this.attr('after', str); 193 | }; 194 | $.Functions.prototype.appendContent = function(str) { 195 | return this.attr('append-content', str); 196 | }; 197 | $.Functions.prototype.appendElement = function(str) { 198 | return this.attr('append-element', str); 199 | }; 200 | $.Functions.prototype.attr = function (attribute, str) { 201 | // Ensure that only strings are added to tag attributes 202 | if (typeof str == 'string') { 203 | // Store the new attribute and value in the tag object 204 | this.tag[attribute] = str; 205 | return this; 206 | } else { 207 | // Flag this t4Query object so that it does not pass through broker utils 208 | this.fail = true; 209 | 210 | // Log a warning in the page output 211 | document.write('
    t4Query warning: Passed attribute ' + str + ' should be a string.
    '); 212 | return false; 213 | } 214 | }; 215 | $.Functions.prototype.before = function(str) { 216 | return this.attr('before', str); 217 | }; 218 | $.Functions.prototype.checked = function() { 219 | return !this.empty; 220 | }; 221 | $.Functions.prototype.dateFormat = function(str) { 222 | return this.attr('date_format', str); 223 | }; 224 | $.Functions.prototype.delimiter = function(str) { 225 | return this.attr('delimiter', str); 226 | }; 227 | $.Functions.prototype.disableDirectEdit = function() { 228 | return this.attr('enable-dedit', 'false'); 229 | }; 230 | $.Functions.prototype.displayField = function(str) { 231 | return this.attr('display_field', str); 232 | }; 233 | $.Functions.prototype.element = function(str) { 234 | return this.attr('element', str); 235 | }; 236 | $.Functions.prototype.format = function(str) { 237 | return this.attr('format', str); 238 | }; 239 | $.Functions.prototype.formatter = function(str) { 240 | return this.attr('formatter', str); 241 | }; 242 | $.Functions.prototype.formatModifiers = function(str) { 243 | return this.attr('format-modifiers', str); 244 | }; 245 | $.Functions.prototype.hasContent = function() { 246 | return this.checked(); 247 | }; 248 | $.Functions.prototype.id = function(str) { 249 | return this.attr('id', str); 250 | }; 251 | $.Functions.prototype.insert = function() { 252 | if (!this.fail) { 253 | // Build a t4 tag from the tag object 254 | // Opening bracket is omitted to prevent preemptive processing of tags not requiring broker utils 255 | var tag = 't4 '; 256 | for (var key in this.tag) { 257 | tag += key + '="' + this.tag[key] + '" '; 258 | } 259 | tag += '/>'; 260 | 261 | // Use Broker Utils to parse the t4 tag and insert onto the page 262 | // Add opening bracket as tag is passed to broker utils to prevent preemptive processing 263 | return '' + $.t4('<' + tag); 264 | } else { 265 | // Flagged object detected--fail silently 266 | return false; 267 | } 268 | }; 269 | $.Functions.prototype.locale = function(str) { 270 | return this.attr('locale', str); 271 | }; 272 | $.Functions.prototype.localeEs = function(str) { 273 | return this.attr('locale_es', str); 274 | }; 275 | $.Functions.prototype.meta = function(str) { 276 | return this.attr('meta', str); 277 | }; 278 | $.Functions.prototype.method = function(str) { 279 | return this.attr('method', str); 280 | }; 281 | $.Functions.prototype.modifiers = function(str) { 282 | /* medialibrary, nav_sections, striptags, htmlentities, nl2br, js-var, rssentities, encode_emails */ 283 | return this.attr('modifiers', str); 284 | }; 285 | $.Functions.prototype.name = function(str) { 286 | return this.attr('name', str); 287 | }; 288 | $.Functions.prototype.output = function(str) { 289 | return this.attr('output', str); 290 | }; 291 | $.Functions.prototype.outputSheetName = function(str) { 292 | return this.attr('output-sheet-name', str); 293 | }; 294 | $.Functions.prototype.processFormat = function(str) { 295 | // Force option to string 296 | if (typeof str !== 'string' && str) { 297 | str = 'true'; 298 | } else { 299 | str = 'false'; 300 | } 301 | return this.attr('process-format', str); 302 | }; 303 | $.Functions.prototype.text = function(str) { 304 | return this.attr('text', str); 305 | }; 306 | $.Functions.prototype.textualNameSeparator = function(str) { 307 | return this.attr('textual-name-separator', str); 308 | }; 309 | $.Functions.prototype.type = function(str) { 310 | return this.attr('type', str); 311 | }; 312 | $.Functions.prototype.url = function(str) { 313 | return this.attr('url', str); 314 | }; 315 | } 316 | 317 | /////////////////////////////////////////////////////////////////////////////// 318 | ///// End of t4Query - Create your content layout below /////////////////////// 319 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /t4Query.min.js: -------------------------------------------------------------------------------- 1 | ///// t4Query - T4 JavaScript Preprocessor superset /////////////////////////// 2 | ///// v1.2 /////////////////////////// 3 | if(typeof $=='undefined'){importClass(com.terminalfour.publish.utils.BrokerUtils);var $=function(field){var t4Obj;if(content.get(field).publish()!==null){t4Obj=$.createObject({name:field,type:'content',output:'normal'});if(content.get(field).publish().isEmpty()){t4Obj.empty=true;t4Obj.toString=function(){return ''};t4Obj.valueOf=function(){return ''}}return t4Obj}else{t4Obj=$.createObject({name:field,type:'content',output:'normal'});t4Obj.fail=true;t4Obj.empty=true;t4Obj.toString=function(){return ''};t4Obj.valueOf=function(){return ''};return t4Obj}};$.random=function(){return Math.floor(Math.random()*10000000)};$.directEditPreserve=true;$.toggleDirectEditPreserve=function(){if($.directEditPreserve){$.directEditPreserve=false}else{$.directEditPreserve=true}};$.w=function(str,indent){var tabs='';if(typeof indent=='number'){for(var i=0;i]*class=(['"]).*?['"])(?![^>]*id=['"].*?['"]).*?>)/g,'$1 id=$3'+$.meta('content_id')+'_'+$.random()+'$3$2')}document.write(tabs+str+'\n')};$.t4=function(tag){return BrokerUtils.processT4Tags(dbStatement,publishCache,section,content,language,isPreview,tag)};$.createObject=function(keyValuePairs){var element=new $.Functions();element.tag={};for(var key in keyValuePairs){element.tag[key]=keyValuePairs[key]}element.empty=false;element.fail=false;return element};$.meta=function(prop){return $.createObject({meta:prop,type:'meta'})};$.nav=function(id){return $.createObject({id:id+'',type:'navigation'})};$.pageInfo=function(prop){if(typeof $.pageInfo[prop]=='function'){return $.pageInfo[prop]()}};$.pageInfo.section=function(){return parseInt(section.getID())};$.pageInfo.sectionName=function(){var thisSection=com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(),section,section.getID(),language);return ""+thisSection.getName(language)};$.pageInfo.channel=function(){var channel=publishCache.getChannel();return parseInt(channel.getID())};$.pageInfo.channelName=function(){var channel=publishCache.getChannel();return ""+channel.getName()};$.pageInfo.microChannel=function(){var sectionID=section.getID();var thisSection=com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(),section,sectionID,language);var microChannel=publishCache.getMicroSiteFromChild(thisSection);if(!microChannel){return false}return parseInt(microChannel.getID())};$.pageInfo.microChannelName=function(){var sectionID=section.getID();var thisSection=com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(),section,sectionID,language);var microChannel=publishCache.getMicroSiteFromChild(thisSection);if(!microChannel){return false}return ""+microChannel.getName()};$.pageInfo.layout=function(){var channel=publishCache.getChannel();return section.getStyle(channel)};$.pageInfo.path=function(){var thisSection=com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(),section,section.getID(),language);var linkObject=com.terminalfour.publish.PathBuilder.getLink(dbStatement,section,thisSection,publishCache,language,false);return ""+linkObject.getLink()};$.Functions=function(){this.valueOf=function(){return this.insert()};this.toString=function(){return this.insert()}};$.Functions.prototype.action=function(str){return this.attr('action',str)};$.Functions.prototype.after=function(str){return this.attr('after',str)};$.Functions.prototype.appendContent=function(str){return this.attr('append-content',str)};$.Functions.prototype.appendElement=function(str){return this.attr('append-element',str)};$.Functions.prototype.attr=function(attribute,str){if(typeof str=='string'){this.tag[attribute]=str;return this}else{this.fail=true;document.write('
    t4Query warning: Passed attribute '+str+' should be a string.
    ');return false}};$.Functions.prototype.before=function(str){return this.attr('before',str)};$.Functions.prototype.checked=function(){return!this.empty};$.Functions.prototype.dateFormat=function(str){return this.attr('date_format',str)};$.Functions.prototype.delimiter=function(str){return this.attr('delimiter',str)};$.Functions.prototype.disableDirectEdit=function(){return this.attr('enable-dedit','false')};$.Functions.prototype.displayField=function(str){return this.attr('display_field',str)};$.Functions.prototype.element=function(str){return this.attr('element',str)};$.Functions.prototype.format=function(str){return this.attr('format',str)};$.Functions.prototype.formatter=function(str){return this.attr('formatter',str)};$.Functions.prototype.formatModifiers=function(str){return this.attr('format-modifiers',str)};$.Functions.prototype.hasContent=function(){return this.checked()};$.Functions.prototype.id=function(str){return this.attr('id',str)};$.Functions.prototype.insert=function(){if(!this.fail){var tag='t4 ';for(var key in this.tag){tag+=key+'="'+this.tag[key]+'" '}tag+='/>';return ''+$.t4('<'+tag)}else{return false}};$.Functions.prototype.locale=function(str){return this.attr('locale',str)};$.Functions.prototype.localeEs=function(str){return this.attr('locale_es',str)};$.Functions.prototype.meta=function(str){return this.attr('meta',str)};$.Functions.prototype.method=function(str){return this.attr('method',str)};$.Functions.prototype.modifiers=function(str){return this.attr('modifiers',str)};$.Functions.prototype.name=function(str){return this.attr('name',str)};$.Functions.prototype.output=function(str){return this.attr('output',str)};$.Functions.prototype.outputSheetName=function(str){return this.attr('output-sheet-name',str)};$.Functions.prototype.processFormat=function(str){if(typeof str!=='string'&&str){str='true'}else{str='false'}return this.attr('process-format',str)};$.Functions.prototype.text=function(str){return this.attr('text',str)};$.Functions.prototype.textualNameSeparator=function(str){return this.attr('textual-name-separator',str)};$.Functions.prototype.type=function(str){return this.attr('type',str)};$.Functions.prototype.url=function(str){return this.attr('url',str)}} 4 | ///// End of t4Query - Create your content layout below /////////////////////// --------------------------------------------------------------------------------