Life, SAP, Consulting, Programming, Coding, ASP.NET, Sharepoint, MVC, Javascript, PHP, WebDesign, CSS, HTML

Posts tagged ‘first-record-missing’

PODS CMS First record missing

Today, I had an interesting experience with Pods CMS and I would like to share with everyone.

Here is the code of that page:

<?php

$param = array(

“where” => “t.enddate >= CURDATE() AND event_type.name=’Training'”,

“orderby” => “t.startdate ASC”,

“limit” => “100”,

);

//$events = pods( ‘event’, $param );

echo ‘<div class=”container”>’;

echo ‘<h3>Select Training Category</h3>’;

echo $events->filters(array(‘fields’=>’training_category’));

echo ‘<p>&nbsp;</p>’;

echo $events->template(‘training_list’);

echo ‘</div>’;

?>

I have a Pods page that list all event. In that page, I need a filter on event_category. My client told me that there was one record missing.

I viewed the code, review the documentation and found that there was nothing wrong.

Trying to search if someone had encountered the same issue as me, I found two major topics:

fetch() won’t return first result

Fetch record is chopping off the first record

However they didn’t help me match. I got the same symptom but different cause, I thought.

After several debugging, found out what was causing that issue. If I remove filter box. I would get correct list of all events. But filter box is client’s requirement.

Then I try to echo filter box before finding records. The code section look like this:

<?php

$param = array(

“where” => “t.enddate >= CURDATE() AND event_type.name=’Training'”,

“orderby” => “t.startdate ASC”,

“limit” => “100”,

);

//$events = pods( ‘event’, $param ); fix first row missing.

$events = pods( ‘event’ );

echo ‘<div class=”container”>’;

echo ‘<h3>Select Training Category</h3>’;

echo $events->filters(array(‘fields’ => ‘training_category’));

echo ‘<p>&nbsp;</p>’;

$events->find($param); //fix first row missing

echo $events->template(‘training_list’);

echo ‘</div>’;

?>

And finally, It worked. I don’t have much time to investigate why the filters box would cause that issue. However, I would like to share with everyone. Hope that it would be helpful in case you encounter the same issue. J