Page 1 of 1

add datestamp to webyep page?

Posted: Thu Oct 21, 2010 10:23 am
by peglomaniac
Hello,

Is there a way to add a date stamp element to a WebYep page?

I am just learning WebYep (finally) and have a long way to go!

peg

Re: add datestamp to webyep page?

Posted: Wed Oct 27, 2010 5:30 pm
by manfred
Peg,

Unfortunately there is no date/timestamp element available. Depending on your needs a small JavaScript may help.

Re: add datestamp to webyep page?

Posted: Wed Oct 27, 2010 6:45 pm
by peglomaniac
thanks manfred.

The page is a 'swap shop' where members of a car club, or paying guests, can post an ad for 30 days. We need to record the date for the paying customers, so we know when the ad ends.

I don't know how to go about writing a javascript... can you recommend somewhere I might be able to get some assistance with that?

If it helps, the page is at http://www.eliminators.ca/swap_shop.php

Many thanks again.
peg

Re: add datestamp to webyep page?

Posted: Sat Oct 30, 2010 12:26 am
by TicTaco
In a e-mail conversation Johannes and I came to this solution.
Within the LoopItem embed the following code before adding any other items:

Code: Select all

<?php
 if (webyep_bIsEditMode()) {
   echo "<div>";
   echo "<b>Startdatum:</b> ";
   webyep_shortText("WY_StartPublish", false);
   echo "<br>";
   echo "<b>Stopdatum: </b>";
   webyep_shortText("WY_StopPublish", false);
   echo "  <i>(optioneel)</i>";
   echo "<br> Datum invoeren als: dd-mm-jjjj)";
   echo "</div>";
 }
 if (
    webyep_bIsEditMode() || (
           (
              strtotime("now") >= strtotime(webyep_sShortTextContent("WY_StartPublish", false))
              ||
              webyep_sShortTextContent("WY_StartPublish", false)== ""
           )
           &&
           (
              strtotime("now") < strtotime(webyep_sShortTextContent("WY_StopPublish", false))
              ||
              webyep_sShortTextContent("WY_StopPublish", false)== ""
            )
        )
     ) {
?>


Just before the end of the Loop item add this code:

Code: Select all

<?php } ?>  //To end the IF


The code works actually quite simple: the input is two times a string through a webyep shorttext item. The strings are then converted to a datestamp which it compares with the datestamp of the moment you are loading the page.

If you enter nothing, the string is left blank and the loopitem will be displayed. So now it's possible to add content with a datestamp (i think the same code here works if you add the hours, minutes and seconds).

If the date is not converted properly this might have soemthing to do with the local settings of the dateformat. You could change this in the first php-line with the setLocale() function.

It made my life better cause there's no need anymore to learn the more difficult CMS. :D

Regards,

Taco.

Re: add datestamp to webyep page?

Posted: Sat Oct 30, 2010 10:38 pm
by manfred
taco,

thank you for posting this solution!

Re: add datestamp to webyep page?

Posted: Mon Nov 01, 2010 3:23 am
by peglomaniac
Thank you for the solution Taco. I have yet to implement it, as I am a serious novice at this - but I will master it.

I need to find out first, where the LoopItem is.

I need to learn a lot, so will be posting some questions that probably have some very elementary answers, but first, I'll try a bit of experimenting...

Many thanks again.

peg