如何使用 Javascript 将 IF 语句添加到 Magento CMS 页面
我需要在 Magneto CMS 页面中放置一个条件语句,以便仅在满足条件时处理静态块。
我只有非常基本的 javascript 知识,并且不确定如何在 javascript 条件语句中包含 Magneto 静态块处理。据我所知:
<script type="text/javascript">
if (location.href.substring(0,5)!='https')
{
{{block type="cms/block" block_id="leaderboard"}}
}
</script>
How do I Tell javascript to process the "{{block type="cms/block" block_id="leaderboard"}}" bit?
另外,使用 javascript 是将条件语句添加到 Magento CMS 页面的最佳方法吗?
I need to place a conditional statement in a Magneto CMS Page to process a static block only if the condition is met.
I only have very basic knowledge of javascript and am unsure how to include the Magneto static-block processing within the javascript conditional statement. This is as far as I have got:
<script type="text/javascript">
if (location.href.substring(0,5)!='https')
{
{{block type="cms/block" block_id="leaderboard"}}
}
</script>
How do I tell the javascript to process the "{{block type="cms/block" block_id="leaderboard"}}" bit?
Also, is using javascript the best way to add a conditional statement to a Magento CMS page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法在 JavaScript 中执行此操作。 JavaScript 在客户端 Web 浏览器上运行,但您需要在服务器上更改它。
您需要闯入 Magento 内部的模板 PHP 代码。
You can't do this in JavaScript. JavaScript runs on the client Web browser, but you need to alter this at the server.
You'll need to break into the template PHP code inside of Magento.