add datestamp to webyep page?

General discussions about WebYep
Post Reply
peglomaniac
Posts: 7
Joined: Sun Oct 17, 2010 6:59 pm

add datestamp to webyep page?

Post by peglomaniac » Thu Oct 21, 2010 10:23 am

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

manfred
Objective Development
Objective Development
Posts: 561
Joined: Sat Jul 31, 2010 9:47 am
Location: Vienna
Contact:

Re: add datestamp to webyep page?

Post by manfred » Wed Oct 27, 2010 5:30 pm

Peg,

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

peglomaniac
Posts: 7
Joined: Sun Oct 17, 2010 6:59 pm

Re: add datestamp to webyep page?

Post by peglomaniac » Wed Oct 27, 2010 6:45 pm

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

TicTaco
Posts: 2
Joined: Wed Oct 13, 2010 11:05 pm

Re: add datestamp to webyep page?

Post by TicTaco » Sat Oct 30, 2010 12:26 am

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.

manfred
Objective Development
Objective Development
Posts: 561
Joined: Sat Jul 31, 2010 9:47 am
Location: Vienna
Contact:

Re: add datestamp to webyep page?

Post by manfred » Sat Oct 30, 2010 10:38 pm

taco,

thank you for posting this solution!

peglomaniac
Posts: 7
Joined: Sun Oct 17, 2010 6:59 pm

Re: add datestamp to webyep page?

Post by peglomaniac » Mon Nov 01, 2010 3:23 am

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

Post Reply