A small addition to the template engine for displaying a list of short news.
The essence of the problem:
I ran into a problem here. It was necessary to display news on the site for different categories - different template.
Of course, there is a "Short news template" parameter in the category settings, but that would be fine, but what if the data needs to be output in the form of a list, a tile and a table. Of course, you can use the constructions [category...] and [aviable...] but when there are a lot of categories, it turns out sooo cumbersome and inconvenient. Especially when there are more than 100 categories on the site and new categories need to be added periodically.
Also do not forget about the system wrapper, which is added automatically before output:
<div id="dle-content">{content}</div>
If the content is displayed as a table, you can still adapt
#dle-content{display: table;}
.shortstory{display:table-row;}
But with the list:
<ul><li>...</li></ul>
It certainly won't work out.
I'm not saying that navigation will also need to be adapted to the above tags.
Solution:
The solution turned out to be quite simple, but incredibly convenient and multifunctional!
To design the desired list, only the shortstory.tpl template is used (or which one is selected for the category). No additional tags are needed in main.tpl.
Here is an example of a short news template:
[page-count=1]<h1>Some SEO description for the selected category</h1>[/page-count]
<table>
<thead>
<tr>
<td>Photo</td>
<td>Description</td>
</tr>
</thead>
<tbody>
[list]
<tr>
<td><img src="{image-1}"></td>
<td>
[full-link]{title}[/full-link]
<div>{short-story limit="200"}</div>
</td>
</tr>
</tbody>
</table>
{navigation}
As you can see, the tag has been added:
[list]...
Inside it is exactly the template of the short news, everything else is a direct wrapper. Also pay attention to the navigation tag. You can manually place it anywhere or give it an individual style. If the tag is not specified, it will be displayed at the bottom by default.
Installation:
Open File engine/modules/show.short.php
Find a string (this is a piece of string, for simplicity):
if( strpos( $tpl->copy_template, "[xfvalue_"
Insert BEFORE it:
////////////////////////////////////////////////////////////////////////////////////////////////
if(preg_match( "#\\[list\\](.+?)\\[/list\\]#is", $tpl->copy_template, $list_tpl ) ){
$global_tpl = $tpl->template;
$tpl->template = $tpl->copy_template = $list_tpl[1];
}else $global_tpl = '';
////////////////////////////////////////////////////////////////////////////////////////////////
Find a line:
switch ( $config['news_navigation'] ) {
Insert BEFORE it:
////////////////////////////////////////////////////////////////////////////////////////////////
if( !$global_tpl )
////////////////////////////////////////////////////////////////////////////////////////////////
At the very bottom, find the code:
}
?>
insert BEFORE it:
////////////////////////////////////////////////////////////////////////////////////////////////
if( $global_tpl AND $news_found ){
$tpl->result['content'] = str_replace( $list_tpl[0], $tpl->result['content'], $global_tpl );
if (stripos ( $tpl->result['content'], "[category=" ) !== false) $tpl->result['content'] = preg_replace_callback ( "#\\[(category)=(.+?)\\](.*?)\\[/category\\]#is", "check_category", $tpl->result['content'] );
if (stripos ( $tpl->result['content'], "[not-category=" ) !== false) $tpl->result['content'] = preg_replace_callback ( "#\\[(not-category)=(.+?)\\](.*?)\\[/not-category\\]#is", "check_category", $tpl->result['content'] );
if(stripos($global_tpl,"{navigation}")!==false) $tpl->result['content'] = str_replace( "{navigation}", $tpl->result['navi'], $tpl->result['content'] );
else $tpl->result['content'] .= $tpl->result['navi'];
}
////////////////////////////////////////////////////////////////////////////////////////////////
That's all.
If the [list] tag is not used in the short news template, then the engine works in standard mode.
DLE version: 10.0 and older
Information
Visitors who are in the group
Guests they can't download files.
Log in to the site under your
login and password or if you are a new user go through the process
registrations on the website.