0
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="'&quot;{cmsBlock}&quot;'"
        >
         <script>
           
            function cmsBlock(){
                cmsBlock{
                    cmsBlocks(identifiers: "footer_links") {
                        items {
                          identifier
                          title
                          content
                        }
                    }
                }
            }
        </script>
        </span>
        
    </div>
</div>
 
[![enter image description here][1]][1]

enter image description here

5
  • Can you please explain what your issue is, do you have any errors? Commented Mar 19, 2021 at 12:14
  • yes sure . this error is display : Uncaught ReferenceError: cmsblock is not defined Commented Mar 19, 2021 at 12:58
  • I am using this code in phtml file but as in console.log i am getting this error. Commented Mar 19, 2021 at 13:10
  • 1
    There 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. Commented Mar 19, 2021 at 13:13
  • 2
    Hi 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. Commented Mar 19, 2021 at 13:44

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.