<?php if (!empty($archives_by_month)) { foreach ($archives_by_month as $month => $archives) { $month_str = date('F Y', strtotime(str_replace('/', '-', $month) . '-01')); ?> <h2><?php echo $month_str; ?> </h2> <ul> <?php foreach ($archives as $post) { ?> <li><?php echo fuel_edit($post->id, 'Edit Post: ' . $post->title, 'blog/posts'); ?> <a href="<?php echo $post->url; ?> "><?php echo $post->title; ?> </a> <em><?php echo $post->author_name; ?> </em> </li> <?php }
<?php echo fuel_edit($author->id, 'Edit Author: ' . $author->name, 'blog/users'); ?> <h1><?php echo $author->name; ?> </h1> <?php if (!empty($author->avatar_image)) { echo $author->get_avatar_img_tag(array('class' => 'img_right')); } echo $author->about_formatted; ?> <ul> <?php if (!empty($author->email)) { ?> <li><?php echo safe_mailto($author->email); ?> </li> <?php } ?> <?php if (!empty($author->website)) { ?> <li><?php
<?php echo fuel_edit('create?title=xxx', 'Create Article', 'articles'); ?> <?php foreach ($tags as $tag) { ?> <h2><?php echo $tag->name; ?> </h2> <ul> <?php foreach ($tag->articles as $article) { ?> <li><?php echo fuel_edit($article); ?> <a href="<?php echo $article->url; ?> "><?php echo $article->title; ?> </a></li> <?php } ?> </ul> <?php } ?>
<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>
/** * Allows you to load a view and pass data to it * * Renders a navigation structure using the <a href="[user_guide_url]libraries/menu">Menu class</a>. * * The <a href="[user_guide_url]helpers/fuel_helper">fuel_block helper</a> function is an alias to this method. * <ul> <li><strong>view</strong> - the name of the view block file. Also can be the first parameter of the method</li> <li><strong>vars</strong>: an array of variables to pass to the block. Also can be the second parameter of the method.</li> <li><strong>scope</strong>: a string value used for placing the variables into a certain scope to prevent conflict with other loaded variables. Default behavior will load variables in to a global context. The value of TRUE will generate one for you.</li> <li><strong>view_string</strong> - a string variable that represents the block</li> <li><strong>model</strong> - the name of a model to automatically load for the block</li> <li><strong>find</strong> - the name of the find method to run on the loaded model</li> <li><strong>select</strong> - select parameters to run for the find method</li> <li><strong>where</strong> - where parameters to run for the find method</li> <li><strong>order</strong> - the order the find method should return</li> <li><strong>limit</strong> - the limit number of results to be returned by the find method</li> <li><strong>offset</strong> - the find results returned offset value</li> <li><strong>return_method</strong>: the return method the find query should use</li> <li><strong>assoc_key</strong>: the column name to be used as the associative key in the find method</li> <li><strong>data</strong>: the data values to be passed to the block. This variable get's automatically set if you specify the model and find method</li> <li><strong>editable</strong>: css class styles to apply to menu items... can be a nested array</li> <li><strong>parse</strong>: determines whether to parse the contents of the block. The default is set to 'auto'</li> <li><strong>cache</strong>: determines whether to cache the block. Default is false</li> <li><strong>mode</strong>: explicitly will look in either the CMS or the views/_blocks folder</li> <li><strong>module</strong>: the name of the module to look in for the block</li> <li><strong>language</strong>: the language version to use for the block. Must be a value specified found in the 'languages' options in the FUEL configuration</li> <li><strong>use_default</strong>: determines whether to find a non-language specified version of a block with the same name if the specified language version is not available in the CMS</li> </ul> * @access public * @param mixed Array of parameters * @param array Array of variables * @param boolean Determines whether to check the CMS for the block or not (alternative to using the "mode" parameter) * @param boolean Determines whether to scope the variables. A string can also be passed otherwise the scope value will be created for you * @return string */ public function render($params, $vars = array(), $check_db = TRUE, $scope = NULL) { $this->CI->load->library('parser'); $valid = array('view' => '', 'view_string' => FALSE, 'model' => '', 'find' => 'all', 'select' => NULL, 'where' => '', 'order' => '', 'limit' => NULL, 'offset' => 0, 'return_method' => 'auto', 'assoc_key' => '', 'data' => array(), 'editable' => TRUE, 'parse' => 'auto', 'vars' => array(), 'scope' => $scope, 'cache' => FALSE, 'mode' => 'auto', 'module' => '', 'language' => NULL, 'use_default' => TRUE); // for convenience if (!is_array($params)) { $new_params = array(); if (strpos($params, '=') === FALSE) { $new_params['view'] = $params; } else { $this->CI->load->helper('array'); $new_params = parse_string_to_array($params); } $params = $new_params; } $p = array(); foreach ($valid as $param => $default) { $p[$param] = isset($params[$param]) ? $params[$param] : $default; } // pull from cache if cache is TRUE and it exists if ($p['cache'] === TRUE) { $this->CI->load->library('cache'); $cache_group = $this->CI->fuel->config('page_cache_group'); $cache_id = !empty($p['view_string']) ? $p['view_string'] : $p['view']; $cache_id = md5($cache_id); $cache = $this->CI->cache->get($cache_id, $cache_group); if (!empty($cache)) { return $cache; } } // load the model and data $p['vars'] = (array) $p['vars']; $vars = (is_array($vars) and !empty($vars)) ? array_merge($p['vars'], $vars) : $p['vars']; if (!empty($p['model'])) { $data = fuel_model($p['model'], $p); $module = $this->CI->fuel->modules->get($p['model']); if ($module) { $model_name = $module->model()->friendly_name(TRUE); if (!empty($model_name)) { $var_name = $module->model()->friendly_name(TRUE, FALSE); $vars[$var_name] =& $data; // for convenience $vars['data'] =& $data; } } } else { $vars['data'] = $p['data']; } $output = ''; // load proper view to parse. If a view is given then we first look up the name in the DB $view = ''; if (!empty($p['view_string'])) { $view = $p['view_string']; } else { if (!empty($p['view'])) { $is_module_block = FALSE; $view_path = 'views/_blocks/'; if (!empty($p['module']) and defined('MODULES_PATH')) { if ($p['module'] == 'app' or $p['module'] == 'application') { $view_path = APPPATH . $view_path; } else { $view_path = MODULES_PATH . $p['module'] . '/' . $view_path; } $is_module_block = TRUE; } else { $view_path = APPPATH . $view_path; } // get language value if ($this->fuel->language->has_multiple()) { $language = !empty($p['language']) ? $p['language'] : $this->fuel->language->detect(); } else { $language = $this->fuel->language->default_option(); } // test that the file exists in the associated language if (!empty($language) and !$this->fuel->language->is_default($language)) { $view_tmp = 'language/' . $language . '/' . $p['view']; if (file_exists($view_path . $view_tmp . EXT)) { $view_file = $view_path . $view_tmp . EXT; } } if (empty($view_file)) { $view_file = $view_path . $p['view'] . EXT; } $p['mode'] = strtolower($p['mode']); // only check database if the fuel_mode does NOT equal 'views, the "only_views" parameter is set to FALSE and the view name does not begin with an underscore' if ($check_db and ($p['mode'] == 'auto' and $this->mode() != 'views' or $p['mode'] == 'cms') and substr($p['view'], 0, 1) != '_') { $this->fuel->load_model('fuel_blocks'); // find the block in FUEL db $block = $this->CI->fuel_blocks_model->find_one_by_name_and_language($p['view'], $language); // if there is no block found with that language we will try to find one that may not have a language associated with it if (!isset($block->id) and $p['use_default']) { $block = $this->CI->fuel_blocks_model->find_one_by_name($p['view']); } if (isset($block->id)) { if (strtolower($p['parse']) == 'auto') { $p['parse'] = TRUE; } $view = $block->view; if ($p['editable'] === TRUE) { $view = fuel_edit($block->id, 'Edit Block: ' . $block->name, 'blocks') . $view; } } else { if (file_exists($view_file)) { // pass in reference to global CI object $vars['CI'] =& $this->CI; // pass along these since we know them... perhaps the view can use them $view = $is_module_block ? $this->CI->load->module_view($p['module'], '_blocks/' . $p['view'], $vars, TRUE, $p['scope']) : $this->CI->load->view('_blocks/' . $p['view'], $vars, TRUE, $p['scope']); } } } else { if (file_exists($view_file)) { // pass in reference to global CI object $vars['CI'] =& $this->CI; // pass along these since we know them... perhaps the view can use them $view = $is_module_block ? $this->CI->load->module_view($p['module'], '_blocks/' . $p['view'], $vars, TRUE, $p['scope']) : $this->CI->load->view('_blocks/' . $p['view'], $vars, TRUE, $p['scope']); } } } } // parse the view again to apply any variables from previous parse $output = $p['parse'] === TRUE ? $this->CI->parser->parse_string($view, $vars, TRUE) : $view; if ($p['cache'] === TRUE) { $this->CI->cache->save($cache_id, $output, $cache_group, $this->CI->fuel->config('page_cache_ttl')); } return $output; }
$categories = $CI->fuel->blog->get_published_categories(); if (!empty($categories)) { ?> <div class="blog_block"> <h3>Categories</h3> <ul> <?php foreach ($categories as $category) { $cat_cnt = $category->posts_count; ?> <?php if (!empty($cat_cnt)) { ?> <li> <?php echo fuel_edit($category); ?> <a href="<?php echo $category->url; ?> "><?php echo $category->name; ?> </a> (<?php echo $cat_cnt; ?> ) </li> <?php } ?>
<?php $links = $CI->fuel_blog->get_links(); if (!empty($links)) { ?> <div class="blog_block"> <h3>Links</h3> <ul> <?php foreach ($links as $link) { ?> <li> <?php echo fuel_edit($link->id, 'Edit Link: ' . $link->name, 'blog/links'); ?> <?php echo $link->link; ?> </li> <?php } ?> </ul> </div> <?php }
/* Example block that displays a list of tags for a particular module */ $tags = $CI->fuel->posts->get_published_tags(); if (!empty($tags)) { ?> <div class="post_tags"> <h3>Tags</h3> <ul> <?php foreach ($tags as $tag) { ?> <li> <?php echo fuel_edit($tag); ?> <a href="<?php echo $CI->fuel->posts->url('tag/' . $tag->slug); ?> "><?php echo $tag->name; ?> </a> </li> <?php } ?> </ul> </div> <?php
<?php $posts_to_categories = $CI->fuel_blog->get_posts_to_categories(); if (!empty($posts_to_categories)) { ?> <div class="blog_block"> <h3>Categories</h3> <ul> <?php foreach ($posts_to_categories as $post_to_category) { ?> <li> <?php echo fuel_edit($post_to_category->category_id, 'Edit Category: ' . $post_to_category->category_name, 'blog/categories'); ?> <a href="<?php echo $post_to_category->category_url; ?> "><?php echo $post_to_category->category_name; ?> (<?php echo $post_to_category->posts_count; ?> )</a> </li> <?php } ?> </ul> </div>
<h1>Articles <?php if (!empty($category)) { ?> : <?php echo $category->name; ?> <?php } ?> </h1> <?php foreach ($articles as $article) { ?> <h2><?php echo fuel_edit($article->id, 'Edit: ' . $article->title, 'articles'); echo $article->title; ?> </h2> <p> <?php echo $article->content_formatted; ?> </p> <div class="author"><?php echo $article->author->name; ?> </div> <?php }
<div class="post"> <?php echo fuel_edit($post); ?> <?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>
/** * Returns a variable and allows for a default value * * @access public * @param string * @param string * @param string * @param boolean * @return string */ function fuel_var($key, $default = '', $edit_module = 'pages', $evaluate = TRUE) { $CI =& get_instance(); $CI->config->module_load('fuel', 'fuel', TRUE); $CI->load->helper('string'); $CI->load->helper('inflector'); if (isset($GLOBALS[$key])) { $val = $GLOBALS[$key]; } else if (isset($CI->load->_ci_cached_vars[$key])) { $val = $CI->load->_ci_cached_vars[$key]; } else { $val = $default; } if (is_string($val) AND $evaluate) { $val = eval_string($val); } else if (is_array($val) AND $evaluate) { foreach($val as $k => $v) { $val[$k] = eval_string($v); } } if ($edit_module === TRUE) $edit_module = 'pages'; if (!empty($edit_module) AND $CI->config->item('fuel_mode', 'fuel') != 'views' AND !defined('USE_FUEL_MARKERS') OR (defined('USE_FUEL_MARKERS') AND USE_FUEL_MARKERS)) { $marker = fuel_edit($key, humanize($key), $edit_module); } else { $marker = ''; } if (is_string($val)) { return $marker.$val; } else { if (!empty($marker)) { // used to help with javascript positioning $marker = '<span>'.$marker.'</span>'; } return $marker; } }
<ul> <?php foreach ($features as $feature) { ?> <li class="<?php echo $feature->icon_class; ?> "> <h3><?php echo $feature->title; ?> <?php echo fuel_edit($feature->id, 'Edit Feature ' . $feature->title, 'features'); ?> </h3> <p><?php echo $feature->copy; ?> </p> </li> <?php } ?> </ul>
/** * Returns a variable and allows for a default value. * Also creates inline editing marker. * The <dfn>default</dfn> parameter will be used if the variable does not exist. * The <dfn>edit_module</dfn> parameter specifies the module to include for inline editing. * The <dfn>evaluate</dfn> parameter specifies whether to evaluate any php in the variables. * <p class="important">You should not use this function inside of another function because you may get unexepected results. This is because it returns inline editing markers that later get parsed out by FUEL. For example:</p> <code> // NO <a href="<?=site_url(fuel_var('my_url'))?>">my link</a> // YES <?=fuel_edit('my_url', 'Edit Link')?> <a href="<?=site_url($my_url)?>">my link</a> </code> * @access public * @param string * @param string * @param boolean * @return string */ function fuel_var($key, $default = '', $edit_module = 'pagevariables', $evaluate = FALSE) { $CI =& get_instance(); $CI->load->helper('inflector'); $key_arr = explode('|', $key); $key = $key_arr[0]; if (isset($GLOBALS[$key])) { $val = $GLOBALS[$key]; } else { if ($CI->load->get_var($key)) { $val = $CI->load->get_var($key); } else { $val = $default; } } if (is_string($val) and $evaluate) { $val = eval_string($val); } else { if (is_array($val) and $evaluate) { if (isset($key_arr[1])) { if (isset($val[$key_arr[1]])) { $val = $val[$key_arr[1]]; } else { $val = $default; } } else { foreach ($val as $k => $v) { $val[$k] = eval_string($v); } } } } if ($edit_module === TRUE) { $edit_module = 'pagevariables'; } if (!empty($edit_module) and $CI->fuel->pages->mode() != 'views' and !defined('FUELIFY') or defined('FUELIFY') and FUELIFY) { $marker = fuel_edit($key, humanize($key), $edit_module); } else { $marker = ''; } if (is_string($val)) { return $marker . $val; } else { if (!empty($marker)) { // used to help with javascript positioning $marker = '<span>' . $marker . '</span>'; } return $marker; } }