1
BigKev73
Changing Site Logo and Welcome Message with the Holiday
  • 2021/2/10 22:59

  • BigKev73

  • Just popping in

  • Posts: 13

  • Since: 2021/1/26


I made this change awile ago, but thought I would share it. This is pretty much a change to the default theme header. This is the change I made to theme.tpl to the header section.

le="color: #000000"><?php <!-- Start Header --> <table cellspacing="0"> <tr id="header"> <td id="headerlogo"><a href="<{xoAppUrl /}>" title="<{$xoops_sitename}>"><{php}> //This is used to calculate the various holidays and change the main Banner Logo Appropriately $currentYear = date("Y"); $day = date("j"); $mnth = date("n"); //Used to Calculate floating Holidays $easterday = date("j", easter_date($currentYear)); $eastermnth = date("n", easter_date($currentYear)); $edaystart = ($easterday - 7); $edaystop = ($easterday + 2); if ($edaystart<1 ) {$edaystart = 1;} if ($edaystop>31 ) {$edaystop = 31;} $turkeyDay = date('j', strtotime("november $currentYear fourth thursday")); $turkeyStart = ($turkeyDay - 7); $turkeyStop = ($turkeyDay + 2); //Normal Image $HolidayMsg = "Hello"; $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_normal.jpg"; //XMAS if ($mnth == "12" AND $day <= 29){ $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_xmas.jpg"; $HolidayMsg = "Merry Christmas"; }else if ($mnth == "11" AND $day > $turkeyStop ) { $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_xmas.jpg"; $HolidayMsg = "Merry Christmas"; //NYE }else if ($mnth == "12" AND $day > 29) { $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_newyears.jpg"; $HolidayMsg = "Happy New Years"; }else if ($mnth == "1" AND $day < 7) { $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_newyears.jpg"; $HolidayMsg = "Happy New Years"; //St Pattys Day }else if ($mnth == "3" AND $day > 10 AND $day <= 19){ $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_stpattys.jpg"; $HolidayMsg = "Happy St. Patty's Day"; //Easter }else if ($mnth == $eastermnth AND $day >= $edaystart and $day <= $edaystop){ $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_easter.jpg"; $HolidayMsg = "Happy Easter"; //4th July }else if ($mnth == "6" AND $day >= 28){ $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_4thjuly.jpg"; $HolidayMsg = "Happy 4th of July"; }else if ($mnth == "7" AND $day <= 6){ $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_4thjuly.jpg"; $HolidayMsg = "Happy 4th of July"; //THANKSGIVING }else if ($mnth == "11" AND $day >= $$turkeyStart AND $day <= $turkeyStop ) { $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_turkey.jpg"; $HolidayMsg = "Happy Thanksgiving"; //Default Normal Logo }else{ $logofile = $this->_tpl_vars['xoops_imageurl']. "logo_normal.jpg"; } echo '<img src="' . $logofile . '"'; <{/php}> alt="<{$xoops_sitename}>"/></a></td> <td id="headerbanner"><{$xoops_banner}></td> </tr> <tr> <td id="headerbar" colspan="2" height="25" style="vertical-align: middle;"><FONT COLOR = #0066FF><B>&nbsp;<{if $xoops_isuser}> <{php}>echo $HolidayMsg;<{/php}> <{$xoops_name}> and Welcome Back! &nbsp;<{else}> <{php}>echo $HolidayMsg;<{/php}>! If you're new here, please register for a free account <{/if}>&nbsp;</B></FONT COLOR></td> </tr> </table> <!-- End header -->


This looks at the date, then changes the img src to the appropriate logo depending on the holiday. It changes a few days before the holiday and reset a few days after the holiday. It also changes the welcome message that appears in the header bar. Each of those images are basically my same site logo, with a different holiday theme added to it.

Hopefully, someone else finds this useful. I am sure there is a more SMARTY way of doing this. I just figured it was easier for me to inject PHP to handle it.

2
Mamba
Re: Changing Site Logo and Welcome Message with the Holiday
  • 2021/2/11 4:36

  • Mamba

  • Moderator

  • Posts: 11542

  • Since: 2004/4/23


Very cool!

I hope, one of our theme designers will be able to use it.
Support XOOPS => DONATE
Use 2.7.x | Docs | Modules | Bugs

3
alain01
Re: Changing Site Logo and Welcome Message with the Holiday
  • 2021/2/12 9:58

  • alain01

  • Just can't stay away

  • Posts: 544

  • Since: 2003/6/20


Hi Kev,
2 remarks,

- Add a directory images in the theme, better than in the root theme directory
- If we want to generalize your code, we should take into account the international and geographic aspect of the dates.
Example 1:The holidays are not all at the same time depending on the country, depending on the region (3 different zones in France),
Example 2: certain holidays do not exist in certain countries (July 4 in the United States, July 14 in France)

I dont find xoops smarty date to transform your php code in template files with smarty tests but I'm not a specialist.

Alain01