Question about serendipity_fetchEntries

Discussion corner for Developers of Serendipity.
Post Reply
eburrows
Regular
Posts: 19
Joined: Fri May 05, 2006 11:28 pm

Question about serendipity_fetchEntries

Post by eburrows »

Sorry if this is a stupid question but I have not been able to figure it out as of yet. What is the field id for categories that are associated with an entry?

I am doing further parsing on the entries array and it would be very useful to find this out. Obviously I can get the selected entries by doing the following:

Code: Select all

$entries = array();
$entries = serendipity_fetchEntries('all');

foreach ($entries as $entry_val){
  $id = $entry_val['id'];
  $title = $entry_val['title'];
  $body = $entry_val['body'];
  $extended = $entry_val['extended'];
  $author = $entry_val['author'];
}
What is the field that holds the categories? I tried the obvious like $entry_val['category'] but it didn't do anything. Also I was reading in functions_entries.inc.php about how to pass serendipity_fetchEntries specified categories using $serendipity['GET']['category']. How do I actually utilize this? I am guessing the passing parameters are the category ids not the names correct? In my plugin I added:

Code: Select all

$catss = "1;2";
$serendipity['GET']['category'] == $catss;

$entries = serendipity_fetchEntries('all');
but the results didn't change. Is this because I should be passing specific variables rather than the generic all? Any help would be greatly appreciated!

Thanks,
Evan
eburrows
Regular
Posts: 19
Joined: Fri May 05, 2006 11:28 pm

Disregard the question about category filtering

Post by eburrows »

The second part of my question I have managed to get working. I am not correctly grabbing the right entries using fetchEntries by setting $serendipity['GET']['category'] to the category ids that I want. The first part on what the field id for the category is when the fetchEntries array is returned though!
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Question about serendipity_fetchEntries

Post by garvinhicking »

Hi!

I suggest you to use print_r($entries) to see all available fields. There you should see $entry['categories'] as one of them. :)

Code: Select all

$catss = "1;2";
$serendipity['GET']['category'] == $catss;

$entries = serendipity_fetchEntries('all');
but the results didn't change. Is this because I should be passing specific variables rather than the generic all? Any help would be greatly appreciated!
It might be because you use this 'all' parameter, which is an invalid $range. See the PHPdoc comment for the fetchEntries function to see which variables you need to pass.

Also you might simply want to return the SQL code that the function would use, where you could check if your category ids appear. You can use the $returncode function variable to not return an array, but the SQL query instead.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply