enter code <div class="bg-container border-t border-b border-container">
<div class="container px-5 py-6 mx-auto flex items-center sm:flex-row flex-col"
x-data="cmsblock()"
x-init="fetch('http://127.0.0.1:96/magento2test/graphql')
.then(response => response.json())
.then(data =>cmsBlock = data.cmsBlock)
"
>
<span class="ml-3 text-xl"
x-data="'"{cmsBlock}"'"
>
<script>
function cmsBlock(){
cmsBlock{
cmsBlocks(identifiers: "footer_links") {
items {
identifier
title
content
}
}
}
}
</script>
</span>
</div>
</div>
[![enter image description here][1]][1]
-
Can you please explain what your issue is, do you have any errors?Ben Crook– Ben Crook2021-03-19 12:14:50 +00:00Commented Mar 19, 2021 at 12:14
-
yes sure . this error is display : Uncaught ReferenceError: cmsblock is not definedMehulKanjariya– MehulKanjariya2021-03-19 12:58:26 +00:00Commented Mar 19, 2021 at 12:58
-
I am using this code in phtml file but as in console.log i am getting this error.MehulKanjariya– MehulKanjariya2021-03-19 13:10:12 +00:00Commented Mar 19, 2021 at 13:10
-
1There are several issues with this, I advise you study Alpine JS and compare what you have done with hyva-themes/magento2-default-theme/Magento_Theme/templates/elements/slider.phtml If I get time I'll go through it later.Ben Crook– Ben Crook2021-03-19 13:13:52 +00:00Commented Mar 19, 2021 at 13:13
-
2Hi Mehul. By the looks of that code snippet, you might be trying to get this to work in Hyvä Themes. I'd like to point out that we have excellent support for these kind of questions on our Slack. You should have access to that if you're working with a valid license for Hyvä. If you're working on behalf of a merchant that purchased a license, please ask them to request access to support, we'll be happy to help you with this question.willem wigman– willem wigman2021-03-19 13:44:52 +00:00Commented Mar 19, 2021 at 13:44
Add a comment
|
1 Answer
You need to pass right string/identifiers: ["footer_links_block"]
{
cmsBlocks(identifiers: ["footer_links_block"]) {
items {
content
identifier
title
}
}
}
Response
{
"data": {
"cmsBlocks": {
"items": [
{
"content": "<ul class=\"footer links\">\n <li class=\"nav item\"><a href=\"http://magento.local/index.php/about-us/\">About us</a></li>\n <li class=\"nav item\"><a href=\"http://magento.local/index.php/customer-service/\">Customer Service</a></li>\n</ul>\n",
"identifier": "footer_links_block",
"title": "Footer Links Block"
}
]
}
}
}
this will resolve your problem.
