We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

When retrieving a ChannelEntry from a Model, there's no data for any grid fields. How get that?

Development and Programming

dmDev08's avatar
dmDev08
100 posts
9 years ago
dmDev08's avatar dmDev08

When I query the Model service for a ChannelEntry, the grid fields show as empty. However, if I query for a ChannelEntryVersion, that does have grid data under “version_data”. But after publishing the entry, I need to look at the ChannelEntry (as that’s now the latest) but I cannot find any grid data in there. Why would it be empty for an entry?

The ChannelEntryVersion->version_data->field_id_8 has the grid rows, but no where in the ChannelEntry are the grid rows (I output the var_dump( $entry ) to a file and the grid data’s not in there).

All I see in the entry is “field_id_8” => ” “, “field_ft_8” = “xhtml”.

How do I get a grid field’s data from the model service?

$entry = ee( "Model" )->get( "ChannelEntry" )
    ->filter( "channel_id", $channelId )
    ->filter( "entry_id", $entryId )
    ->filter( "status", "IN", array( "open" ) )
    ->first();

EDIT:

If I do the query with “Versions”, then I find that data under $entry->Versions[ 0 ]->version_data. Is that correct? Is that the latest, published data?

$entry = ee( "Model" )->get( "ChannelEntry" )
    ->with( "Versions" )
    ->filter( "channel_id", $channelId )
    ->filter( "entry_id", $entryId )
    ->filter( "status", "IN", array( "open" ) )
    ->first();  

//Grid data now in here:
$entry->Versions[ 0 ]->version_data
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.