0

If a client is interested in a copyright range in their footer rather than just current years, how can i make this dynamic in EE?

7

I figure this quick little example would help someone so I've asked and answered my own question:

Copyright © {if '{current_time format="%Y"}' > "2010"}2010 - {/if}{current_time format="%Y"}. ACME Inc. All rights reserved.

This assumes:

a) your start year is 2010 - could be whatever four-digit year you want (since that's what the date comparison is looking for

b) yes, this is a complex conditional - natively it winds up having to be in order to get the format parameter in there. You could probably do this more efficiently with current time as a stashed variable, but i wanted to simply show a basic native approach here first.

c) this will only insert the range IF the current year is greater than the start year. Otherwise, it will only show the current year. Something like this only makes sense if you know for sure the client wants to have a dynamically-set range in their copyright footer.

Hope this helps someone.

2
  • personally I would avoid the conditional. Set my copywrite date to the current year and then when the new year comes chnge it to 2012 - {current_time format="%Y"}. Not a set and forget it, but no advanced conditionals and you only need to revisit the site once to then set it and forget it.
    – CreateSean
    Dec 7 '12 at 23:25
  • 1
    I created this more for the edge case wherein you create and launch the site early in the year and so setting the current year as the start year in the date range isn't necessarily practical, since it would mean remembering to return 11 months later to change the code. In a pinch, this works, and if you take the extra step and stash it or save it as a low variable, all the better. But I agree with you - if you can get away with avoiding the conditional, all the better. If the client's start date will never be the current year, you're saved from having to choose in the first place. Dec 7 '12 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.