CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Token for current date?
Pages: [1]

Author Topic: Token for current date?  (Read 11450 times)

kmitz

  • I post occasionally
  • **
  • Posts: 74
  • Karma: 2
Token for current date?
May 13, 2010, 06:13:47 am
Hi,

Is there an undocumented token that displays today's date for use in a CiviMail message?  I've tried the Smarty "now" function which didn't work.

kmitz

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Token for current date?
May 13, 2010, 01:14:01 pm

no

but if you do write one / figure out how to get smarty now to work, please publish your findings so others can benefit

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

kmitz

  • I post occasionally
  • **
  • Posts: 74
  • Karma: 2
Re: Token for current date?
May 13, 2010, 02:34:41 pm
Hey Lobo,

I'm assuming that the HTML version (via CKEditor) of a CiviMail is run through Smarty...or is the token replacement done outside of Smarty?  I'm a little puzzled why Smarty functions don't work.  If that's true, then a custom Smarty plugin won't work either.

kmitz

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Token for current date?
May 13, 2010, 03:08:32 pm

No. CiviMail messages are not run via smarty

you can try the technique suggested here: http://civicrm.org/node/480

have not tested that in a long time, so you might need to check / fix the code

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Cedeira

  • I post occasionally
  • **
  • Posts: 45
  • Karma: 1
    • CompuLogiX Systems, Inc.
Re: Token for current date?
August 23, 2010, 08:32:09 pm
Not to be facetious, but, if you go to google.com and in the search box you enter the keywords you are looking for and then site:civicrm.org, google will give you back all search results including blogs, forum, documentation, etc. e.g.
token hook blog lobo site:civicrm.org

or conversely you can click on the advance search link next to the search button and it will give you lots of choices including date parameters to search on  ;)

Mind you that it might not be as good as setting up Google Custom Search on the site since it might do something extra with the indexing... but I have already used it to find blog entries and it works.

lobo,
maybe version 4.0 should include a real ECMS such as Alfresco http://www.alfresco.com/community/ to be used as the repository for documentation, portal, blogs, wiki, etc.? 

Speedy
God grant me the serenity to accept the things I can not change, valor to change the ones I can, and the knowledge to recognize the difference!

starryeyez024

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
Re: Token for current date?
October 28, 2010, 09:55:52 am
Quote from: Cedeira on August 23, 2010, 08:32:09 pm
Not to be facetious, but, if you go to google.com and in the search box you enter the keywords you are looking for and then site:civicrm.org, google will give you back all search results including blogs, forum, documentation, etc. e.g.
token hook blog lobo site:civicrm.org

I think this is where we all start... if it were that easy I don't think this forum post would be here. I have searched the CiviCRM site many times and can't find a token for today's date. And if it is easy for you to find, could you please include it here on the forum post? Thanks.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Token for current date?
October 28, 2010, 04:41:23 pm

CiviCRM does not expose a token for today's date. You should be able to use Smarty's php feature at the very least to be able to print out todays date in the template:

http://www.smarty.net/manual/en/language.function.php.php

you can also search across all CiviCRM site via CiviSearch :)

http://civicrm.org/civisearch

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

vsharma012

  • I’m new here
  • *
  • Posts: 20
  • Karma: -2
    • Adaptive IT
  • CiviCRM version: 4.1
  • CMS version: Drupal
Re: Token for current date?
March 03, 2013, 02:52:56 am
Thanks for guidance Lobo,  This is how it will work. to display the current date when using message template.

{php}
    $mdate=date('F jS, Y');
     $this->assign('CurrentDate',$mdate);
{/php}
<strong>{$CurrentDate}</strong>

Vikas sharma
Vikas Sharma
Adaptive IT
http://www.adaptiveitsystems.com

fmcooke

  • I’m new here
  • *
  • Posts: 18
  • Karma: 2
    • Beta Consulting
  • CiviCRM version: 4.3.5
  • CMS version: Joomla! 2.5.13
  • MySQL version: N/A
  • PHP version: PHP Version 5.3.10-1ubuntu3.1
Re: Token for current date?
July 06, 2013, 06:17:12 am
Thanks everybody! I will include the code that I used to change the language of the date as my server was speaking the date in English and I need it in spanish!.

{php}

     setlocale(LC_ALL,"es_ES");
     $mdate=strftime("%d de %B del %Y");
     $this->assign('CurrentDate',$mdate);
   
{/php}
<p align="right"> Salta, {$CurrentDate}</p>


I am not a programer just found the code in the web and I think that maybe is useful for others!.

Kind regards,
Fede
Kind Regards,
Federico Cooke

Jon-man

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
  • Supporting voluntary action since 1975
  • CiviCRM version: 4.4.6
  • CMS version: Drupal 7.28
  • MySQL version: 5.1.68-cll
  • PHP version: 5.3.18
Re: Token for current date?
April 29, 2015, 02:00:30 am
If you're using Drupal you can use our module which makes today's date available as a token in CiviCRM.
https://www.gmcvodatabases.org.uk/civicrm-stuff/civicrm_todaysdate_token.tar.gz

Just extract it to sites/all/modules

This works for CiviCRM 4.4.x and 4.5.x so far.

N.B. This makes 3 dates available which are formats most useful for the UK, but can be changed simply if you look at the code

Jon-man

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Token for current date?
April 29, 2015, 08:34:01 am
We discovered at the sprint that just about everyone has written a token for this at some point (here's mine https://github.com/eileenmcnaughton/nz.co.fuzion.civitoken) - core would welcome a patch to put that in core according to DGG if someone wants to...
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Token for current date?

This forum was archived on 2017-11-26.