Displaying news on pages

<< Click to Display Table of Contents >>

Navigation:  Work With The Engine >

Displaying news on pages

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 id="1,2,5-8" category="2,3,5-8" author="x" days="x" template="custom" available="global" navigation="no" from="0" limit="10" fixed="yes" order="date" sort="desc" cache="yes"}

 

Where:

 

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.

 

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.

 

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.

 

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.

 

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.

 

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.

 

[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.

 

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" 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.

 

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.

 

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.

 

{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.

 

{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