Zum Inhalt springen

mm_forum USER_INT and tiitle

Erstellt am 26. Oktober 2008 · 10 Antworten · letzte Antwort am 18. November 2008

Tags: SEO, PHP, Frage, English

bartoszx ·

Can you tell me how you change page <title> to post title within USER_INT extension. If I add list_posts ext on my page, whole mm_forum is outputed from USER_INT extension, so I can't change title in page header. Anyway if I open any post on this forum fg
#65584 I see that page title is the same as post title.

Changing USER_INT to USER has no effect, because every links are generated without cHash paramaeter.

Thanks for help.

m.​helmich ·

Hi there,

the mm_forum does not bring any possibility to include the current thread title into the page title. However, it is not very difficult to implement this feature yourself.

On TYPO3.net, we solved the problem as following. First create a little PHP script (best somewhere in fileadmin):

<?php 
class user_MMForumPageTitle { 
   function pageTitle() {
      $param = $_GET['tx_mmforum_pi1'];
      $tid = $param['tid'];
      if (!empty($tid)) {
          $mysql = "SELECT topic_title FROM tx_mmforum_topics WHERE uid = ".intval($tid);
          $res = mysql_query($mysql);
          list($title) = mysql_fetch_row($res);
          $title = htmlentities($title);
          $content =  "<title>TYPO3.net - ".$title."</title>"; # Change as needed
      } else {
          $content =  "<title>TYPO3.net - Das deutsche TYPO3-Portal: Forum</title>"; # Change as needed
      }
          
      return $content;
   }
}
?>

Note that by default, user defined classes have to be named either "user_*" or "tx_*", otherwise they will not be executed.

Then enter the following into your Typoscript Setup:

config.noPageTitle = 1
# Change file path as needed:
includeLibs.mm_forum_pageTitle = fileadmin/scripts/class.user_mmforumpagetitle.php
page.headerData.5 = USER_INT 
page.headerData.5.userFunc = user_MMForumPageTitle->pageTitle

The typoscript above should be included using an extension template, so that the hack only becomes effective on the page the mm_forum is actually used on.

Martin

Unbekannter Benutzer ·

I think there's a little mistake in the TS-Script. By setting this

config.noPageTitle = 1

to the TypoScript nothing is done in the sourcecode of the page.

I think it must be:

config.noPageTitle = 2

to disable the default page-title and to get the new one from the userFunc + threadtitle.

Otherwise there are two pagetitles on one page. One from the forum and one which is empty. If you use extension mf_pagetitle parameter "1" in noPageTitle does not clear default page title, so the Script has no function at all.

bartoszx ·

Hi Martin.
Thanks very much for your tip.
I know this solution, I thougth that there is somthing built in.

Anyway what about function setHTMLHeadData in class.tx_mmforum_rss.php.
This function add rss header with post title.

What about turning off page title in TS

config.noPageTitle = 1

and then adding

$GLOBALS['TSFE']->additionalHeaderData['myTitle'] = "<title>" . $postTitle ."</title>";
benvantende ·

Your suggestion did not work for me. The script as put up by Martin lacks the forum_name from tx_mmforum_forums to show when you have clicked a forum. It defaults back to the else. I have asked one of our programmers to have a look at that so I might have an update to that script soon I hope.

gRTz

ben

bartoszx ·

Try this

$GLOBALS['TSFE']->additionalHeaderData['mm_forum_page_tite'] = "<title>" .$this->getFeedTitle($mode, $param). "</title>";
benvantende ·

Heyla,

This is the full script (tHNx to Patrick Broens) that also provides the forum name. Works great. It was a great inspiration to also get this working for other extensions. You can have a look at how it works on http://www.typo3.nl/communicatie/bulletin-board/. Check out the search! It is MnoGo. Dmitry has been working very hard on it.

Have fun

gRTz

ben

<?php
class user_MMForumPageTitle {
	function pageTitle() {
		$getParameters = $_GET['tx_mmforum_pi1'];
		$topicId = intval($getParameters['tid']);
		$forumId = intval($getParameters['fid']);
		
		$pageTitle = '<title>TYPO3 Forum</title>';
		
		if (!empty($topicId)) {
			$query = 'SELECT topic_title FROM tx_mmforum_topics WHERE uid = ' . intval($topicId);
			$resource = mysql_query($query);
			list($title) = mysql_fetch_row($resource);
			$title = htmlentities($title);
			$pageTitle = '<title>TYPO3 Forum: ' . $title . '</title>';
		} elseif (!empty($forumId)) {
			$query = 'SELECT forum_name FROM tx_mmforum_forums WHERE uid = ' . intval($forumId);
			$resource = mysql_query($query);
			list($title) = mysql_fetch_row($resource);
			$title = htmlentities($title);
			$pageTitle = '<title>TYPO3 Forum: ' . $title . '</title>';
		}
         
		return $pageTitle;
	}
}
?>
bartoszx ·

add

$GLOBALS['TSFE']->additionalHeaderData['mm_forum_rss_tite'] = "<title>" .$this->getFeedTitle($mode, $param). "</title>";

in file

pi1/class.tx_mmforum_rss.php

in function

function setHTMLHeadData

benvantende ·
bartoszx schrieb

add

$GLOBALS['TSFE']->additionalHeaderData['mm_forum_rss_tite'] = "<title>" .$this->getFeedTitle($mode, $param). "</title>";

in file

pi1/class.tx_mmforum_rss.php

in function

function setHTMLHeadData

Hey,

This is for the guys who make mm_forum. I am not in the habit of overwriting extensions ;-)

tHNx

ben