页脚缓存解决方法......什么是正确的方法来做到这一点?
我的 footer.phtml 中有以下代码块,
<!-- Customer Modal -->
<?php if (array_key_exists("customer_select", $_COOKIE) == FALSE ): ?>
<script type="text/javascript" src="<?=$this->getSkinUrl('js/jqModal.js')?>"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#customer_type_dialog").jqm().jqmShow();
});
</script>
<?php include("../../templates.eu/templates.sbc.de/_includes/customer_select.php"); ?>
<?php endif; ?>
当我打开块缓存时,它会停止评估它,仅返回缓存的值。我该如何解决这个问题或者有什么更好的方法来做到这一点?基本上我正在检查 cookie 是否存在,如果存在,我将向页面添加一些 js 和另一个文件。
I have the following chunk of code in my footer.phtml
<!-- Customer Modal -->
<?php if (array_key_exists("customer_select", $_COOKIE) == FALSE ): ?>
<script type="text/javascript" src="<?=$this->getSkinUrl('js/jqModal.js')?>"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#customer_type_dialog").jqm().jqmShow();
});
</script>
<?php include("../../templates.eu/templates.sbc.de/_includes/customer_select.php"); ?>
<?php endif; ?>
When I turn on the block caching it stops evaluating this an only returns the value that was cached. HOw do I work around this problem or what is a better way to do this? Basically I'm checking to see if a cookie exists and if it does I'm adding some js and another file to the page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将上面的代码放入它自己的模板文件中并更改布局:
这样页脚就会被缓存(这有助于保持页面快速)并且每次都会评估您的 cookie 检查。此外,Javascript 会保留到页面的最后一个可能的位置,这是内联脚本的最佳实践。
Put the above code in it's own template file and make this layout change:
This way the footer gets to be cached (which helps keep pages fast) and your cookie check is evaluated each time. Also the Javascript is left until the last possible point of the page which is a best practice for inline scripts.