Magento:Fishpig/Wordpress 扩展无法解析帖子页面上的 local.xml

发布于 2024-12-29 08:00:43 字数 546 浏览 3 评论 0原文

因此,大约一个月前,我在 Magento 网站上安装了 Fishpigs Wordpress 扩展,一切运行良好。上周,不知何故,格式发生了混乱。追踪问题所在,我发现帖子页面停止使用我的自定义 .phtml 布局(“wordpress.phtml”)。不过,所有其他与 WordPress 相关的页面都正确使用了该模板。

我已经添加到

<wordpress_default>
    <reference name="root">
        <action method="setTemplate"><template>page/wordpress.phtml</template></action>
    </reference>
</wordpress_default>

我的 local.xml 中,一切都很好。今天,我什至尝试在扩展设置中设置所有布局和相同的交易,只有帖子页面未呈现正确的布局。这是一个奇怪的问题,我不知道从哪里开始寻找......

So I setup Fishpigs Wordpress extension about a month ago on my Magento site and all was working well. Somewhere, somehow in the last week the formatting went haywire. Tracking down what went wrong, I found that the post pages stopped using my custom .phtml layout ('wordpress.phtml'). All other wordpress related pages use the template properly though.

I had added

<wordpress_default>
    <reference name="root">
        <action method="setTemplate"><template>page/wordpress.phtml</template></action>
    </reference>
</wordpress_default>

in my local.xml and all was good. Today I even tried setting all the layouts in the extension settings and same deal, only the post page isn't rendering the correct layout. This is a strange problem, I'm not sure where to start looking...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月蹉跎了容颜 2025-01-05 08:00:43

我在这里看到三种可能性(假设您已经执行了清除缓存存储的神圣仪式)

  1. 对帖子页面的请求未加载您的 local.xml 文件,可能是因为它使用不同的主题和/或设计包

  2. 帖子页面未发布wordpress_default 句柄,因此尽管包含您的 local.xml 文件,但您的 setTemplate 操作永远不会被调用

  3. 有一个在布局之后调用的布局更新更新(通过 XML 或直接在 PHP 代码中),将根模板设置为其他内容。

调查这三项中的每一项,您应该找到答案。

关于选择 #3,我没有安装 FishPig 扩展,也没有广泛使用它,但看起来该扩展在 ViewController.php 中做了一些调整来自动设置如果 WordPress 页面对象(?我不知道这是什么)有一个字段设置为 'onecolumn' ,则模板为 page/1column.phtml'1column'

parent::loadLayout($handles, $generateBlocks, $generateXml);    

if ($this->_getPage()) {
    $keys = array('onecolumn', '1column');
    $template = $this->_getPage()->getCustomField('_wp_page_template');

    foreach($keys as $key) {
        if (strpos($template, $key) !== false) {
            if ($rootBlock = $this->getLayout()->getBlock('root')) {
                $rootBlock->setTemplate('page/1column.phtml');
            }

            break;
        }
    }
}

我会开始在那里寻找。

I see three possibilities here (assuming you've already performed the holy rite of clearing your cache storage)

  1. The request for the post page isn't loading your local.xml file, possibly because its using a different theme and/or design package

  2. The post page isn't issuing the wordpress_default handle, so although your local.xml file is being included, your setTemplate action is never called

  3. There is a layout update that's called after your layout update (either via XML or directly in PHP code) which sets the root template to something else.

Investigate each of these three items and you should find your answer.

Regarding choice #3, I don't have an installation with the FishPig extension installed and haven't used it extensively, but it looks like the extension does some jiggery pokery in ViewController.php to automatically set the template to page/1column.phtml if the wordpress page object (? I don't know what this is) has a field set to 'onecolumn' or '1column'.

parent::loadLayout($handles, $generateBlocks, $generateXml);    

if ($this->_getPage()) {
    $keys = array('onecolumn', '1column');
    $template = $this->_getPage()->getCustomField('_wp_page_template');

    foreach($keys as $key) {
        if (strpos($template, $key) !== false) {
            if ($rootBlock = $this->getLayout()->getBlock('root')) {
                $rootBlock->setTemplate('page/1column.phtml');
            }

            break;
        }
    }
}

I'd start looking there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文