将Wordpress与Symfony集成 [英] integrating Wordpress with Symfony

查看:116
本文介绍了将Wordpress与Symfony集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Symfony 1.2构建的网站.我正在尝试将Wordpress 2.8.4集成到其中以增强我的博客的功能.我按照 http://www.theodo上的说明进行操作. fr/blog/2009/03/integrate-wordpress-into-symfony/,包括

I have a site built with Symfony 1.2. I'm trying to integrate Wordpress 2.8.4 into it to power my blog. I followed the instructions at http://www.theodo.fr/blog/2009/03/integrate-wordpress-into-symfony/, including the 2 steps in the comments at http://www.theodo.fr/blog/2009/03/integrate-wordpress-into-symfony/comment-page-1/#comment-573. My actions.class.php file looks like this:

 <?php
 class sfWordpressActions extends sfActions
 {
   public function executeIndex(sfWebRequest $request)
   {

     // Don't load symfony's I18N
     $standard_helpers = sfConfig::get('sf_standard_helpers');
     $standard_helpers = array_diff($standard_helpers, array('I18N'));
     sfConfig::set('sf_standard_helpers', $standard_helpers);

     define('WP_USE_THEMES', true);
     chdir( dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'wordpress' );
     global $wpdb;

     ob_start();
     require_once( 'wp-blog-header.php' );
     $this->blog = ob_get_contents();
     if (function_exists('is_feed') && is_feed())
     {
       ob_end_flush();
       throw new sfStopException();
     }
     else
     {
       ob_end_clean();
     }
   }
 }
    ?>

我的indexSuccess.php很简单

My indexSuccess.php is simply

This is a test
<?php echo $blog ?>

我的wp-blog-header.php是

And my wp-blog-header.php is

<?php
/**
 * Loads the WordPress environment and template.
 *
 * @package WordPress
 */

if ( !isset($wp_did_header) ) {
  $wp_did_header = true;

  require_once( dirname(__FILE__) . '/wp-load.php' );

  // @HACK FABRICE
  // All variables defined here are considered global by Wordpress
  $local_global_vars = get_defined_vars();
  foreach($local_global_vars as $local_name => $local_value)
  {
    $GLOBALS[$local_name] = $local_value;
  }
  // Don't create new global variables ourselves, and do not overwrite other global variables, for example $name...
  unset($local_name, $local_value, $local_global_vars);
  // @HACK FABRICE

  wp();

  // @HACK Fabrice
  global $posts;
  // @HACK Fabrice

  require_once( ABSPATH . WPINC . '/template-loader.php' );
}

这是我的问题:

按原样,我转到该页面时一无所获.我的Symfony标头都没有,Wordpress内容也没有,什么都没有.当我注释掉"require_once('wp-blog-header.php');"行时在actions.class.php中,一切正常,但没有Wordpress内容.这使我相信Symfony在包含Wordpress内容的过程中正在消亡.该如何解决?

As it is, I get nothing when I go to the page. None of my Symfony headers, no Wordpress content, nothing. When I comment out the line "require_once( 'wp-blog-header.php' );" in actions.class.php, everything works fine but there is no Wordpress content. This leads me to believe that that Symfony is dying somewhere in the process of including the Wordpress stuff. How this might be fixed?

推荐答案

我已经在theodo.fr上写了一篇有用的文章的后续指南,该文章可与WordPress的最新版本一起使用并具有升级步骤: http://blog.codeclarity.com/2009/12/02 /integrating-symfony-and-wordpress/.我相信您的冲突是Symfony和WordPress定义的esc_js函数.如果您在第4步中运行我的命令,那么最好使用最新版本.希望有帮助.

I've written a follow-up guide to the helpful article on theodo.fr that works with the latest versions of WordPress and has steps for upgrading: http://blog.codeclarity.com/2009/12/02/integrating-symfony-and-wordpress/. I believe your conflict is the esc_js function defined by both Symfony and WordPress. If you run my command in step 4 you should be good to go with the latest version. Hope that helps.

这篇关于将Wordpress与Symfony集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆