XF 2.3 help converting this xenForo 1.x syntax to xenForo 2.3 syntax

island

Active member
Licensed customer
Can someone help convert the following excellent xf 1.4/1.5 code to work in the xf 2.3.10 message macros template:

Code:
{xen:if '{$user.register_date} < {xen:calc '{$serverTime} - 86400 * 7'}', '{xen:date $user.register_date, 'M Y'}', '{xen:date $user.register_date}'}

The purpose is to display Join Date as Month Year instead of Month Day Year, while maintaining Today and Yesterday for those join dates in the postbit only
 
Solution
This would be the XF 2.3 equivalent:
Code:
<xf:if is="$user.register_date < ($xf.time - 86400 * 7)">
      {{ date($user.register_date, 'M Y') }}
<xf:else />
      <xf:date time="$user.register_date" />
</xf:if>

What changed:
  • {xen:if} → <xf:if is="...">
  • {xen:calc '{$serverTime} - 86400 * 7'} → ($xf.time - 86400 * 7)
  • {xen:date $user.register_date, 'M Y'} → {{ date($user.register_date, 'M Y') }}
  • {xen:date $user.register_date} → <xf:date time="$user.register_date" />
The last one is important, <xf:date> is what gives you the "Today", "Yesterday" relative dates in XF2. The plain {{ date() }} function just outputs a static formatted date.
This would be the XF 2.3 equivalent:
Code:
<xf:if is="$user.register_date < ($xf.time - 86400 * 7)">
      {{ date($user.register_date, 'M Y') }}
<xf:else />
      <xf:date time="$user.register_date" />
</xf:if>

What changed:
  • {xen:if} → <xf:if is="...">
  • {xen:calc '{$serverTime} - 86400 * 7'} → ($xf.time - 86400 * 7)
  • {xen:date $user.register_date, 'M Y'} → {{ date($user.register_date, 'M Y') }}
  • {xen:date $user.register_date} → <xf:date time="$user.register_date" />
The last one is important, <xf:date> is what gives you the "Today", "Yesterday" relative dates in XF2. The plain {{ date() }} function just outputs a static formatted date.
 
Solution
Back
Top Bottom