Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Automatically input current year in custom field of article_custom?
I have been unable to figure this out. I hope you can help me out.
I have the following article_custom tag:
<txp:article_custom section="artists" limit="1" form="front_page_artist" sort="rand()" year="2012" />
I want the current year automatically input for the custom field year
.
I tried year="<txp:php>echo safe_strftime('%Y');</txp:php>"
, but article_custom doesn’t output anything.
I am sure the answer is already in the forum, but I have been unable to discover it…
Do you have any suggestions?
• Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
• MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
• JapaneseStreets.com – Japanese street fashion (mostly txp)
Offline
Re: Automatically input current year in custom field of article_custom?
Maybe try
<txp:variable name="current_year"><txp:php>echo safe_strftime('%Y');</txp:php></txp:variable>
then
<txp:article_custom section="artists" limit="1" form="front_page_artist" sort="rand()" year='<txp:variable name="current_year" />' />
Edit: Corrected custom_field to variable. Thanks!
Last edited by maruchan (2012-03-05 03:48:25)
Offline
Re: Automatically input current year in custom field of article_custom?
That did the trick. Thanks, maruchan.
This is one of those times where you think, how come I didn’t think of that…
Others wanting to benefit from this, please notice the accidental typo: txp:custom_field
should be txp:variable
.
The correct code is:
<txp:article_custom section="artists" limit="1" form="front_page_artist" sort="rand()" year='<txp:variable name="current_year" />' />
Last edited by Kjeld (2012-03-04 07:10:48)
• Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
• MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
• JapaneseStreets.com – Japanese street fashion (mostly txp)
Offline
#4 2012-03-04 13:23:22
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: Automatically input current year in custom field of article_custom?
Kjeld wrote:
I tried
year="<txp:php>echo safe_strftime('%Y');</txp:php>"
, but article_custom doesn’t output anything.
If this is literally what you tried, then it’s the double quotes.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline