This topic is locked

Open list page on current month

12/27/2008 9:03:10 AM
PHPRunner General questions
A
Astrid author

Is there a way to open the list page on the current month. I've made an events calendar starting december 2008 end ending february 2010. I want users to be able to search through complete calender, but it would be nice if the moment the open the calendar they see the current month.

Database has Date field.

J
Jane 1/5/2009

Hi,
current month is selected when you open monthly list page first.

Please check your calendar template more carefully.

A
Astrid author 1/5/2009

I'm not using the calendar template.

Just a list based on a database

Date

Event

From

Untill

J
Jane 1/6/2009

Hi,
to filter records on the list page add where clause in the List page: Before SQL query event on the Events tab.

Here is a sample:

if ($_REQUEST["a"]=="search" || $_REQUEST["a"]=="advsearch")

$strWhereClause = whereAdd($strWhereClause,"MONTH(`Date`)=MONTH(CURDATE()) and YEAR(`Date`)=YEAR(CURDATE())");



http://dev.mysql.com/doc/refman/5.0/en/dat...l#function_year

http://dev.mysql.com/doc/refman/5.0/en/dat...#function_month

A
Astrid author 1/6/2009

Sorry Jane,

It doesn't work.

I've tried another solution found in this forum with a button in kalender_list.htm

<input type=button class=button value="Huidige maand" onClick="kalender_list.php?showrecords=maand" >



And this in kalender_events.php

// List page: Before SQL query

function BeforeQueryList(&$strSQL,&$strWhereClause,&$strOrderBy)

{

//********** Custom code ************

// put your custom code here

if (@$_REQUEST["showrecords"]=="maand")

$strWhereClause = whereAdd($strWhereClause,"MONTH(`Datum`)=MONTH(CURDATE()) and YEAR(`Datum`)=YEAR(CURDATE())");
} // function BeforeQueryList



Nothing happens when I click the button.

Sergey Kornilov admin 1/6/2009

Astrid,
as a first step try to open the following URL in your browser manually:

kalender_list.php?showrecords=maand

A
Astrid author 1/6/2009

Astrid,

as a first step try to open the following URL in your browser manually:

kalender_list.php?showrecords=maand



Sergey,

That works!

Now the button.........

A
Astrid author 1/7/2009

Sergey,

Found a simple solution:

As the list is in a wrapper in my site, menu-item from site opens with:

site/kalender_list.php?showrecords=maand



To enable viewing complete list, changed tekst on Show all button to "Show all months".

To enable going back to current month, created new button:

<input class=button type=button value="Toon huidige maand" onClick="history.back()">



Works like a charm!