Paginate by Category

7 posts by 2 authors in: Forums > CMS Builder
Last Post: May 11, 2009   (RSS)

By zip222 - May 6, 2009 - edited: May 7, 2009

I am working on a site for a foundation. One of the tables is for grants that they have given out in the past. The first criteria for sorting the list is by the quarter in which they were given (date_awarded). The list is going to get quite lengthy so I would like to only display the grants from one quarter at a time - the most recent first. I would then like to have a drop down menu for selecting a different quarter which would then show only those grants given in the selected quarter.

A live version of the page is posted here:
http://www.buhlfoundation.org/whatwedo/recent-recipients.php

The drop down is generated from the db, but I can't seem to get it to work.

Viewer code...
<?php

require_once "/data/16/1/154/52/1806867/user/1957059/htdocs/cmsAdmin/lib/viewer_functions.php";

list($past_recipientsRecords, $past_recipientsMetaData) = getRecords(array(
'tableName' => 'past_recipients',
'loadUploads' => '0',
'allowSearch' => '1',
'where' => 'showonsite=1',
));

?>


Form Code...
<form method="GET" action="recent-recipients.php" style="background: #eee; padding: 7px 10px;margin: 0 0 20px">
<label>Show Grants From Another Quarter:</label>
<select name="date_awarded_keyword">
<?php foreach ($past_recipientsRecords as $record): ?>
<?php if ($record['date_awarded'] != @$boardMtgdate): ?>
<?php $boardMtgdate = $record['date_awarded']; ?>
<option value="<?php echo ($record['date_awarded']) ?>"><?php echo date("F j, Y", strtotime($record['date_awarded'])) ?></option>
<?php endif ?>
<?php endforeach; ?>
</select>
<input type="submit" name="submit" value="Submit" />
</form>

Re: [jdancisin] Paginate by Category

By ross - May 7, 2009

Hi there.

Thanks for posting!

I think this one is going to come down to how you store the dates in your database.

Do you actually say what quarter each record is in, or do you just enter the current date when you add it?

This will determine how the code needs to work on your page.

Let me know and we'll go from there. Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Paginate by Category

By zip222 - May 7, 2009

They are entered as dates, using the "date/time" field type. Time is disabled.

Re: [jdancisin] Paginate by Category

By ross - May 8, 2009

Hi.

I think the first step here is going to be switching the name of that drop down menu from:

date_awarded_keyword

to

date_awarded_min

That will basically say, return all listings that have a date higher than the one you selected.

Now, from there, we can either do a little bit of code and calculate what quarter you are currently in and determine from there, what articles should be displayed.

An easier way might be to just have a second drop down for the max date (date_awarded_max) so you are basically just doing a range search.

The second option will be easier to setup.

Let me know what you think ;).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Paginate by Category

By zip222 - May 8, 2009

Right now I have it setup with using date_awarded_min and its not returning what I want, and the _max doesn't either. I need the user to be able to select a date and display only the grants given out on that date.

When I select "January 21, 2009" I only want to see the grants awarded on that date. Another thing is that after a search has been run I need the drop down to continue to display all of the possible dates. But right now it only displays the date I selected. I realize the methodology I am using to generate the drop down is to blame for this, but I don't know another way.

Re: [jdancisin] Paginate by Category

By ross - May 11, 2009

Hi there.

I think this is going to be something I need to take a closer look at.

Could you send me an email through consulting@interactivetools.com with a link to this post and some FTP details?

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/