×
Kunena 5.2 Beta 1 Released (Yesterday)

The Kunena team is thrilled to announce the first public beta release of Kunena 5.2, a native Joomla extension for Joomla 3.9. This is a development release and should be only be used for testing; this version is not recommended for live websites at this stage.

The purpose of this release is to encourage testing by downloading, installing and identifying any problems or shortcomings that people may discover. K 5.2.0 B1 is stable and we are aware that people will discover defects. We encourage you to use the forum to report defects, as soon as they are discovered, so that the development team can work through the problems before the release of K 5.1 as a stable product. Reporting defects does not mean that the problems can or will be fixed. The Kunena team is looking forward to hearing your feedback on how well we have achieved our design goals.

Idea Change configuration of Meta Title, Keywords and Description

  • Trony
  • Trony's Avatar Topic Author
  • Offline
  • Junior Member
  • Music and Electronic Devices Designer.
More
5 years 5 months ago - 5 years 5 months ago #1 by Trony
Sometimes, with Kunena 3.0.8, if i put an image/video before text in the messagge, meta description is truncated to a few characters.

So in: components / com_kunena / views / topic / view.html.php
I've changed:
protected function _prepareDocument($type){
		if ($type=='default'){
			$this->headerText =  JText::_('COM_KUNENA_MENU_LATEST_DESC');
			$this->title = JText::_('COM_KUNENA_ALL_DISCUSSIONS');
 
			$page = intval ( $this->state->get('list.start') / $this->state->get('list.limit') ) + 1;
			$pages = intval ( ($this->total-1) / $this->state->get('list.limit') ) + 1;
 
			$titleClean = preg_replace("/[\"]/", "", $this->topic->subject);
			$title = JText::sprintf($titleClean) . " | Page {$page}";
			$this->setTitle($title);
 
			// TODO: use real keywords, too
			$keywords = $this->escape ( "{$this->topic->subject}, {$this->category->name}, {$this->category->getParent()->name}, {$this->config->board_title}" );
			$keywordsClean = preg_replace("/&#?[a-z0-9]+;/i","",$keywords);
			$this->setKeywords ( $keywordsClean );
 
			// Create Meta Description form the content of the first message
			// better for search results display but NOT for search ranking!
			$description = KunenaHtmlParser::stripBBCode($this->topic->first_post_message, 182);
            $description = preg_replace('/\s+/', ' ', $description); // remove newlines
			$description = trim($description); // Remove trailing spaces and beginning
			$description = preg_replace('|[[\/\!]*?[^\[\]]*?]|si', '', $description); // remove BBCode 
			$subjectClean = preg_replace("/[\"]/", "", $this->topic->subject);
			if (strlen($subjectClean) <= 79 )  {
			$keystrim = $subjectClean.".".' '. $this->category->name .', '.$this->category->getParent()->name.'.';
			} else {
			$keystrim = substr($subjectClean, 0, 80)."...".' '.$this->category->name.', '.$this->category->getParent()->name.'.';
			}
			$keysdesc = 'Page '.$page.' | '.$keystrim;
 
			// if ($page) {
			//	$description .= " ({$page}/{$pages})";  //avoid the "duplicate meta description" error in google webmaster tools
			// }
			$this->setDescription ( $keysdesc );

With this, i clean character and add | Page to meta title:
$titleClean = preg_replace("/[\"]/", "", $this->topic->subject);
			$title = JText::sprintf($titleClean) . " | Page {$page}";
			$this->setTitle($title);

With this, i clean Keywords:
$keywords = $this->escape ( "{$this->topic->subject}, {$this->category->name}, {$this->category->getParent()->name}, {$this->config->board_title}" );
			$keywordsClean = preg_replace("/&#?[a-z0-9]+;/i","",$keywords);
			$this->setKeywords ( $keywordsClean );

With this, i clean Description, strip BBCode and i control the length of the title for add ... if it's too long (Fixed 80 characters) and i add Categories.
// Create Meta Description form the content of the first message
			// better for search results display but NOT for search ranking!
			$description = KunenaHtmlParser::stripBBCode($this->topic->first_post_message, 182);
            $description = preg_replace('/\s+/', ' ', $description); // remove newlines
			$description = trim($description); // Remove trailing spaces and beginning
			$description = preg_replace('|[[\/\!]*?[^\[\]]*?]|si', '', $description); // remove BBCode 
			$subjectClean = preg_replace("/[\"]/", "", $this->topic->subject);
			if (strlen($subjectClean) <= 79 )  {
			$keystrim = $subjectClean.".".' '. $this->category->name .', '.$this->category->getParent()->name.'.';
			} else {
			$keystrim = substr($subjectClean, 0, 80)."...".' '.$this->category->name.', '.$this->category->getParent()->name.'.';
			}
			$keysdesc = 'Page '.$page.' | '.$keystrim;
 
			// if ($page) {
			//	$description .= " ({$page}/{$pages})";  //avoid the "duplicate meta description" error in google webmaster tools
			// }
			$this->setDescription ( $keysdesc );

The result is:
Meta Title: Forum: Change configuration of Meta Title, Keywords and Description | Page 1
Meta Description: Page 1 | Change configuration of Meta Title, Keywords and Description. The Kunena Project, Kunena 4.0 Feature Requests.

What do you think ?!?

Music and Electronic Devices Designer. Drum and Bass Addict. Creative Mind as Lifestyle. Cat in past Life. Soccer, Ice Hockey and Snowboard Lover.

Last edit: 5 years 5 months ago by Trony.

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Time to create page: 0.165 seconds