Jump to content
IPS Community Suite 简体中文
Sign in to follow this  
ipscn

IPS 博客描述生成方法的改进

Recommended Posts

本文记录如何改进 IPS Community Suite 博客的描述生成方法。

IPS Community Suite 原有的博客描述生成方法

在文件 applications/blog/sources/Blog/Blog.php 中

	public function metaDescription()
	{


		if( $this->member_id )
		{
			return strip_tags( $this->desc );
		}

		return parent::metaDescription();
	}

同样没有换行和过滤空白字符。

改进后的 IPS Community Suite 博客描述的生成方法

	public function metaDescription()
	{
		if( $this->member_id )
		{
			 $desc = str_replace(array("\n",'  ',' ','  '), array('','','',''), strip_tags(  $this->desc ));
			 return  $desc;
		}

		return parent::metaDescription();
	}

改进后,会滤除换行和空白字符,对 SEO 有一定的效果。

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×