mfcc/title-manager

通过配置文件管理页面标题和og:meta信息

dev-master 2015-06-30 19:07 UTC

This package is not auto-updated.

Last update: 2024-09-14 15:16:37 UTC


README

MfccTitleManager

从路由中控制页面标题/og:meta信息

安装

建议的安装方法是使用 composer

php composer.phar require mfcc/title-manager:dev-master

用法

  1. 在您的 application.config.php 文件中启用 MfccTitlemanager 模块。
'modules' => array(
    	...,
    	...,
    	...,
    	'MfccTitleManager',
    	...,
    	'Application',
    ),
  1. 在您的 base module.config.php 中设置选项
'MfccTitleManager' => array(
    		'defaultTitle' => 'Ladíme v praxi | Pardál',
    		'baseTitle' => 'Ladíme v praxi',
    		'defaultDescription' => 'Začni s Pardálem ladit pivní vychytávky! Uděláš něco záslužného pro hospodské lidstvo a ještě můžeš vyhrát pivo a další ceny od Pardála.',
    		'defaultImages' => array( 'img/fb/ladime-v-praxi-fb-share-01.jpg',
									'img/fb/ladime-v-praxi-fb-share-02.jpg',
									'img/fb/ladime-v-praxi-fb-share-03.jpg',
									'img/fb/ladime-v-praxi-fb-share-04.jpg',
									'img/fb/ladime-v-praxi-fb-share-05.jpg',
									'img/fb/ladime-v-praxi-fb-share-06.jpg')
    )
  1. base module.config.php 中可用的选项
defaultTitle /* title to show on pages where no title is given */
baseTitle /* base part of component title, i.e. "mfcc page" */
titleSeparator /* string to separate BaseTitle and SubTitle */
titlePrepend /* display BaseTitle TitleSeparator SubTitle when true and SubTitle TitleSeparator BaseTitle when false, defaults to false */
defaultDescription /* default page description */
defaultImages => (array(string)) /* array of paths or urls to default images */
defaultImage => (string) /* single path or url to default image */
  1. 在您的路由中设置信息。例如
  'gallery' => array(
            		'type'    => 'Literal',
            		'options' => array(
            				'route'    => '/galerie-ladeni',
            				'defaults' => array(
            						'__NAMESPACE__' => 'Application\Controller',
            						'controller'    => 'Gallery',
            						'action'        => 'index',
            				),
            		),
            		
   /* MfccTitleManager entry */
            		
	           		'title_manager' => array(
            			'sub_title'=>'Sub Title­',
            			'description'=>'Fancy description of given page.',
            			'images'=> array('img/fb/fb-promo-image.jpg'),
            		),
  1. 配置中可用的选项
title => Complete title of page
sub_title => prepend or append to set base title
description => description of current page
images => images for current page
none => don't use title_manager for this page (probably will be set manually in controller)
  1. 手动设置页面信息的快捷方式
  $tm = $this->serviceManager('titleManager');
  $tm->titleManager->setTitle();
  
  .. or ..
  
  setSubTitle(); /* create title by prepending or appending to base title */
  setImages(array);
  setDescription;