我的mybb上有一个函数显示上一篇文章的日期:$ lastpostdate
函数以下列格式打印值:01-27-2016,上午12:31
我需要以其他方式显示,但我不想修改功能本身,因为它在网页上的多个位置使用 - 原始格式适合我。
所以基本上我需要这样的工作:
我在考虑制作一个有条件的(因此在特定的地方,日期格式会有所不同)看起来有点像这样:
if ($lastpostdate = regex match(original form))
{
print($lastpostdate but in different form);
}
我实际上只需要这样做:
$lastpostdate='<span>01-27-2016, 12:31 am</span>';
进入这个:
$lastpostdate_after='<span>01-27-2016,<br />12:31 am</span>';
我想克隆函数并调整其中的格式应该更容易,然后使用自定义表单。
我只能使用PHP。
解决:
为了将php添加到模板中,需要一个插件:PHP and Template Conditionals (2.1) by ZiNgA BuRgA
将{$ lastpostdate}替换为:
<?php
$input=$lastpostdate;
$output =str_replace(',', ',<br />', $input);
print($output);
?>
这不是有条件的。