php - How to convert Wordpress post_content into Laravel view? -


i've been using laravel application development have found wordpress great @ bootstrapping high quality views through multitude of amazing themes, widgets, , customization options.

having laravel , wordpress work side-by-side has been simple setup excellent guide @ http://grossi.io/2014/working-with-laravel-4-and-wordpress-together/

the question how hook wp's html/css/js generation functions can bring content laravel view post_id. here's typical data want convert:

post_content = <code>[fullwidth backgroundcolor="" backgroundimage="" backgroundrepeat="no-repeat"]          </code> <h1 style="text-align: center; font-size: 30px !important;">test test<span       style="color: #e9a825;"> #1 </span>testing testing</h1> <p style="text-align: center; margin-top: -10px; font-size: 17px !important;">with on [tooltip   title="stack overflow awesome"]<strong>yeah!</strong>[/tooltip]more [tooltip title="abc"]<strong>test</strong>  [/tooltip] test.</p> [/fullwidth] 

the goal generation internally in laravel if possible since ideally i'd inject custom data laravel app queried post content before generating html/css/js pass onto view.

i have found solution works me. added code basecontroller. use follows:

echo $this->_get_wp_post(123);  public function _get_wp_post($post_id) {     ob_start();     get_header();     $header = ob_get_contents();     ob_end_clean();      ob_start();              $content = '';     global $post;     $post  = get_post($post_id);     setup_postdata($post);     the_content();     $content = ob_get_contents();     wp_reset_postdata();     ob_end_clean();      ob_start();     get_footer();     $footer = ob_get_contents();     ob_end_clean();      return $header . $content . $footer; } 

a caveat: tweaking might required elements custom themes work expected and/or eliminate laravel exceptions.

hope helpful somebody.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -