forked from laysense/laysense.cn
39 lines
1.9 KiB
PHP
39 lines
1.9 KiB
PHP
<?php
|
|
use App\Content\DirectoryCard;
|
|
use App\Content\Html;
|
|
use App\Content\View;
|
|
|
|
$e = View::escape(...);
|
|
?>
|
|
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
|
|
<div class="catalog-grid">
|
|
<?php foreach ($products as $product): ?>
|
|
<?php
|
|
$card = $product['card'];
|
|
$body = Html::articleBody($product);
|
|
$target = DirectoryCard::links($product, $body)['primary'];
|
|
$extra = $card['extra_url'] ?? '';
|
|
?>
|
|
<article class="catalog-card">
|
|
<?php if (!empty($card['image'])): ?>
|
|
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
|
|
<?php endif ?>
|
|
<div class="catalog-content">
|
|
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
|
|
<h3><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h3>
|
|
<?php if ($product['summary']): ?>
|
|
<p><?= $e($product['summary']) ?></p>
|
|
<?php else: ?>
|
|
<div class="rich"><?= $body ?></div>
|
|
<?php endif ?>
|
|
<?php if ($target !== '' || $extra !== ''): ?>
|
|
<div class="actions">
|
|
<?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?>
|
|
<?php if ($extra !== '' && $extra !== $target): ?><a href="<?= $e($extra) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
|
</div>
|
|
<?php endif ?>
|
|
</div>
|
|
</article>
|
|
<?php endforeach ?>
|
|
</div>
|