<< Click to Display Table of Contents >> Navigation: Work With The Engine > Global templates tags |
The basic layout of your page is in the template file named main.tpl. This file is first of all loaded by DLE script and all the other engine components are connected to it. Let us consider the main ones: {AJAX}, {info}, {content}, {custom}. These tags are responsible for the correct display of news.
{AJAX} tag displays JavaScript service tags that are necessary for a normal operation of the engine as a whole and AJAX technology in particular. It is recommended to place it at the beginning of the template after the <body> tag.
{info} tag displays service information about errors and performed actions (e.g. "Login failed, incorrect password" or "You must fill in all fields"). It is recommended to place it before the {content} tag.
{content} tag is responsible for the direct article and other engine modules displaying.
{tags} tag is responsible for the display of tag clouds (special keywords specified in the articles)
[sort]{sort}[/sort] tags are responsible for the display of news sort order selection for user if it is allowed in script settings
{custom} tag is responsible for the display of the article in a custom format. It has the following parameters:
{custom name="X" id="1,2,5-8" category="2,3,5-8" subcat="yes" author="x" days="x" template="custom" available="global" navigation="no" from="0" limit="10" fixed="yes" order="date" sort="desc" cache="yes"}
Where:
name this is the name of the block, which can later be used to determine whether to show or hide any content outside of this block if there is content in this block or it is missing. For example, writing {custom name="block1" category="6"} it will show publications from the category ID6, and the block itself will be named “block1”. New global tags have been added to operate with this name: [custom=X] Text [/custom] where X is the name of the block, which outputs the text enclosed in them if the block with the given name contains information. And also the opposite tags have been added [not-custom=X] Text [/not-custom] which display the text enclosed in them if the block with the given name does not contain any information and there are no publications.Thus, you can make additional external design of the blocks or, conversely, hide it, depending on whether there are publications in the block or not. For example, [custom=block1] Header {custom name="block1" category="6"} [/custom]. At the same time, the block may be placed anywhere on the page, not necessarily within these tags. Therefore, you can adjust and change other elements in the template based on these tags.
id - is the list of article IDs which you want to display, separated by a comma with no spaces. You can also specify the range of article IDs using the dash. For example, 1,4-8,11 displays the article with ID 1, articles with IDs from 4 to 8, and article with ID 11.
idexclude - is completely opposite of the parameter id="article IDs list" and allows you to display news that does not belong to the specified article IDs. For example, {custom idexclude="5-10"} will display all the news that do not belong to the range of IDs between 5 and 10.
category is the list of category IDs which you want to display, separated by a comma with no spaces. You can also specify the range of category IDs using the dash. For example, 1,4-8,11 displays the category with ID 1, categories with IDs from 4 to 8, and category with ID 11.
categoryexclude - is completely opposite of the parameter category="category list" and allows you to display news that does not belong to the specified categories. For example, {custom categoryexclude="2,7"} will display all the news that do not belong to the category IDs 2 and 7.
subcat indicates if posts from subcategories should also be included. The parameter can take one of the following values: subcat="yes" indicates that all posts from the category and its subcategories will be selected, subcat="only" indicates that only posts from subcategories will be selected and posts from the category won't. For example, site has only categories with ID 1, 2 and 3. 1 is a category, 2 and 3 are its subcategories. If {custom category="1" subcat="yes"} tag is used then all posts from categories 1, 2 and 3 will be selected.
tags - is the list of keywords from the tag cloud that is assigned to the news. For example, the tag {custom tags="news,templates"} displays all the stories that contain keywords from the tag cloud "news" and "templates".
template - is a template file that will be used to display news. In this case it will be custom.tpl. If you use multiple templates on the website then this file must be in each template. This template uses tags similar to the article annotation template.
available - is a section where requested news will be displayed. It can take the following values:
global - in all sections
main - on Homepage
date - when viewing news of a specific period
cat - when viewing category
showfull - when viewing the full article
search - when viewing search results
userinfo - when viewing user profile
register - when register
stats - when viewing statistics
pm - when viewing personal messages
feedback - when viewing feedback
favorites - when viewing favorites
newposts - when viewing new posts
addnews - when you add news
lastnews - when watching the latest news on the website
lastcomments - when viewing the latest comments
lostpassword - when recovering password from the account on the website
static - when viewing static pages
catalog - when viewing the page catalog
alltags - when viewing the tag cloud
tags - when viewing the news from the tag cloud
allnews - when viewing all the news on the website or all the news of any user
You can combine sections using "|" section, for example, available="userinfo|register|main" will display your news on the Homepage, at registration and when viewing user profile.
from - the article number you want to start with.
limit - number of news displayed
order - criterion of news sort. It can have the following values:
date - sort news by date
editdate - sort by date edit
rating - sort news by rating
reads - sort news by views
comments - sort news by number of comments
title - sort news by article titles
rand - random sort order for news
id_as_list - sorts the publications as they appear in the ID list. For example, the tag {custom id = "3,4,1,2" order = "id_as_list"} will display articles first with ID 3, then 4, then 1, and 2.
lastviewed - display user's last viewed posts
sort - specifies the publications sort order. Use desc to sort publications in descending order, and asc to sort publications in ascending order.
author - article author's login. News of the specified author only will be displayed if you use this parameter. Authors’ usernames can be listed, separated by comma. For example, {custom author="admin" limit="5"} tag will display 5 articles of the author with "admin" login.
authorexclude it allows to display publications of all the articles, except for the specified author's. Authors’ usernames can be listed, separated by comma. For example, {custom authorexclude="admin,test"} displays the articles of all the authors, except for the authors with usernames "admin" and "test".
catalog it allows to display publications, which contain the symbol code specified in the parameter. Symbol codes can be listed in the parameter, separated by comma. For example, {custom catalog="a,b"} displays the articles, which contain symbol codes "a" and "b".
catalogexclude it allows to display publications, which do not contain specified symbol code, where X is the symbol code assigned to articles. Symbol codes can be listed in the parameter, separated by comma. For example, {custom catalogexclude="a,b"} displays the articles, which do not contain symbol codes "a" and "b".
xfields it allows to display publications, which contain the value of extra fields of the articles specified in the parameter. Parameters can also be separated by comma. For example, {custom xfields="value 1, value 2"} displays the articles, which have extra fields which contain "value 1" and "value 2".
xfieldsexclude it allows to display publications, which do not contain the value of extra fields of the articles specified in the parameter. Parameters can also be separated by comma. For example, {custom xfieldsexclude=" value 1, value 2"} displays the articles, which do not have extra fields which contain "value 1" and "value 2".
days - is the time period, where x is the number of days, the news of which should be displayed. For example, {custom days="2" limit="5"} displays 5 news of the last 2 days.
banners enables or disables the output of advertising materials that are assigned for output between publications. This parameter can take two values: "yes "to enable output, and" no " to disable output. By default, if this parameter is not included in tags, the display of advertising materials between publications will be disabled. For example, the tag {custom banners="yes" limit="5"} enable the output of advertising materials between publications, according to the settings of these advertising materials
futureannounce takes values yes or no. This parameter works in conjunction with the days="X" parameter, and specifies that articles from future dates should be taken. For example, {custom futureannounce="yes" days="1"} tag means that it is necessary to display articles whose publication date is set to tomorrow (+1 days). {custom futureannounce="yes" days="2"} tag displays articles whose publication date is set for tomorrow and the day after tomorrow, etc. This parameter may be useful for those who want to show upcoming announcements on a website.
cache - takes values yes or no - to set whether to cache displayed data or not. It is recommended to cache it to reduce the load. You can specify the period in minutes, hours, or days. Values with the suffixes “m”, “h” and “d” are used to specify the caching time. For example, if you specify {custom cache="30m"....}, the block will be forcibly cached for 30 minutes if you specify {custom cache="2h"....}, then the block will be cached for 2 hours, if you specify {custom cache="1d" ....} then the block will be cached for one day.
navigation - takes values yes or no - to set whether to use page navigation or not. Navigation is displayed only for pages that support navigation for the {content} tag. For example, the Homepage, category pages, etc. If the page does not support navigation, such as full article or a static page, then navigation will be automatically disabled for this tag regardless of the value specified.
fixed - takes values yes, no, only or without. It is used to choose should the fact that news were fixed be taken into account during the publication or not. If yes is specified, then fixed news will be displayed in the beginning, if no is specified, then fixed news will be displayed in the list of news without taking this option into account. In case if only is specified, then only the fixed news will be displayed. If without is specified, then fixed news will not be displayed at all.
sortbyuser="yes" If this parameter is enabled, website visitors will be able to set a convenient way of sorting news for this section at their discretion [sort]{sort}[/sort]
favorites="yes" takes only one value, and displays the publications that the visitor has in his bookmarks. For example, the {custom favorites="yes" order="id_as_list”} tag will display publications from the user's bookmarks in the sort order in which they were bookmarked.
Attenion! All parameters of this tag are optional. Only one parameter is required. All other parameters, if they are not specified, will be taken from the general settings of the script. For example:
{custom id="1,2" order="date"} - displays news with IDs from 1 to 2 и and sort them by date.
{custom category="2,7" from="5" cache="yes"} - displays news from categories 2 and 7, and amount of news will be taken from the script settings. News will be displayed starting with the article with ID 5.
{custom order="date" from="9" limit="5"} - displays the last 5 news, starting with the tenth article.
Remember! Each use of the tag creates an additional load on the database, as there is an additional selection. So use it wisely if you want to save resources.
[available=section] text [/available] tag displays the text enclosed in the tag if the specified section of the website is viewed:
This tag takes parameters same as available parameter of {custom} tag. You can combine sections using "|" symbol, e.g. userinfo|register|main
For example:
[available=userinfo|register|main] text [/available]
will display the text enclosed in tags on Homepage, when registering and viewing user profile.
Note, you can also specify [not-available=userinfo|register|main] text [/not-available] tag which is completely opposite to the available tag and displays text everywhere except the specified sections.
[category=X]text[/category] tag displays the text enclosed in tags if the specified category is viewed:
This tag takes category ID as a parameter, and allows to specify several categories.
[category=1,2,3,7-10] text [/category]
will display the text enclosed in tags if a visitor views the category with ID 1 or 2 or 3, and from 7 to 10.
Note, you can also specify [not-category=1,2,3,7-10] text [/not-category] tag which is completely opposite to the category tag and displays text everywhere except the specified categories.
[group=X]text[/group] tag displays the text enclosed in the tags if the user belongs to specified user group:
This tag takes group ID as a parameter, and allows to specify several groups.
[group=1,2,3] text [/group]
will display the text enclosed in tags if the user is Administrator, chief editor or journalist.
Note, you can also specify [not-group=1,2,3] text [/not-group] tag which is completely opposite to the group tag and displays text everywhere except the specified groups.
[country=X] text [/country]
display the text specified in them if the visitor is in the specified X countries, where X is a list of ISO country codes. Countries can be separated by commas. For example, tags [country=RU, BY, KZ] text [/country] the text will be displayed if the visitor is from Russia, Belarus or Kazakhstan.
[not-country=X] text [/not-country]
display the text specified in them if the visitor is not in the specified X countries, where X is a list of ISO country codes.
{country}
outputs the ISO code of the country in which the site visitor is located, for example, outputs RU if the visitor is in Russia, or US if the visitor is in the USA.
[page-count=1,2,3] text [/page-count]
Will display the text enclosed in them if the user is at a certain news navigation page, regardless of the section of the website, where 1,2,3 are numbers of navigation pages. This tag allows you to adjust the display of the information on a certain page and is useful for information blocks and advertising. You can use this tag in conjunction with other ones that determine sections of the website and the categories.
For example, [aviable=cat][category=1][page-count=1] text [/page-count][/category][/aviable] tags combination displays text only if the user is viewing the first page of news of the category with ID 1, and those are article annotations. And user won't see this text when he will go to another page.
[not-page-count=1,2,3] text [/not-page-count]
Displays the text published in the tags on any pages except those which are specified in the tags.
{banner_name} this tag is designed to display advertising information on the website. The name for the banner is set in a special module in the Administration Panel.
[banner_name] text [/banner_name] displays the text enclosed in them if the specified banner is displayed on the page.
{inform_name} is designed to display RSS informers and news from other websites. Name and all the settings for the tag are set in the Administration Panel.
[static=имя страницы] text [/static]
will display the text enclosed in tags if a visitor views a static page with the specified name. It is allowed to specify pages in the tag separated by comma. For example, [static=test1,test2,test3] text [/static] display enclosed text on pages: test1, test2 and test3
[not-static=page name] text [/not-static]
will display the text enclosed in tags if the visitor does not view static page with the specified name. Pages may be specified in the tag separated by comma.
[smartphone] text [/smartphone]
will display the text enclosed in tags if a visitor is browsing your site with a smartphone.
[not-smartphone] text [/not-smartphone]
will display the text enclosed in tags if a visitor is browsing your site not with a smartphone.
[tablet] text [/tablet]
will display the text enclosed in tags if a visitor is browsing your site with a tablet.
[not-tablet] text [/not-tablet]
will display the text enclosed in tags if a visitor is browsing your site not with a tablet.
[desktop] text [/desktop]
will display the text enclosed in tags if a visitor is browsing your site with a desktop computer or laptop.
[not-desktop] text [/not-desktop]
will display the text enclosed in tags if a visitor is browsing your site not with a desktop computer or laptop.
[ios] text [/ios]
will display the text inside the tags if the user’s device operates on the iOS system by Apple
[not-ios] text [/not-ios]
will display the text inside the tags if the website user’s device doesn’t operate on the iOS system
[android] text [/android]
will display the text inside the tags if the user’s device operates on the Android system by Google
[not-android] text [/not-android]
will display the text inside the tags if the website user’s device doesn’t operate on the Android system
You can also include one template into another using {include file="my_block.tpl"} tag. This tag includes specified my_block.tpl file into the template. The tag is designed to simplify the structure template when a complex layout with multiple tags is used.
{customcomments id="1,2,5-8" newsid="1,2,5-8" category="2,3,5-8" author="x" days="x" template="custom" available="global" from="0" limit="10" order="date" sort="desc" cache="yes"}
which allows to display comments in a customized form in any place of the website. This tag is used for the additional display of comments and can be used, for example, to display last comments on the main page of your website, etc.
This tag can take the following parameters:
id – the list of comment IDs which you want to display, separated by commas without spaces. You can also specify the range of comment IDs using dashes. For example, 1,4-8,11 displays a comment with ID 1, comments with IDs from 4 to 8, and a comment with ID 11.
newsid – the list of publication IDs which you want to display, separated by commas without spaces. You can also specify the range of publication IDs using dashes. For example, 1,4-8,11 displays a comment from publication with ID 1, comments from publication with IDs from 4 to 8, and a comment from publication with ID 11.
newsidexclude - the list of publication IDs that you don't want to display, separated by commas without spaces. You can also specify the range of publication IDs using dashes. For example, 1,4-8,11 don't displays a comment from publication with ID 1, comments from publication with IDs from 4 to 8, and a comment from publication with ID 11.
category – a list of article category IDs where you want to choose comments from, separated by commas without spaces. You can also specify the range of categories using dashes. For example, 1,4-8,11 displays comments from category with ID 1, from IDs from 4 to 8, and from ID 11.
categoryexclude – is completely opposite of the parameter category="list of categories" and allows to display comments to articles which do not belong to categories specified as the parameter value. For example, {customcomments categoryexclude="2,7"} displays all the comments to articles which do not belong to categories with IDs 2 and 7.
author – displays the username of a comment author. When using this parameter, the specified author’s comments will be displayed. You can enumerate several authors separating by commas. For example, {customcomments author="admin" limit="5"} tag displays 5 comments of the author with "admin" username.
authorexclude – authors’ usernames whose comments should not be displayed. Authors’ logins can be separated by commas. For example, {customcomments authorexclude="admin,test"} tags display comments of all authors except "admin" and "test" users.
days – the time period in days, where x is a number of days for which the comments should be displayed. For example, {customcomments days="2" limit="5"} tag displays 5 comments for the last 2 days.
template – a template file that will be used for displaying comments. In this case it will be custom.tpl . If you use several templates on the website, then this file must be present in each template. This template uses tags similar to those tags which you use in the comments display template (comments.tpl).
available - is a section where requested comments will be displayed. It can take the following values:
global - in all sections
main - on Homepage
date - when viewing news of a specific period
cat - when viewing category
showfull - when viewing the full article
search - when viewing search results
userinfo - when viewing user profile
register - when register
stats - when viewing statistics
pm - when viewing personal messages
feedback - when viewing feedback
favorites - when viewing favorites
newposts - when viewing new posts
addnews - when you add news
lastnews - when watching the latest news on the website
lastcomments - when viewing the latest comments
lostpassword - when recovering password from the account on the website
static - when viewing static pages
catalog - when viewing the page catalog
alltags - when viewing the tag cloud
tags - when viewing the news from the tag cloud
allnews - when viewing all the news on the website or all the news of any user
You can combine sections using "|" section, for example, available="userinfo|register|main" will display your news on the Homepage, at registration and when viewing user profile.
from – indicates the number of a comment, from which the output begins. Comments numbering starts with zero. For example, if you want to skip the first comment that matches your conditions, you need to specify from = "1"
limit – the number of displayed comments.
order – comments sorting criteria. It can take the following values:
date – sorting comments by date. For example, {customcomments order="date" limit="5"} tag displays five latest comments.
rating – sorting comments by rating. For example, {customcomments order="rating" limit="5"} tag displays five highest-rated comments.
rand – sorting comments in a random order. For example, {customcomments order="rand" limit="5"} tag displays five comments in a random order.
id_as_list - sorts the publications as they appear in the ID list. For example, the tag {customcomments id = "3,4,1,2" order = "id_as_list"} will display comments first with ID 3, then 4, then 1, and 2.
sort - indicates the sort order of comments. If the value is desc, then articles are sorted in descending order, and when it is asc, articles are sorted in ascending order.
cache - takes values yes or no and specifies whether to cache the displayed information or not. We recommend to cache the displayed blocks to reduce the server load. You can specify the period in minutes, hours, or days. Values with the suffixes “m”, “h” and “d” are used to specify the caching time. For example, if you specify {customcomments cache="30m"....}, the comment block will be forcibly cached for 30 minutes if you specify {customcomments cache="2h" ....}, then the block with comments will be cached for 2 hours, if you specify {customcomments cache="1d" ....} then the block with comments will be cached for one day.
All the parameters of this tag are optional. It is enough to specify just one parameter. You can also combine various parameters of this tag at your discretion.
{* Commented-out code *}
This tag is used to comment-out the code. Everything between "{*" and "*}" is removed from a template and will not be displayed on the website. These tags will be useful for template developers to debug various parts of the code by allowing to temporarily comment-out these parts. This tag is global and may be used in different templates.
{lang text="LANG_PARAMETER"}
This tag is designed to output information from the website.tpl language file, which is currently in use, where LANG_PARAMETER is the value of the parameter to be output. For example, the tag {lang text="attach_images"} will display the inscription “Attach images” from the language pack
{catmenu}
You can make and display category menu in templates. {catmenu} tag is used to display category menu. This tag can be used in any template file, it is global. It uses and embeds categorymenu.tpl template file.
{catmenu id="1,2,3-5" subcat="yes" template="custom" cache="yes"}
Displays a menu of categories in a custom format, where:
id="1,2,3-5" – is a list of ID categories that you want to display in the menu. You can list several categories separated by commas, or specify a range of IDs with a dash.
subcat="yes" - This parameter takes "yes", "no" or "only" value and is used in conjunction with "id" parameter of the tag. It defines for a specified list of categories whether it is needed to connect subcategories automatically. For example, if there is a category with ID 1 and it has subcategories ID 2 and ID 3, then the category 1 and its subcategories 2 and 3 are displayed by {catmenu id="1" subcat="yes"} tag. And just category 1 is displayed if {catmenu id="1" subcat="no"} tag is used. A value of "only" means that only the subcategories of the category with ID "1" will be displayed. If you use the {catmenu id = "1" subcat = "only"} tag, only the subcategories of the category with ID "1" will be displayed. For example, you can automatically display a list of subcategories from the viewed category using the simple expression [available = cat] {catmenu id = "{category-id}" subcat = "only"} [/avalilable]
template="custom" – is a template name to be used as a default menu template instead of categorymenu.tpl
cache="yes" – This parameter takes "yes" or "no" value and indicates whether it is needed to cache a given block or not. When caching is active, the ability to control the emphasizing of the currently viewed category using [active] text [/ active] tags in the template is unavailable automatically.
{catnewscount id="X"}
It displays the number of articles within a certain category, where X stands for ID of a needed category. This tag is useful to display the number of categories in manually created menu templates.
{category-id}
Display the ID of the category viewed by the visitor. This tag will be useful when organizing the menu on the site and when you need to quickly reassign any CSS classes or the names of template files, when you edit articles display templates.
{category-title}
Display the name of the category viewed by the visitor. This tag will be useful when you need to display the name of the category you are viewing.
{category-description}
Display the category description on the site when the user views the category. It is also available when displaying full descriptions.
[category-description] текст [/category-description]
Display the text enclosed in them if the category being viewed has a given category description
[not-category-description] текст [/not-category-description]
Display the text enclosed in them if the category does not have a description.
{category-icon}
Display the icon of the category viewed by the user, or news category if the full text is viewed
{category-url}
Display the URL of the viewed category
{page-title}
Display specified in the section "Titles, descriptions, meta tags" title for the page
{page-description}
Displays specified in the section "Titles, descriptions, meta tags" description for the page
{page-count}
Displays the number of the page the user is view
[script] код [/script] Global tags which you can place use executable jаvascript code. In this case, the data code will be placed directly in the executable block of other DataLife Engine JS codes, it will be launched immediately after loading other JS scripts that are used when included. Thus, you can organize all the JS codes in the template, standardize their execution order, and avoid any conflicts in the future.
{cache-id}
Outputs the current cache ID
[active-plugins=X] Text [/active-plugins]
Displays the text enclosed in it if the specified plugin is enabled and used on the site.Where X is the plugin ID or its name. For example, you can specify [active-plugins=1] Text [/active-plugins] or [active-plugins=My plugin] Text [/active-plugins], and if a plugin with ID 1 or with the name “My plugin” is enabled in the system, then the text specified in the tag will be output. You can also list several parameters in the tag separated by commas, for example, [active-plugins=1,2,5] Text [/active-plugins]
[not-active-plugins=X] Text [/not-active-plugins]
Displays the text enclosed in it if the specified plugin is disabled and is not used on the site. Where X is the plugin ID or its name. For example, you can specify [not-active-plugins=1] Text [/not-active-plugins] or [not-active-plugins=My plugin] Text [/not-active-plugins], and if the plugin with ID 1 or with the name “My plugin” is disabled in the system and is not used, then the text specified in the tag will be output. You can also list several parameters in the tag separated by commas, for example, [not-active-plugins=1,2,5] Text [/not-active-plugins].
User Profile:
{profile-link} - Displays link to user's profile
{profile-login} - Displays username
{ip} - Displays user's IP
{foto} - Displays link to user's avatar
{fullname} - Displays user's full name
[fullname] text [/fullname] - Displays text included in tags in case user's full name is specified in user's profile
{land} - Displays user's country
[land] text [/land] - Displays text included in tags in case country is specified in user's profile
{mail} - Displays user's e-mail
{group} - Displays user's group
{registration} - Displays date of user's signing in
{lastdate} - Displays date of user's last visit
{group-icon} - Displays user's group icon
{time_limit} - Displays the date until which user is in the group, if the group is temporary
[time_limit] text [/time_limit] - Displays text included in tags if user is in temporary group
{comm-num} - Displays number of user's comments
{comments} - Displays link to user's comments
[comm-num] text [/comm-num] - Displays text included in tags if user has comments on the website
[not-comm-num] text [/not-comm-num] - Displays text included in tags if user has no comments on the website
{news} - Displays link to user's news
{rss} - Displays link to RSS of user's news
{news-num} - Displays number of user's news
[news-num] text [/news-num] - Displays text included in tags if user has news on the website
[not-news-num] text [/not-news-num] - Displays text included in tags if user has no news on the website
{new-pm} - Displays number of user's unread private messages
{all-pm} - Displays total number of user's private messages
{favorite-count} - Displays total number of posts in user's favourites
[profile_xfvalue_X] - Displays value of optional field named 'X' from the profile
[profile_xfgiven_X] text [/profile_xfgiven_X] - Displays text included in tags if optional field named 'X' is specified in profile
[profile_xfnotgiven_X] text [/profile_xfnotgiven_X] - Displays text included in tags if optional field named 'X' is not specified in profile
{admin-link} - Displays link to admin panel if user has access to it
[admin-link] text [/admin-link] - Displays text included in tags if user has access to admin panel