XF 2.2 UNIX Timestamp in Certain Templates

jgaulard

Active member
Hi,

I'm looking to add a UNIX timestamp to two templates:

bb_code_tag_attach

attachment_macros

I've tried the {$timestamp} and {$serverTime} variables with no luck. Does anyone know a variable I can use to add a timestamp to these two templates?

Thank you.

Jay
 
Thank you for this. I do get the current timestamp, which is what I wanted, but for some reason, what I'm trying to do isn't working.

I'm attempting to write a conditional that says, if later than a certain date, then do this. If not, then do that.

Code:
<xf:if is="$xf.time < 1618588800 OR $xf.visitor.user_id">

I have no idea why it isn't working. It seems like it should.

Jay
 
That timestamp has elapsed, so I think you would want to use >.

The following works for me:
HTML:
<xf:if is="$xf.time > 1618588800">
    {{ dump('test') }}
</xf:if>
 
Hi Jeremy,

Thank you so much for your help with this. I'm basically trying to say, if a photo has been uploaded to a post before this morning, then keep the clickable link active, but if it's been uploaded to a post after this morning, then strip away the anchor text. Here's my code:

Code:
<xf:if is="$xf.time < 1618588800 OR $xf.visitor.user_id">

<a class="file-preview {{ $canView ? 'js-lbImage' : '' }}" href="{$attachment.direct_url}" target="_blank">
<img src="{$attachment.thumbnail_url}" alt="{$attachment.filename}"
width="{$attachment.thumbnail_width}" height="{$attachment.thumbnail_height}" loading="lazy" />
</a>

<xf:else />
    
<span class="file-preview">
<img src="{$attachment.thumbnail_url}" alt="{$attachment.filename}"
width="{$attachment.thumbnail_width}" height="{$attachment.thumbnail_height}" loading="lazy" />
</span>

</xf:if>

I'm not sure if I'm missing something here.

Jay
 
Then you would want to use the attachment timestamp ($attachment.attach_date) rather than the current timestamp. Do note that crafty users will still be able to determine the full attachment URL just by looking at the thumbnail URL, in case that is a concern.
 
I want a code similar to this too. My code will be like this.
The content should not appear from 23:00 until 09:00 in the morning.
Please write the query code for this
 
Last edited:
A code like this will work for me, but I want to include it in data by adding a template. How can I do it

PHP:
<?php
$saat=date('H');
 
if($saat == 01 || $saat == 02 || $saat == 03 || $saat == 04 || $saat == 05 || $saat == 06 ||  $saat == 07 || $saat == 23 || $saat == 00){
        echo "no text";
    }
    else{
        echo "show text";
    }
?>
 
Then you would want to use the attachment timestamp ($attachment.attach_date) rather than the current timestamp. Do note that crafty users will still be able to determine the full attachment URL just by looking at the thumbnail URL, in case that is a concern.
Hi Jeremy - You wouldn't happen to have something that would work for the bb_code_tag_quote and the reaction_list_row templates, would you? The current timestamp code doesn't work. My goal is to only show the /goto/ and /reaction links to people if they've been added before a certain date.

Thanks!

Jay
 
Top Bottom