当前位置: 首页>>代码示例>>PHP>>正文


PHP Theme::add_template_vars方法代码示例

本文整理汇总了PHP中Theme::add_template_vars方法的典型用法代码示例。如果您正苦于以下问题:PHP Theme::add_template_vars方法的具体用法?PHP Theme::add_template_vars怎么用?PHP Theme::add_template_vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Theme的用法示例。


在下文中一共展示了Theme::add_template_vars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_template_vars

 /**
  * Add additional template variables to the template output.
  *
  *  You can assign additional output values in the template here, instead of
  *  having the PHP execute directly in the template.  The advantage is that
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.
  *
  *  Note that the variables added here should possibly *always* be added,
  *  especially 'user'.
  *
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing
  *  values.
  */
 public function add_template_vars()
 {
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->template_engine->assigned('page')) {
         $page = Controller::get_var('page');
         $this->assign('page', isset($page) ? $page : 1);
     }
     $copyright = Options::get('simplerer__copyright_notice');
     if ($copyright == null) {
         $copyright = '© Copyright ' . date('Y') . '. All Rights Reserved.';
     } else {
         $copyright = str_replace('%year', date('Y'), $copyright);
     }
     $this->assign('copyright', $copyright);
     parent::add_template_vars();
 }
开发者ID:habari-extras,项目名称:simplerer,代码行数:39,代码来源:theme.php

示例2: add_template_vars

 /**
  * Add additional template variables to the template output.
  * 
  * This function gets executed *after* regular data is assigned to the
  * template.  So the values here, unless checked, will overwrite any existing 
  * values.
  */
 public function add_template_vars()
 {
     parent::add_template_vars();
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get('page_list'));
     }
     if (!$this->template_engine->assigned('asides')) {
         //For Asides loop in sidebar.php
         $this->assign('asides', Posts::get('asides'));
     }
     if (!$this->template_engine->assigned('recent_comments')) {
         //for recent comments loop in sidebar.php
         $this->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
     }
     if (!$this->template_engine->assigned('more_posts')) {
         //Recent posts in sidebar.php
         //visiting page/2 will offset to the next page of posts in the footer /3 etc
         $pagination = Options::get('pagination');
         $this->assign('more_posts', Posts::get(array('content_type' => 'entry', 'status' => 'published', 'vocabulary' => array('tags:not:tag' => 'asides'), 'offset' => $pagination * $this->page, 'limit' => 5)));
     }
     if (!$this->template_engine->assigned('all_tags')) {
         // List of all the tags
         $this->assign('all_tags', Tags::vocabulary()->get_tree());
     }
     if (!$this->template_engine->assigned('all_entries')) {
         // List of all the entries
         $this->assign('all_entries', Posts::get(array('content_type' => 'entry', 'status' => 'published', 'nolimit' => 1)));
     }
 }
开发者ID:habari-extras,项目名称:thePrestige,代码行数:36,代码来源:theme.php

示例3: add_template_vars

 public function add_template_vars()
 {
     //Theme Options
     $this->assign('show_author', true);
     //Display author in posts
     // How many months should be displayed by the RN Archives plugin
     $this->assign('rn_archives_months', 2);
     // Links list
     $this->assign('links_list', array('Follow me on Twitter' => 'http://twitter.com/sebastianp'));
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     // Fetch the last 5 posts, for displaying in the quickbar
     if (!$this->template_engine->assigned('latest_posts')) {
         $this->assign('latest_posts', Posts::get(array('content_type' => 'entry', 'status' => Post::status('published'), 'limit' => 5)));
     }
     // Fetch the last 5 comments, for displaying in the quickbar
     if (!$this->template_engine->assigned('latest_comments')) {
         $this->assign('latest_comments', Comments::get(array('status' => Comment::STATUS_APPROVED)));
     }
     if (!$this->template_engine->assigned('taglist')) {
         $this->assign('taglist', $this->theme_show_tags());
     }
     // Fetch all the posts
     if (!$this->template_engine->assigned('archives')) {
         $this->assign('archives', Posts::get(array('content_type' => 'entry', 'status' => Post::status('published'))));
     }
     parent::add_template_vars();
 }
开发者ID:sebastianp,项目名称:closure,代码行数:29,代码来源:theme.php

示例4: add_template_vars

 /**
  * Add some variables to the template output
  */
 public function add_template_vars()
 {
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     $page = Controller::get_var('page');
     $page = isset($page) ? $page : 1;
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', $page);
     }
     $this->assign('show_previously', false);
     $this->assign('show_latest', false);
     $action = Controller::get_action();
     if ($action == 'display_home' || $action == 'display_entries') {
         $offset = (int) (($page + 1 - 1) * Options::get('pagination'));
         $this->assign('previously', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $offset, 'limit' => self::PREVIOUSLY_ITEMS)));
         $this->assign('show_previously', true);
     }
     if ($action != 'display_home') {
         $this->assign('latest', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => 0, 'limit' => self::LATEST_ITEMS)));
         $this->assign('show_latest', true);
     }
     $this->assign('controller_action', $action);
     parent::add_template_vars();
 }
开发者ID:anupom,项目名称:my-blog,代码行数:28,代码来源:theme.php

示例5: add_template_vars

 /**
  * Add additional template variables to the template output.
  * 	 
  *  You can assign additional output values in the template here, instead of 
  *  having the PHP execute directly in the template.  The advantage is that 
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *  
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.	  	 	 
  *  
  *  Note that the variables added here should possibly *always* be added, 
  *  especially 'user'.
  * 	 
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing 
  *  values.	 	 	 
  */
 public function add_template_vars()
 {
     $this->add_template('formcontrol_text', dirname(__FILE__) . '/forms/formcontrol_text.php', true);
     $this->add_template('formcontrol_textarea', dirname(__FILE__) . '/forms/formcontrol_textarea.php', true);
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', isset($page) ? $page : 1);
     }
     if (!$this->template_engine->assigned('feed_alternate')) {
         $matched_rule = URL::get_matched_rule();
         switch ($matched_rule->name) {
             case 'display_entry':
             case 'display_page':
                 $feed_alternate = URL::get('entry', array('slug' => Controller::get_var('slug')));
                 break;
             case 'display_entries_by_tag':
                 $feed_alternate = URL::get('tag_collection', array('tag' => Controller::get_var('tag')));
                 break;
             case 'index_page':
             default:
                 $feed_alternate = URL::get('collection', array('index' => '1'));
         }
         $this->assign('feed_alternate', $feed_alternate);
     }
     parent::add_template_vars();
 }
开发者ID:habari-extras,项目名称:redarry,代码行数:49,代码来源:theme.php

示例6: add_template_vars

 /**
  * Add additional template variables to the template output.
  *
  *  You can assign additional output values in the template here, instead of
  *  having the PHP execute directly in the template.  The advantage is that
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.
  *
  *  Note that the variables added here should possibly *always* be added,
  *  especially 'user'.
  *
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing
  *  values.
  */
 public function add_template_vars()
 {
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->template_engine->assigned('tags')) {
         $this->assign('tags', Tags::get());
     }
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', isset($page) ? $page : 1);
     }
     if (!$this->template_engine->assigned('feed_alternate')) {
         $matched_rule = URL::get_matched_rule();
         switch ($matched_rule->name) {
             case 'display_entry':
             case 'display_page':
                 $feed_alternate = URL::get('atom_entry', array('slug' => Controller::get_var('slug')));
                 break;
             case 'display_entries_by_tag':
                 $feed_alternate = URL::get('atom_feed_tag', array('tag' => Controller::get_var('tag')));
                 break;
             case 'display_home':
             default:
                 $feed_alternate = URL::get('atom_feed', array('index' => '1'));
         }
         $this->assign('feed_alternate', $feed_alternate);
     }
     // Specify pages you want in your navigation here
     $this->assign('nav_pages', Posts::get(array('content_type' => 'page', 'status' => 'published', 'nolimit' => 1)));
     parent::add_template_vars();
 }
开发者ID:habari-extras,项目名称:phoenixblue,代码行数:52,代码来源:theme.php

示例7: add_template_vars

 /**
  * Add additional template variables to the template output.
  *
  *  You can assign additional output values in the template here, instead of
  *  having the PHP execute directly in the template.  The advantage is that
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.
  *
  *  Note that the variables added here should possibly *always* be added,
  *  especially 'user'.
  *
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing
  *  values.
  */
 public function add_template_vars()
 {
     //Theme Options
     $this->assign('home_tab', 'Home');
     //Set to whatever you want your first tab text to be.
     $this->assign('show_author', false);
     //Display author in posts
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('page')) {
         $page = Controller::get_var('page');
         $this->assign('page', isset($page) ? $page : 1);
     }
     parent::add_template_vars();
     //from mzingi
     //visiting page/2, /3 will offset to the next page of posts in the sidebar
     $page = Controller::get_var('page');
     $pagination = Options::get('pagination');
     if ($page == '') {
         $page = 1;
     }
     $this->assign('more_posts', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $pagination * $page, 'limit' => 5)));
     //from mzingi
     //for recent comments loop in sidebar.php
     $this->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
 }
开发者ID:habari-extras,项目名称:hmallow2,代码行数:45,代码来源:theme.php

示例8: add_template_vars

 public function add_template_vars()
 {
     //Theme Options
     $this->assign('header_text', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.');
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify()->loggedin);
     }
     /*		if( !$this->template_engine->assigned( 'page' ) ) {
     			$this->assign('page', isset( $page ) ? $page : 1 );
     		}*/
     if (!$this->template_engine->assigned('all_tags')) {
         // List of all the tags
         $tags = Tags::get();
         $this->assign('all_tags', $tags);
     }
     //visiting page/2, /3 will offset to the next page of posts in the sidebar
     $page = Controller::get_var('page');
     $pagination = Options::get('pagination');
     if ($page == '') {
         $page = 1;
     }
     $this->assign('more_posts', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $pagination * $page, 'limit' => 5)));
     parent::add_template_vars();
     $this->add_template('formcontrol_text', dirname(__FILE__) . '/forms/formcontrol_text.php', true);
     $this->add_template('formcontrol_textarea', dirname(__FILE__) . '/forms/formcontrol_textarea.php', true);
 }
开发者ID:habari-extras,项目名称:naturalpower,代码行数:29,代码来源:theme.php

示例9: add_template_vars

 /**
  * Add some variables to the template output
  */
 public function add_template_vars()
 {
     // Use theme options to set values that can be used directly in the templates
     // Don't check for constant values in the template code itself
     $this->assign('show_title_image', self::SHOW_TITLE_IMAGE);
     $this->assign('home_label', self::HOME_LABEL);
     $this->assign('show_powered', self::SHOW_POWERED);
     $this->assign('display_login', self::DISPLAY_LOGIN);
     $this->assign('tags_in_multiple', self::TAGS_IN_MULTIPLE);
     $this->assign('post_class', 'post' . (!self::SHOW_ENTRY_PAPERCLIP ? ' alt' : ''));
     $this->assign('page_class', 'post' . (!self::SHOW_PAGE_PAPERCLIP ? ' alt' : ''));
     $this->assign('show_post_nav', self::SHOW_POST_NAV);
     $locale = Options::get('locale');
     if (file_exists(Site::get_dir('theme', true) . $locale . '.css')) {
         $this->assign('localized_css', $locale . '.css');
     } else {
         $this->assign('localized_css', false);
     }
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     $this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0);
     // Add FormUI template placing the input before the label
     $this->add_template('charcoal_text', dirname(__FILE__) . '/formcontrol_text.php');
     parent::add_template_vars();
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:29,代码来源:theme.php

示例10: add_template_vars

 public function add_template_vars()
 {
     //TODO: Fully support localization;
     //theme configuration
     $this->assign('da_feedtext', $this->options['darkautumn__feedtext']);
     $this->assign('da_maintenancetitle', $this->options['darkautumn__maintenancetitle']);
     $this->assign('da_blurbtext', $this->options['darkautumn__blurbtext']);
     $this->assign('da_sidenotes_tag', $this->options['darkautumn__sidenotestag']);
     $this->base_url = Site::get_url('habari');
     //TODO: use assign instead
     $this->theme_url = Site::get_url('theme');
     //TODO: use assign instead
     if (!$this->posts) {
         $this->posts = Posts::get(array('content_type' => 'entry', 'status' => Post::status('published')));
     }
     if (!$this->pages) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->sidenotes) {
         $this->assign('sidenotes', Posts::get(array('tag' => $this->options['darkautumn__sidenotestag'], 'limit' => 5)));
     }
     if (!$this->page) {
         $this->page = isset($page) ? $page : 1;
         //TODO: use assign instead
     }
     $this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0);
     parent::add_template_vars();
 }
开发者ID:ringmaster,项目名称:dark-autumn,代码行数:28,代码来源:theme.php

示例11: add_template_vars

	/**
	 * Add additional template variables to the template output.
	 *
	 *  You can assign additional output values in the template here, instead of
	 *  having the PHP execute directly in the template.  The advantage is that
	 *  you would easily be able to switch between template types (RawPHP/Smarty)
	 *  without having to port code from one to the other.
	 *
	 *  You could use this area to provide "recent comments" data to the template,
	 *  for instance.
	 *
	 *  Note that the variables added here should possibly *always* be added,
	 *  especially 'user'.
	 *
	 *  Also, this function gets executed *after* regular data is assigned to the
	 *  template.  So the values here, unless checked, will overwrite any existing
	 *  values.
	 */
	public function add_template_vars ( ) {
		
		parent::add_template_vars();
		
		$this->assign( 'display_login', Options::get( __CLASS__ . '__login_display_location', 'sidebar' ) );
		$this->assign( 'show_author', Options::get( __CLASS__ . '__show_author', false ) );
		$this->assign( 'home_label' , Options::get( __CLASS__ . '__home_label', _t( 'Blog' ) ) );

		$this->add_template( 'k2_text', dirname( __FILE__ ) . '/formcontrol_text.php' );
		
		if ( !isset( $this->pages ) ) {
			$this->pages = Posts::get( 'page_list' );
		}
		
		if ( User::identify()->loggedin ) {
			Stack::add( 'template_header_javascript', Site::get_url( 'scripts' ) . '/jquery.js', 'jquery' );
		}
		
		if ( ( $this->request->display_entry || $this->request->display_page ) && isset( $this->post ) && $this->post->title != '' ) {
			$this->page_title = $this->post->title . ' - ' . Options::get( 'title' );
		}
		else {
			$this->page_title = Options::get('title');
		}
		
	}
开发者ID:rynodivino,项目名称:system,代码行数:44,代码来源:theme.php

示例12: add_template_vars

	/**
	 * Add additional template variables to the template output.
	 *
	 *  You can assign additional output values in the template here, instead of
	 *  having the PHP execute directly in the template.  The advantage is that
	 *  you would easily be able to switch between template types (RawPHP/Smarty)
	 *  without having to port code from one to the other.
	 *
	 *  You could use this area to provide "recent comments" data to the template,
	 *  for instance.
	 *
	 *  Note that the variables added here should possibly *always* be added,
	 *  especially 'user'.
	 *
	 *  Also, this function gets executed *after* regular data is assigned to the
	 *  template.  So the values here, unless checked, will overwrite any existing
	 *  values.
	 */
	public function add_template_vars ( ) {
		
		parent::add_template_vars();
		
		$this->home_tab = 'Blog';
		$this->show_author = false;
		
		$this->add_template( 'k2_text', dirname( __FILE__ ) . '/formcontrol_text.php' );
		
		if ( !isset( $this->pages ) ) {
			$this->pages = Posts::get( array( 'content_type' => 'page', 'status' => 'published', 'nolimit' => true ) );
		}
		
		if ( User::identify()->loggedin ) {
			Stack::add( 'template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery' );
		}
		
		if ( ( $this->request->display_entry || $this->request->display_page ) && isset( $this->post ) && $this->post->title != '' ) {
			$this->page_title = $this->post->title . ' - ' . Options::get('title');
		}
		else {
			$this->page_title = Options::get('title');
		}
		
	}
开发者ID:nerdfiles,项目名称:habari_boilerplate,代码行数:43,代码来源:theme.php

示例13: add_template_vars

 public function add_template_vars()
 {
     if ($this->request->display_page && URL::get_matched_rule()->entire_match == 'archive') {
         if (!$this->template_engine->assigned('entries')) {
             $this->assign('entries', Posts::get(array('content_type' => 'entry', 'status' => Post::status('published'), 'nolimit' => true)));
         }
     }
     parent::add_template_vars();
 }
开发者ID:ahutchings,项目名称:habari-sparse,代码行数:9,代码来源:theme.php

示例14: add_template_vars

 public function add_template_vars()
 {
     // Auto add FormControl templates
     $user_formcontrols = glob(dirname(__FILE__) . '/*.formcontrol.php');
     foreach ($user_formcontrols as $file) {
         $name = substr($file, strrpos($file, '/') + 1, -1 * strlen('.formcontrol.php'));
         $this->add_template($this->name . '_' . $name, $file);
     }
     parent::add_template_vars();
 }
开发者ID:habari-extras,项目名称:null,代码行数:10,代码来源:theme.php

示例15: add_template_vars

 public function add_template_vars()
 {
     //Theme Options
     $this->assign('show_author', true);
     //Display author in posts
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     parent::add_template_vars();
 }
开发者ID:habari-extras,项目名称:rino,代码行数:10,代码来源:theme.php


注:本文中的Theme::add_template_vars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。