Magento Store - Remove Block using Update XML

后端 未结 2 504
太阳男子
太阳男子 2020-12-21 11:53

I am using this code in my template file to display a static block in my left sidebar:

getLayout()->createBlock(\'cms/block\')->setBlo         


        
2条回答
  •  南方客
    南方客 (楼主)
    2020-12-21 12:48

    Someone else can correct me here, but I'm fairly sure that you're going to have trouble trying to accomplish this given the way you called the block. Normal layout updates allow you to remove blocks, but those are blocks that were also created with the layout (e.g. the Layout object knows about them after you call loadLayout()).

    In your case, you create the block on the fly and then immediately use it to echo some HTML. If you want to be able to delete it with layout updates, try moving it into the layout files first, then use the normal layout block removal method:

    
       
    
    

    Otherwise, you could hide it either in the PHP (By setting some global variable and checking it before outputting the block. Poor form but it might work.) or in CSS. Let me know if any of these work for you.

    Thanks, Joe

提交回复
热议问题