Creating a ModX website part 7: The two footers
published onFor now we are skipping the contact form section as we will get to that later.
For now we will deal with the two footers. One contains an address, links to social media accounts and a section about the Freelancer theme we are using. The other simply contains a copyright message.
Editing the larger footer
First all of we will address the larger of the two footers.
If you are using this theme for a single person then the easiest way to do this would be to open up the chunk in the Elements section in the ModX backend and make the necessary changes. This information is not going to change and so hard - coding it will work.
If you are going to use this theme for multiple people, as we have been doing throughout these posts, then you may wish to use Template Variables instead.
If you do go down the route of using Template Variables remember to move the ModX tag for this section from the template into each individual page. This will allow you to give each Template Variable a value so that the address and links change with each page you visit
Editing the copyright notice
Currently the HTML for your copright footer looks something like this
<!-- Copyright Section-->
<div class="copyright py-4 text-center text-white">
<div class="container"><small>Copyright © Your Website 2023</small></div>
</div>
This can also be done in ModX automatically by using the following HTML and ModX instructions instead. What we have also done here is to move the year to before your website name rather than it appearing after it.
<!-- Copyright Section-->
<div class="copyright py-4 text-center text-white">
<div class="container"><small>Copyright © [[!+nowdate:default=`now`:strtotime:date=`%Y`]] Your Website</small></div>
</div>
Alternative method of displaying copyright text
It is possible to display the copyright text, along with the appropriate dates, using PHP if the method above wasn't what you wanted.
To set this up first click on the Elements tab then on the + to the right of the Snippets text.
In the Name field enter Copyright and then paste the following code into the Snippet Code (PHP) field (replacing what is already there).
<?php
$now = date("Y");
$startYear = $modx->getOption('startYear', $scriptProperties, $now);
$spacer = $modx->getOption('spacer', $scriptProperties, ' - ');
$years = ($now > $startYear) ? $startYear.$spacer.$now : $now;
return $years;
Now click Save.
Go back to the chunk that displays your copyright message and update the chunk to read as follows
<!-- Copyright Section-->
<div class="copyright py-4 text-center text-white">
<div class="container">
<small>Copyright © [[Copyright]] Your Website</small></div>
</div>
Now click Save and view your site.
Disclaimer: Both of these methods were found on the ModX forums.
