當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。