You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo "PAR PAGE : " . $response->perPage() . PHP_EOL;
216
234
217
-
$data = $response->data();
218
-
echo "Stories found with the page: " . $data->howManyStories() . PHP_EOL;
219
-
foreach ($data as $key => $story) {
220
-
echo $story->get("id") . " " .
235
+
$stories = $response->data();
236
+
echo "Stories found with the page: " . $stories->howManyStories() . PHP_EOL;
237
+
foreach ($stories as $key => $story) {
238
+
echo $story->id() . " " .
221
239
$story->getName() . PHP_EOL;
222
240
}
223
241
```
224
242
225
243
### Filtering stories
226
244
You can filter stories using `StoriesParams`.
227
245
246
+
> The `StoriesParams` attributes are documented in the `Query Parameters` of [Retrieving multiple stories](https://www.storyblok.com/docs/api/management/core-resources/stories/retrieve-multiple-stories)
247
+
228
248
```php
229
249
use Storyblok\ManagementApi\Endpoints\StoryApi;
230
250
231
251
$storyApi = new StoryApi($client, $spaceId);
232
252
$stories = $storyApi->page(
233
-
new StoriesParams(containComponent: "feature"),
234
-
new PaginationParams(1, 1000)
235
-
);
253
+
new StoriesParams(containComponent: "hero-section"),
254
+
page: new PaginationParams(2, 10)
255
+
)->data();
256
+
echo "Stories found: " . $stories->count();
257
+
echo " STORY : " . $stories->get("0.name") . PHP_EOL;
258
+
236
259
```
237
260
238
261
### Filtering stories via query filters
@@ -244,17 +267,17 @@ Besides using query parameters to filter stories, you can leverage more powerful
244
267
In this example, you will retrieve all stories where the "title" field is empty. (Stories with content types that do not include a "title" field in their schema will be skipped.)
245
268
246
269
```php
247
-
use Storyblok\ManagementApi\QueryParameters\Filters\Filter;
248
270
use Storyblok\ManagementApi\Endpoints\StoryBulkApi;
271
+
use Storyblok\ManagementApi\QueryParameters\Filters\Filter;
249
272
use Storyblok\ManagementApi\QueryParameters\Filters\QueryFilters;
250
273
251
274
$storyBulkApi = new StoryBulkApi($client, $spaceId);
To create a story, you can call the `create()` method provided by `StoryApi` and use the `StoryData` class. The `StoryData` class is specific for storing and handling story information. It also provides some nice methods for accessing some relevant Story fields.
0 commit comments