Make an editable 'copyright' section for your client

on 28-Feb-2010 | Comments ( 6 ) Tags: Evolution, GetField

The solution will not require the client to know what a chunk is. I usually set up generic configurations as a TV for the home page.

Create the TV

Create a new TV called copyright and assign it to the home template. You can choose Text, Textarea or Rich Textarea as input type.

As a default value use the example below:

© YourSite 2009-[[GetCurrentYear]]

Create snippet to get the current year

Create a new snippet called GetCurrentYear and paste the code below:

<?php
return date("Y");
?>

Show the TV value in all your templates

In order to display the value of the copyright TV you have to install a snippet like GetField.

Use it in your templates like:

[[GetField? &docid=`1` &field=`copyright`]]

modxRules uses this method. As an example check the copyright information present in the footer of this page.

Write a comment

  • Required fields are marked with *.

If you have trouble reading the code, click on the code itself to generate a new random code.
 
gremlin
Posts: 4
Comment
lol
Reply #6 on : Fri April 09, 2010, 19:47:25
I thought I was the only one doing this, made me laugh to see that I am not the only one.

One thing I noticed is that it logged errors and preferred I add the timezone.

date_default_timezone_set('America/Los_Angeles');
echo date('Y');
cipa
Posts: 2
Comment
Re: Make an editable 'copyright' section for your client
Reply #5 on : Fri April 09, 2010, 21:16:58
I think I added the time zone in the .htaccess file.
Vincent
Posts: 4
Comment
GetField?
Reply #4 on : Thu April 22, 2010, 03:27:00
Hey exactly what I was looking for!
thanks so much.

Why can't we just call the TV without using GetField?
cipa
Posts: 2
Comment
Re: Make an editable 'copyright' section for your client
Reply #3 on : Thu April 22, 2010, 05:02:28
It's easier for a client to edit a TV assigned to the home page. I prefer not to show clients how to edit chunks if it can be done in other way.

Think of the home page like the configuration section of the site. To get the value of those configuration TVs you need GetField.
smiley
Posts: 4
Comment
year
Reply #2 on : Mon May 10, 2010, 15:42:51
hehe - same here. Wrote myself the exact "snippet" some time ago.
Does anyone know another way to get the current year - say using some modx variable?
aaron
Posts: 4
Comment
Does client really need to edit???
Reply #1 on : Mon May 17, 2010, 12:07:44
This is a cool solution, I was wondering what the client needed to edit in the copyright that justifies using a TV on the home page? Based on your example you can just put something like:

© [ (site_name) ] 2009-[ [GetCurrentYear] ]

Quick modx Evolution Tags

  • cached [[snippet]] or uncached [!snippet!]
  • {{chunk}}
  • [+placeholder+]
  • [*resourceField/TV*]
  • [^timing^]
  • [~link~]

Quick modx Revolution Tags

  • [[snippet]]
  • [[$chunk]]
  • [[+placeholder]]
  • [[*resourceField/TV]]
  • [[~link]]
  • [^timing^]
  • [[++systemSetting]]
  • [[%languageStringKey]]
  • all tags can be called un-cached like: [[! snippet]]

Timing Tags (Evo and Revo)

  • [^qt^] - Query time
  • [^q^] - Query count
  • [^p^] - Parse time
  • [^t^] - Total time
  • [^s^] - Source
© modxRULES! 2009-2014