<div class="post"> <?php echo fuel_edit($post->id, 'Edit Post', 'blog/posts'); ?> <?php echo blog_block('post_unpublished', array('post' => $post)); ?> <h1><?php echo $post->title; ?> </h1> <div class="post_author_date"> Posted on <span class="post_content_date"><?php echo $post->get_date_formatted(); ?> </span> by <span class="post_author_name"><?php echo $post->author_name; ?> </span> </div> <div class="post_content"> <?php echo $post->content_formatted; ?> </div> </div>
function post($permalink = null) { if (empty($permalink)) { show_404(); } $this->load->library('session'); $blog_config = $this->config->item('blog'); $post = $this->fuel_blog->get_post($permalink); if (isset($post->id)) { $vars = $this->_common_vars(); $vars['post'] = $post; $vars['user'] = $this->fuel_blog->logged_in_user(); $vars['page_title'] = $post->title; $vars['next'] = $this->fuel_blog->get_next_post($post); $vars['prev'] = $this->fuel_blog->get_prev_post($post); $antispam = md5(random_string('unique')); $field_values = array(); // post comment if (!empty($_POST)) { $field_values = $_POST; // the id of "content" is a likely ID on the front end, so we use comment_content and need to remap $field_values['content'] = $field_values['new_comment']; unset($field_values['antispam']); if (!empty($_POST['new_comment'])) { $vars['processed'] = $this->_process_comment($post); } else { add_error(lang('blog_error_blank_comment')); } } $cache_id = fuel_cache_id(); $cache = $this->fuel_blog->get_cache($cache_id); if (!empty($cache) and empty($_POST)) { $output =& $cache; } else { $this->load->library('form'); if (is_true_val($this->fuel_blog->settings('use_captchas'))) { $captcha = $this->_render_captcha(); $vars['captcha'] = $captcha; } $vars['thanks'] = $this->session->flashdata('thanks') ? blog_block('comment_thanks', $vars, TRUE) : ''; $vars['comment_form'] = ''; $this->session->set_userdata('antispam', $antispam); if (is_true_val($this->fuel_blog->settings('allow_comments'))) { $this->load->module_model(BLOG_FOLDER, 'blog_comments_model'); $this->load->library('form_builder', $blog_config['comment_form']); $fields['author_name'] = array('label' => 'Name', 'required' => TRUE); $fields['author_email'] = array('label' => 'Email', 'required' => TRUE); $fields['author_website'] = array('label' => 'Website'); $fields['new_comment'] = array('label' => 'Comment', 'type' => 'textarea', 'required' => TRUE); $fields['post_id'] = array('type' => 'hidden', 'value' => $post->id); $fields['antispam'] = array('type' => 'hidden', 'value' => $antispam); if (!empty($vars['captcha'])) { $fields['captcha'] = array('required' => TRUE, 'label' => 'Security Text', 'value' => '', 'after_html' => ' <span class="captcha">' . $vars['captcha']['image'] . '</span><br /><span class="captcha_text">' . lang('blog_captcha_text') . '</span>'); } // now merge with config... can't do array_merge_recursive' foreach ($blog_config['comment_form']['fields'] as $key => $field) { if (isset($fields[$key])) { $fields[$key] = array_merge($fields[$key], $field); } } if (!isset($blog_config['comment_form']['label_layout'])) { $this->form_builder->label_layout = 'left'; } if (!isset($blog_config['comment_form']['submit_value'])) { $this->form_builder->submit_value = 'Submit Comment'; } if (!isset($blog_config['comment_form']['use_form_tag'])) { $this->form_builder->use_form_tag = TRUE; } if (!isset($blog_config['comment_form']['display_errors'])) { $this->form_builder->display_errors = TRUE; } $this->form_builder->form_attrs = 'method="post" action="' . site_url($this->uri->uri_string()) . '#comments_form"'; $this->form_builder->set_fields($fields); $this->form_builder->set_field_values($field_values); $this->form_builder->set_validator($this->blog_comments_model->get_validation()); $vars['comment_form'] = $this->form_builder->render(); $vars['fields'] = $fields; } $output = $this->_render('post', $vars, TRUE); // save cache only if we are not posting data if (!empty($_POST)) { $this->fuel_blog->save_cache($cache_id, $output); } } if (!empty($output)) { $this->output->set_output($output); return; } } else { show_404(); } }