| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
PHP Code in template to use date function? | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
![]() In a template is it possible to replace the code like the following examples to use a date function:
<li> <a href="https://www.usapolicesupply.com/help.php?"><img src="{$AltSkinDir}/custom/welcome/promotions/image_slider/images/operator.jpg" alt="" /></a> <p class="flex-caption">We have access to over 120,000 products.</p> </li> <li> <a href="http://www.usapolicesupply.com/breast-cancer-awareness/"><img src="{$AltSkinDir}/custom/welcome/promotions/image_slider/images/bcaware.jpg" alt="" /></a> <p class="flex-caption">October is Breast Cancer Awareness Month</p> </li> with PHP code like this: // Macmillan Cancertalk week (21-25 Jan) if ((date('m') == 01) && (date('d') >= 21) || (date('m') == 01) && (date('d') <= 23)) { echo "<img src=\"images/ribbons/cancertalk.gif\" height=\"145\" width=\"175\" alt=\"Macmillan Cancertalk\" /><br /><h6 class=\"awareness\">Macmillan Cancertalk Week <span class=\"morelink\"><a href=\"the-bookstall-cancer-links-and-resources.php\">more...</a></span></h6>"; } // Macmillan Cancertalk week (21-25 Jan) and Cervical Cancer Awareness Week (24-30 Jan) else if ((date('m') == 01) && (date('d') == 24)) { echo "<img src=\"images/ribbons/macmillan_cervical.gif\" height=\"145\" width=\"175\" alt=\"Macmillan Cancertalk and white and teal awareness ribbons\" /><br /><h6 class=\"awareness\">Macmillan Cancertalk Week & Cervical Cancer Awareness Week <span class=\"morelink\"><a href=\"the-bookstall-cancer-links-and-resources.php\">more...</a></span></h6>"; }
__________________
www.usapolicesupply.com v4.6.3 Xcartmods reBoot Template WebsiteCM CDSEO Pro SEO BCS Multipe Upselling Links Firetank Feed Manager BCS Product Importer Updater Pro BCS Drop Shipper Pro BCS Quote Request Module BCS Printable Online Catalog |
|||||||||
#2
|
|||||||||
|
|||||||||
![]() Yes, but you want to use smarty code in your template.
http://www.smarty.net/docsv2/en/language.modifier.date.format.tpl Examples: Code:
11-04-2013 Monday November 2013
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
#3
|
|||||||||
|
|||||||||
![]() Am I going in the right direct with this?
{if $smarty.now|date_format:%A eq 'Dec'} Welcome Sir. {elseif $smarty.now|date_format:%A <> 'Dec'} Welcome Ma'am. {else} Welcome, whatever you are. {/if}
__________________
www.usapolicesupply.com v4.6.3 Xcartmods reBoot Template WebsiteCM CDSEO Pro SEO BCS Multipe Upselling Links Firetank Feed Manager BCS Product Importer Updater Pro BCS Drop Shipper Pro BCS Quote Request Module BCS Printable Online Catalog |
|||||||||
#4
|
|||||||||
|
|||||||||
![]() Quote:
Second, you don't usually make two comparisons at once. You have less than/greater than, it would need to be is variable less than or is variable greater than. I don;t see why you need the else if. Just say If = Dec do this else do this. If it is not december the else would fire.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
#5
|
|||||||||
|
|||||||||
![]() Here we go, tried to make it easy and spelled out for everyone to grasp completely. I also attached the code in a text file so you could save it and reference later easily.
Code:
What is today's date smarty? 11-12-2013 What month is it smarty? November What day of the month is it smarty? 12 What day of the week is it smarty? Tuesday What year is it smarty? 2013 Is it November smarty? Yes Is it December smarty? No Is it November 1st-9th smarty? No Is it November 10th-20th smarty? Yes Is it December 2nd-10th smarty? No
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
|
#6
|
|||||||||
|
|||||||||
![]() Thank you totaltec (Mike)
I tried what you sent and it worked great and I now understand the concept. Thanks JEC
__________________
www.usapolicesupply.com v4.6.3 Xcartmods reBoot Template WebsiteCM CDSEO Pro SEO BCS Multipe Upselling Links Firetank Feed Manager BCS Product Importer Updater Pro BCS Drop Shipper Pro BCS Quote Request Module BCS Printable Online Catalog |
|||||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|