+ Post New Thread
Results 1 to 4 of 4
Coding Thread, Display Week 1 or Week 2 on Joomla Intranet Page in Coding and Web Development; Hello, We are trying to develop a new Intranet page for our school using Joomla, we operate a 2 Week ...
  1. #1

    Join Date
    Aug 2005
    Location
    Shropshire
    Posts
    284
    Thank Post
    16
    Thanked 11 Times in 8 Posts
    Rep Power
    21

    Display Week 1 or Week 2 on Joomla Intranet Page

    Hello,

    We are trying to develop a new Intranet page for our school using Joomla, we operate a 2 Week timetable and so, what we would like on the HomePage is some kind of coding/script that would display the current date (that's easy enough) but would also display whether we were currently on Week 1 or Week 2 for the timetable.

    Is anybody able to point me in the right direction of how we get this working? Or does anybody have a code already to do this or similar? I've never done any coding before, so don't really know where to start on this!

    Many Thanks

    Matt

  2. #2

    Join Date
    Apr 2008
    Location
    Keighley, West Yorks
    Posts
    312
    Thank Post
    44
    Thanked 49 Times in 43 Posts
    Rep Power
    21
    Matt,

    weeks.php
    <?php
    //Usage:
    //echo getWeekByDate("25/03/08");
    // OR
    //echo getWeekByDate(date("d/m/Y",strtotime("now")));

    function getWeekByDate($dateIN) // DD/MM/YY format
    {
    $dateIN = invertdate2($dateIN);
    $dateIN = str_replace("/","-",$dateIN);
    $dateIN = date("y-m-d",strtotime($dateIN));

    $file = "weeks.csv";
    $lines = file($file);
    $size = count($lines);
    $weekcom = date("Y",strtotime("now"));

    if (date("N",strtotime($dateIN)) == 1)
    {
    $dateIN = date("y-m-d",strtotime($dateIN));
    }
    else
    {
    $dateIN = date("y-m-d",strtotime("last monday",strtotime($dateIN)));
    }
    $weekcom = date("dmy",strtotime($dateIN));

    $wkfound = false;
    for($i=0;$i<$size;$i++)
    {
    list($wkdate,$week) = explode("," , $lines[$i]);

    $m = substr($wkdate,0,2);
    $d = substr($wkdate,3,2);
    $y = substr($wkdate,7,4);

    $wkdate = $d . "/" . $m . "/" . $y;
    if (date("dmy",strtotime($wkdate)) == $weekcom)
    {
    return $week;

    $wkfound = true;
    }

    }

    if (!$wkfound)
    {
    return "Unknown Week [$dateIN]";
    }
    else
    {
    return "Known Week [$dateIN]";
    }
    } //end function getWeekByDate

    function invertdate2($inDate)
    {
    $lenPart1 = strpos($inDate,"/");
    $lenPart2 = strpos($inDate,"/",$lenPart1);
    $stPart3 = $lenPart1+$lenPart2+2;

    $part1 = substr($inDate,0,$lenPart1);
    $part2 = substr($inDate,$lenPart1+1,$lenPart2);
    $part3 = substr($inDate,$stPart3);

    return $part3 . "/" . $part2 . "/" . $part1;
    }

    ?>
    weeks.csv
    05/03/2012,Week A
    12/03/2012,Week B
    19/03/2012,Week A
    26/03/2012,Week B
    02/04/2012,Easter Holiday
    09/04/2012,Easter Holiday
    16/04/2012,Week A
    23/04/2012,Week B
    The above PHP code, together with a 2-column CSV file called "weeks.csv" in the same folder, will do what you want - it's just a case of working out how to display it in Joomla which I can't help with.

    I do exactly the same as what you're asking, except in Frog - we embed a HTML brick/widget which displays this page hosted on our internal webserver.

    Peter

  3. 3 Thanks to howartp:

    gumbygaz (17th May 2013), mattpant (2nd April 2012), naysweb (6th June 2013)

  4. #3

    Join Date
    Aug 2005
    Location
    Shropshire
    Posts
    284
    Thank Post
    16
    Thanked 11 Times in 8 Posts
    Rep Power
    21
    Many Thanks Peter for the scripts you use. I will try them out on our setup.

    Matt

  5. #4
    gumbygaz's Avatar
    Join Date
    Nov 2009
    Location
    Staffordshire
    Posts
    93
    Thank Post
    77
    Thanked 13 Times in 12 Posts
    Rep Power
    12
    Cheers! Year old post, but was just what I needed for our Frog page Thanks for sharing

SHARE:
+ Post New Thread

Similar Threads

  1. Intranet page based on group membership
    By MK-2 in forum Web Development
    Replies: 22
    Last Post: 17th June 2011, 08:15 PM
  2. XPe or CE on old P2 350s 64Mb RAM
    By monkey_boy in forum Thin Client and Virtual Machines
    Replies: 16
    Last Post: 5th March 2009, 05:57 PM
  3. Any free video to flash converters or ideas on video?
    By Quackers in forum Web Development
    Replies: 15
    Last Post: 26th June 2007, 03:23 PM
  4. Probs with Smooth Gallery on Joomla Template
    By bensewell in forum Web Development
    Replies: 2
    Last Post: 26th June 2007, 07:09 AM
  5. firewall on or off on network
    By Uraken in forum Windows
    Replies: 25
    Last Post: 22nd February 2007, 10:26 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •