I've installed the MageSpecialist reCAPTCHA module on my Magento 2 webshop.
The module is working perfectly fine on the default contact form, but the reCAPTCHA is not rendered on the custom cms page.
This is how I display the contact form on the custom cms page:
{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
I tried to add a code snippet from the layout section of the module contact_index_index to the cms page Layout Update XML.
<referenceContainer name="form.additional.info">
<block class="MSP\ReCaptcha\Block\Frontend\ReCaptcha" name="msp-recaptcha" after="-" template="MSP_ReCaptcha::msp_recaptcha.phtml">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="msp-recaptcha" xsi:type="array">
<item name="component" xsi:type="string">MSP_ReCaptcha/js/reCaptcha</item>
<item name="zone" xsi:type="string">contact</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceContainer>
This also did not help with trying to render the reCAPTCHA on the custom cms page.
Is there anyone who can help me out with this?
With the below code I was able to add Contact Us form in a CMS page along with the MSP reCaptcha on the form, Add the below code in Admin > Content > Pages > [CMS Page] > Add / Edit > Design > Layout Update XML:
<referenceContainer name="content">
<block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml">
<container name="form.additional.info" label="Form Additional Info"/>
</block>
</referenceContainer>
<referenceContainer name="form.additional.info">
<block class="MSP\ReCaptcha\Block\Frontend\ReCaptcha" name="msp-recaptcha" after="-"
template="MSP_ReCaptcha::msp_recaptcha.phtml">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="msp-recaptcha" xsi:type="array">
<item name="component" xsi:type="string">MSP_ReCaptcha/js/reCaptcha</item>
<item name="zone" xsi:type="string">contact</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceContainer>
Related
This is my code for adding top header links in magento 2.2.2 but as i am having multiple store's it is showing in all web site's top header but my requirement is to add this link in my default store top header...not in all the multi-store web-site's header
<referenceBlock name="header.links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="wholesale">
<arguments>
<argument name="label" xsi:type="string">New Link</argument>
<argument name="path" xsi:type="string">New Link</argument>
</arguments>
</block>
</referenceBlock>
I'm editing local.xml file to load some javascript, one of them is carosule.js and I want it only on my index page so I can use <cms_index_index> node but it is instantiated by init.js. How can I load them in an order I want?
<cms_index_index>
<reference name="head">
<action method="addItem">
<type>skin_js</type>
<name>js/mycaro.js</name>
</action>
</reference>
</cms_index_index>
<default>
<reference name="head">
<action method="addItem">
<type>skin_js</type>
<name>js/jquery.min.js</name>
</action>
<action method="addItem">
<type>skin_js</type>
<name>js/init.js</name>
</action>
</reference>
</default>
Currently it is loading in this order
<script type="text/javascript" src="http://localhost/m/skin/frontend/hs1st/default/js/jquery.min.js"></script>
<script type="text/javascript" src="http://localhost/m/skin/frontend/hs1st/default/js/init.js"></script>
<script type="text/javascript" src="http://localhost/m/skin/frontend/hs1st/default/js/mycaro.js"></script>
The loading of the plugin should not depend on the order of loading of the files. You need to trigger the loading of the plugin when the DOM has finished loading to be sure all the necessary files are loaded.
Let's say init.js contains something like this;
jQuery('#carousel').Carousel({option:optionvalue});
You'll want to wrap it in code to run when the DOM has finished loading, like this;
jQuery(window).ready(function () {
jQuery('#carousel').Carousel({option:optionvalue});
});
See https://api.jquery.com/ready/
I was getting a SQLSTATE [42000] access violation: 1064 error only when clicking on a product page.
I located the problem in local.xml and it had something to do with this specific block:
<!-- List Products by category in the main area-->
<reference name="content">
<block type="catalog/product_list" name="featured" after="header.image" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>202</category_id></action>
<action method="setColumnCount"><columns>4</columns></action>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
</block>
</reference>
Can someone explain what I did wrong and why it's doing this? I'm trying to list a few products on the homepage while hiding the product list toolbar.
Thanks!
So, unfortunately local.xml is meant to have datebase configuration and stuff like that.
Configuration about the layout should be put in a layout.xml and you have to wrap it in a layout-tag like that:
<?xml version="1.0"?>
<layout version="0.1.0">
<reference name="content">
<block type="catalog/product_list" name="featured" after="header.image" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>202</category_id></action>
<action method="setColumnCount"><columns>4</columns></action>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
</block>
</reference>
</layout>
I found the answer. I had the block wrapped in:
<layout version="0.1.0">
<default>
<!--block here-->
</default>
</layout>
When it needed to be in:
<layout version="0.1.0">
<cms_index_index>
<!--block here-->
</cms_index_index>
</layout>
This ended up fixing the problem of getting a SQLSTATE syntax error when clicking into a product page.
Google Analytics stopped working as i upgrade the Magento 1.6 to Magento 1.7.
Really Stuck what to do, i have already
reference name="after_body_start">
<block type="googleanalytics/ga" name="google_analytics" as="google_analytics" template="googleanalytics/ga.phtml" />
</reference>
in my googleanalytics.xml
Not able to set it properly for Magento 1.7.
Add a tag template="googleanalytics/ga.phtml" in the layout/googleanalytics.xml
<layout version="0.1.0">
<!--
Default layout, loads most of the pages
-->
<default>
<!-- Mage_GoogleAnalytics -->
<reference name="after_body_start">
<block type="googleanalytics/ga"
name="google_analytics"
as="google_analytics"
template="googleanalytics/ga.phtml" />
</reference>
</default>
</layout>
Magento doesn't want to look in my theme folder for these JS files when I use this code in local.xml
<!-- /app/design/frontend/my-theme/default/layout/local.xml -->
<xml>
<cms_page>
<reference name="head">
<action method="addItem"><type>skin_js</type><name>my.js</name><params/></action>
</reference>
</cms_page>
</xml>
This results in
<head>
<script src="http://example.com/skin/frontend/base/default/my.js" />
</head>
whereas if I where to put the same XML code within the "default" xml tag it loads correctly. i.e....
<!-- /app/design/frontend/my-theme/default/layout/local.xml -->
<xml>
<default>
<reference name="head">
<action method="addItem"><type>skin_js</type><name>my.js</name><params/></action>
</reference>
</default>
</xml>
loads...
<head>
<script src="http://example.com/skin/frontend/MYTHEME/default/my.js" />
</head>
<!-- Emphasis Added -->
The problem is that I only want to load this script for cms_pages. Is this impossible?
Using Magento 1.6 ~ The and yes, I've cleared the cache ;)
Oh, and my design configuration ( admin > configuration > design ) has "package" set to "my-theme", and the "default" set to "default"
The reason it ends up using the wrong URL when loading CMS pages is likely that you have a custom theme set on that CMS page.
The custom theme you define on a per-page level overrides the normal theme when the CMS page is rendered.
Check your CMS page settings under the custom design section.