<div class="itbox pagenow"><i class="fa fa-hand-o-right"></i>
{eyou:sql sql="SELECT * FROM ey_tagindex WHERE litpic != '' AND litpic IS NOT NULL ORDER BY ID ASC LIMIT 9" cache="false" }
<a href="/index.php/tags/{$field.id}.html">{$field.tag} </a>
{/eyou:sql}
</div>
<div class="itbox pagenow">
<i class="fa fa-hand-o-right"></i>
{eyou:sql sql="SELECT * FROM ey_tagindex WHERE litpic != '' ORDER BY id ASC LIMIT 9" cache="false"}
{eyou:php}
// 获取当前标签ID(双重验证机制)
$current_id = 0;
// 方式1:通过系统内置变量获取
if (!empty($eyou['field']['id'])) {
$current_id = intval($eyou['field']['id']);
}
// 方式2:通过URL参数获取(备用方案)
if (empty($current_id)) {
$uri = parse_url($_SERVER['REQUEST_URI']);
preg_match('/tags\/(\d+)\.html/', $uri['path'], $matches);
$current_id = !empty($matches[1]) ? intval($matches[1]) : 0;
}
// 获取当前循环的标签ID
$loop_id = $field['id']; // 注意:$field变量需要在循环内部访问
{/eyou:php}
<a href="/index.php/tags/{$field.id}.html"
class="tag-item {if $loop_id == $current_id}current-tag{/if}"
data-tid="{$field.id}">
{$field.tag}
</a>
{/eyou:sql}
</div>
<style>
.tag-item.current-tag {
color: #ff6f00 !important;
transform: scale(1.05);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
</style>