Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Global counter or random var

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Fria
Smarty n00b


Joined: 24 Sep 2015
Posts: 1

PostPosted: Thu Sep 24, 2015 1:46 pm    Post subject: Global counter or random var Reply with quote

Hello,
I'm building a small reservation system for a product. When the form is submitted an email is sent to the user that he has successfully reserved a copy.
I would like to include in this email a unique reservation order, lets say from 1 to 999.
The form is processed through one .tpl file in which there is an include for 2 other .tpl files: one with email subject and one with email content.
I'd like to put a counter on every reservation and send it in the email content.

Is there a global counter of some sort? Or perhaps there's an easier way to do this?

Kind regards!

EDIT: I know that counter is global, but Im not sure how to use it in this case
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Sep 24, 2015 6:51 pm    Post subject: Reply with quote

The {counter} is global between main template and it's subtemplate. It's not global between page calls.
You can use also in your template the PHP function uniqid() to get a unique number.
See http://php.net/manual/en/function.uniqid.php
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP