1 | <?php |
||
2 | /** @var \Apps\ActiveRecord\Content[] $records */ |
||
3 | |||
4 | use Ffcms\Core\Helper\Date; |
||
5 | use Ffcms\Core\Helper\Text; |
||
6 | use Ffcms\Core\Helper\Type\Str; |
||
7 | |||
8 | foreach ($records as $record) { |
||
9 | $title = \App::$Translate->getLocaleText($record->title); |
||
10 | if (Str::likeEmpty($title)) { |
||
11 | continue; |
||
12 | } |
||
13 | $title = Text::snippet($title, 50); |
||
14 | $date = Date::humanize($record->created_at); |
||
15 | $categoryUrl = \App::$Alias->baseUrl . '/content/list/' . $record->cpath; |
||
16 | $categoryLink = '<a href="' . $categoryUrl . '">' . \App::$Translate->getLocaleText($record->ctitle) . '</a>'; |
||
17 | $newsLink = \App::$Alias->baseUrl . '/content/read/' . $record->cpath; |
||
18 | $newsLink = rtrim($newsLink, '/') . '/' . $record->path; |
||
19 | |||
20 | echo '<div class="row"><div class="col-md-12">'; |
||
21 | echo '<a href="' . $newsLink . '">→ ' . $title . '</a><br />'; |
||
22 | echo '<small class="float-left">' . $categoryLink . '</small>'; |
||
23 | echo '<small class="float-right text-secondary">' . $date . '</small>'; |
||
24 | echo '</div></div>'; |
||
25 | echo '<hr class="pretty" />'; |
||
26 | } |
||
27 | ?> |
||
0 ignored issues
–
show
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.