Closed lphilippo closed 1 year ago
Hi @lphilippo thanks for the question...
Elgentos\PrismicIO\Block\StaticBlock
is just a document loader...
Within the block you need to add the actual template or groups or slices.
If you just want to test if the document is loaded correctly and if your store is in developer mode.
<block class="Elgentos\PrismicIO\Block\StaticBlock">
<arguments>
<argument name="data" xsi:type="array">
<item name="identifier" xsi:type="string">home-page</item>
<item name="content_type" xsi:type="string">homepage</item>
</argument>
</arguments>
<block class="Elgentos\PrismicIO\Block\Debug">
</block>
This should show up as debug information in the frontend.
A more complete example would be:
A static block in Prismic with:
title
Rich text fieldtext
<- name for the slice
awesome
Rich text field<block class="Elgentos\PrismicIO\Block\StaticBlock">
<arguments>
<argument name="data" xsi:type="array">
<item name="identifier" xsi:type="string">home-page</item>
<item name="content_type" xsi:type="string">homepage</item>
</argument>
</arguments>
<block class="Elgentos\PrismicIO\Block\Template" template="Elgentos_PrismicIO::component/static_block.phtml">
<block class="Elgentos\PrismicIO\Block\Dom\RichText" template="data.title" as="title" />
<block class="Elgentos\PrismicIO\Block\Slices" template="data.body" name="static_block.slices" as="slices" />
<block class="Elgentos\PrismicIO\Block\Container" name="static_block.slices.text">
<block class="Elgentos\PrismicIO\Block\Dom\RichText" template="primary.awesome" />
</block>
</block>
</block>
</block>
component/static_block.phtml
<div>
<?= $block->getChildHtml('title'); ?>
</div>
<div>
<?= $block->getChildHtml('slices'); ?>
</div>
@JeroenBoersma that's an amazing answer! Could you add that to this repo's readme maybe so more people can find it?
Ah brilliant! This example definitely helps a lot and it solved some doubts we had about whether certain parts where the responsibility of Magento or Prismic
ok the most hard thing to understand is what is needed for successful request and that every document needs a uid added manually. thats a really static process , you already add a title to document and will duplicate that data for uid in prismic just to connect the dots . But great example explains a lot
Hello,
We're struggling with an issue that is probably and hopefully quite straightforward.
In order to try out he integration with Prismic.io, we have created a custom type and published a single content item.
We then only intend to display it as a StaticBlock, by using:
Unfortunately the output is empty.
By tracing the logic in
StaticBlock.php
we do see that the document information is correctly received (infetchChildDocument()
), but$this->getChildNames()
consequently returns an empty array.In the document data that we see, we also seem to be missing anything that indicates the design (for example, HTML and CSS).
Would you happen to know what obvious part we are missing or skipping here? The module version we're working with is
1.9.2
, Magento 2.4.5 and a Hyva-based theme (should not be relevant, but just in case)