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
Now that we've seen how to programmatically create a story (content) with fields like title, body, and image, let's dive deeper into handling nested components.
610
+
611
+
### Scenario
612
+
613
+
You have a `default-page` content type that includes a *Blok* field. The *Blok* field allows you to nest components within your content. This means you can add a *Hero Section* component, followed by an *Image Text Section* component, and so on.
614
+
615
+
### Goal
616
+
The objective is to:
617
+
618
+
- Set up a *Hero Section* component.
619
+
- Set up an *Image Text Section* component.
620
+
- Add these components to a story.
621
+
622
+
To demonstrate deeper levels of nesting, we will also set up a *Button* component and nest it within the *Image Text Section* component.
623
+
624
+
```php
625
+
626
+
$client = new ManagementApiClient("yourpersonalaccesstoken");
627
+
$spaceId = "yourspaceid";
628
+
$storyApi = new StoryApi($client, $spaceId);
629
+
630
+
// Setting up the hero-section
631
+
$heroSection = new StoryComponent("hero-section");
632
+
$heroSection->set("headline", "Hello World");
633
+
// We are going to setup an external image as background
0 commit comments