Recently on the nopCommerce user forums, a developer wanted to grasp how to implement a popup site-wide for users visiting the website for the first time. varied industries will create use of this; sites that offer adult novelty products, desire to confirm age, or any website that wants to inform site visitors of the advantages of registering with the site. nopCommerce team member haydie offered an imaginative solution; re-use the code for the EU cookie pop-up that’s presently implemented in nopCommerce. Let’s take a glance at how that would work.
The EU cookie law affects websites that originate in any EU member country; recent changes in however the law is interpreted has rendered the requirement to get consent from site visitors to use cookies to be converted into “implied consent”. However, since the code is already enforced in nopCommerce, it’s a straightforward matter to copy the code, or if your site’s not impacted by this law, to easily modify the existing code.
You’ll find the relevant source code in Nop.Web/Views/Common/EuCookieLaw.cshtml, and Nop.Web/Views/Common/EuCookieLaw.Mobile.cshtml.
Let’s open up EuCookieLaw.cshtml and have a look. I’ll skip over the javascript functions for the moment, and focus on the content section:
<div id="dialog-eu-cookie-law" title="@T("EUCookieLaw.Title")" style="display:none;" class="eu-cookie-law">
<div>
@T("EUCookieLaw.Description") (<a id="eu-cookie-privacyinfo-tag" href="javascript:toggleEuCookiePrivacyInfo();" class="eu-cookie-privacyinfo-tag">@T("Common.Show")</a>)
</div>
<div class="clear">
</div>
<div id="eu-cookie-law-privacyinfo" style="display: none;">
@Html.Action("TopicBlock", "Topic", new { systemName = "privacyinfo" })
</div>
</div>
<div>
@T("EUCookieLaw.Description") (<a id="eu-cookie-privacyinfo-tag" href="javascript:toggleEuCookiePrivacyInfo();" class="eu-cookie-privacyinfo-tag">@T("Common.Show")</a>)
</div>
<div class="clear">
</div>
<div id="eu-cookie-law-privacyinfo" style="display: none;">
@Html.Action("TopicBlock", "Topic", new { systemName = "privacyinfo" })
</div>
</div>
We can see that the titles “EUCookieLaw.Description” and “Common.Show”, and therefore the topic “privacyinfo” comprise the content that’s showed the site users; let’s log into our nopCommerce instance, and access that info. Edit the topic and titles to reflect the message you wish to point out your web site guests.
Now under Configuration/Settings/General and Miscellaneous Settings, check “Display EU cookie law warning: “, and click on “Save”. Restart your application, and visit your web site in a new browser window. You’ll currently see your new pop-up displayed – easy, and extremely effective!
0 comments:
Post a Comment