Magento CE:如何根据屏幕分辨率改变php文件内块的位置


Magento CE: How to change position of block inside phtml file depending on screen resolution

我想根据使用javascript的屏幕分辨率在view.phtml内切换块container2的位置。

catalog.xml

<catalog_product_view translate="label">
...
    <reference name="content">
        <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
        ...
            <block type="core/template_facade" name="product.info.container2" as="container2">
                <action method="setDataByKey"><key>alias_in_layout</key><value>container2</value></action>
                <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action>
                <action method="append"><block>product.info.options.wrapper</block></action>
                <action method="append"><block>product.info.options.wrapper.bottom</block></action>
            </block>
        ...
        </block>
    </reference>
</catalog_product_view>

view.phtml:

如果分辨率<?php echo $this->getChildHtml('media') ?>后的位置>

<div class="mobile">
    <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
</div>

else:它必须保持在默认位置。

在javascript中类似于:

width = document.viewport.getWidth();

必须有ajax请求和响应与post变量。但我不确定在哪个地方以及如何将它们结合在一起?

对于低于1.9的版本,可以在后端通过按照一些标准配置不同类型的设计来设置。

在这里解释了为移动设备制作它的方法。

对于这些版本,如果你配置正确,twitter bootstrap工作得很好。

为1.9,RWD包含在基础…

希望有帮助,