Forum Discussion
Hi Clairekav,
Unfortunately I don't have a full solution for you, but I want to throw out some tips that might help get you going in the right direction.
There is a method for the user context object:
${user.registrationTime}
There is also a method for getting a date, for example:
${datesupport.now.addDay(-14)}
However, manipulating and comparing date strings via freemarker might be a little tricky, and it's definitely outside my realm of expertise.
You can find more information about these methods and others here:
And here's a resource talking about dates in Freemarker:
http://freemarker.sourceforge.net/docs/ref_builtins_date.html#ref_builtin_string_for_date
Some possible alternatives...
- Ranks: If you want to show it to members of a certain rank (ie. New Member), there are REST calls for getting the rank of a user.
- Roles: Similarly, if you grant a certain role after users reach a certain rank, you could show the announcement to users that didn't have that role (or vice-versa if you have a "New Member" role that gets removed eventually). There are REST calls to get the roles for a user also.
Depending on how your rank structure is setup, that might be the easiest approach. If you need more information on the two alternatives, just let me know.
I hope this helps!
Thanks very much for the links AdamN, there is a lot of good info there - I would have never found it on my own!
After some playing around I've managed to get the text to change based on user.ID and maybe user.registrationTime (?!).
Note if you're trying to use "less than", < doesn't work, as it interprets this as the end of the code, to you have to use \lt (link here to FreeMarker comparison for further info)
So.....
I can get varying text according to user ID:
My ID is 523, so this works:
<#if user.id == 523 > This is user 523</p> <#else>This is another user </#if>
This is less than (using \lt) user ID of 1000:
<#if user.id \lt 1000 > This is less than user ID 1000</p> <#else>This great than user ID 1000 </#if>
And registration date if exactly 14 days ago - it doesn't throw up an error, however....
Date (-14) formula untested: It doesn't seem to change if I put my exact registration date in days ago but it may have something to do with date formatting?
<#if user.registrationTime == datesupport.now.addDay(-14)> 14 days ago <#else>not 14 days ago </#if>
However I'm having trouble with inserting "less than" - it throws up big yellow "free marker" error...
<#if user.registrationTime \lt datesupport.now.addDay(14)><p>Mouse found</p> <#else><p> not mouse found</p> </#if>
Any ideas about how to get "less than x days ago" for my "user.registrationTime" variable?
If I can't get user.registrationTime to work, I was thinking as AdamN suggested, perhaps using Ranks - however I'm not sure what the variable is called as it wasn't listed under the user info
"user.rank" isn't recognised.... I'm sure it's called something else, I just took a stab. Any clues as to what it is actually called?
<#if user.rank == newbie_giffgaffer > This is a newbie</p> <#else>This is an older member </#if>
This is quite exciting - I will be great to have variable FAQ's according to join date, rank or even the number of log ins.
Our community base is kind of 'un-traditional' - as we have a lot of people visiting who've never used a forum before - so it will be great to crack this to make things a little easier for them.
Any help is greatly appreciated!