Silverstripe静态出版商打破表单提交

时间:2014-01-16 04:14:42

标签: php forms caching silverstripe

我的网站运行正常,直到我启用static publisher并且所有表单提交都失败,我得到以下内容:

  

似乎存在技术问题。请单击后退按钮,刷新浏览器,然后重试。

以前有人遇到过这个吗?

3 个答案:

答案 0 :(得分:1)

如果您使用的是用户定义表单,则此模块为not compatible with Static Publisher

您需要从要包含在静态发布者中的页面列表中排除UserDefinedForm页面。

exclude UserDefinedForm page from the static publisher$ignored = array('UserDefinedForm');添加到allPagesToCache()功能:

public function allPagesToCache() {
    $urls = array();
    $pages = SiteTree::get();

    // ignored page types
    $ignored = array('UserDefinedForm');

    foreach($pages as $page) {
        // check to make sure this page is not in the classname
        if(!in_array($page->ClassName, $ignored)) {
            $urls = array_merge($urls, (array)$page->subPagesToCache());
        }
    }

    return $urls;
}

答案 1 :(得分:1)

除了@ 3dgoo的上述内容之外,如果在您已经运行静态发布者之后添加了一个被忽略的类,则不会删除旧的高速缓存文件,这可能会导致无法预料的问题。

为了解决这个问题,我建议用以下内容重写上述条件:

...
if(!in_array($page->ClassName, $ignored)) {
    $urls = array_merge($urls, (array)$page->subPagesToCache());
} else {
    //If ignored, unpublish from Cache
    $page->unpublishPages($page->subPagesToCache());
}

答案 2 :(得分:1)

您还需要在subPagesToCache()

中排除页面
class Page extends SiteTree {
    var $ignoredPagesToCache = array('UserDefinedForm');

    ::

    public function subPagesToCache() {
        $urls = array();
        // add current page
        if(!in_array($this->ClassName, $this->ignoredPagesToCache)) {
            $urls[] = $this->Link();
        }
        ::
        return $urls;
    }
}