예제 #1
0
 public function getPreviewHTML($template_id, $id = false)
 {
     // get item data
     if ($id) {
         $item = ListingsModel::getItem($id);
     } else {
         $item = WPLE_ListingQueryHelper::getItemForPreview();
     }
     if (!$item) {
         return '<div style="text-align:center; margin-top:5em;">You need to prepare at least one listing in order to preview a listing template.</div>';
     }
     // use latest post_content from product - moved to TemplatesModel
     // $post = get_post( $item['post_id'] );
     // if ( ! empty($post->post_content) ) $item['post_content'] = $post->post_content;
     // load template
     if (!$template_id) {
         $template_id = $item['template'];
     }
     $template = new TemplatesModel($template_id);
     $html = $template->processItem($item, false, true);
     // return html
     return $html;
 }