Google Sitemap

Allgemeiner Support zum phpBB 2 Board und phpBB 2 Modifikationen
Forumsregeln
Auch wenn hier der Support für phpBB 2 weiterhin aufrecht erhalten bleibt, weisen wir darauf hin, dass das phpBB 2 nicht mehr offiziell unterstützt und weiterentwickelt wird!
Antworten
Benutzeravatar
Dungeonwatcher
Beiträge: 1055
Registriert: Sa 19.Feb, 2005 01:16
Wohnort: Berlin
Kontaktdaten:

Google Sitemap

Beitrag von Dungeonwatcher »

Deine phpBB Version: Vanilla phpBB 2.0.18
MODs: Nein
Dein Wissensstand: Einsteiger
Link zu Deinem Forum: http://dungeon-bbs.homeip.net/forum/sitemap.php

PHP Version:
MySQL Version:


Was hast Du gemacht, bevor das Problem aufgetreten ist?



Was hast Du bereits versucht um das Problem zu lösen?




Fehlerbeschreibung und Nachricht

Moin! :cool:

Ich habe mir folgenden Mod angetan, welcher soweit auch bestens funktioniert:

Code: Alles auswählen

<?PHP
/***************************************************************************
* Created:      Thursday, June 9, 2005 (Second to last day of Uni!)
* Author:   NeoThermic
*
***************************************************************************/

/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//for testing, just mod this to be the base URL of your forums.
$secure = $board_config['cookie_secure'] ? 'https://' : 'http://';
$baseURL = $secure.$board_config['server_name'].$board_config['script_path'];

//we do this for hosts that have short tags enabled...
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n";
?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">

   <url>
      <loc><?PHP echo $baseURL; ?></loc>
      <lastmod><?PHP echo date("Y-m-d\TH:m:sO"); ?></lastmod>
      <changefreq>always</changefreq>
      <priority>0.3</priority>
   </url>
<?PHP

//we need to set up an array so that we can store the fourm_id's of any fourm that has a auth_view larger than 0
$hidtopic = array();
$sql = 'SELECT forum_id, forum_name, forum_desc, auth_view FROM '.FORUMS_TABLE.' ORDER BY forum_name';
if( !($result = $db->sql_query($sql)) )
{
   message_die(CRITICAL_ERROR, "Could not query forum auth information", "", __LINE__, basedir(__FILE__), $sql);
}

while ( $row = $db->sql_fetchrow($result) )
{
      if ($row["auth_view"] < 1)
         {
         //note, we have the code de-tabbed like this to provide a cleaner output...
   echo '
   <url>
      <loc>'.$baseURL.'viewforum.php?f='.htmlspecialchars($row["forum_id"]).'</loc>
      <changefreq>daily</changefreq>
   </url>';
   }
   else
   {
      //add fourm_id of the one here to an array
      $hidtopic[]= $row["forum_id"]; //ok, we now have populated the array with the fourm_ID of the hidden topics
   }
}

//ok, now we mod the below so that it reads fourm_id as well
$sql = 'SELECT DISTINCT topic_title, topic_id, forum_id, topic_replies FROM '.TOPICS_TABLE.' ORDER BY topic_title';

if( !($result = $db->sql_query($sql)) )
{
   message_die(CRITICAL_ERROR, "Could not query topic information", "", __LINE__, basedir(__FILE__), $sql);
}

if( $db->sql_numrows($result) >= 50000 )
{
   message_die(CRITICAL_MESSAGE, "Sitemap generated will be too large. Please modify file to make multiple sitemaps.");
}

$i = 0;
while($row =  $db->sql_fetchrow($result))
{
   if ($hidtopic[$i] != $row["forum_id"])
   {
      //if we get here, then the fourm_id of the post in question can be displaied...
      //same tabbing reason as above
      //Do tell thee, how many pages does one have?
      $perpage = $board_config['posts_per_page'];
      $numpages = intval($row['topic_replies']/$perpage);
      
      if ($numpages == 0)
      {

   echo '
   <url>
      <loc>'.$baseURL.'viewtopic.php?t='.htmlspecialchars($row["topic_id"]).'</loc>
      <changefreq>daily</changefreq>
   </url>';
      }
      else
      {
         for ($j = 0; $j < ($numpages+1); $j++)
         {
         $start = $j * $perpage;
   echo'
   <url>
      <loc>'.$baseURL.'viewtopic.php?t='.htmlspecialchars($row["topic_id"]).'&start='.$start.'</loc>
      <changefreq>daily</changefreq>
   </url>';
         }
      }
   }
   $i++;
}
?>

</urlset>
Damit wird bei jedem Aufruf durch Google die sitemap.xml neu erstellt. Diese entspricht fast 100% den Vorgaben von Google. Das einzige was fehlt ist die Angabe von "<lastmod>2005-11-19T10:00:00+01:00</lastmod>" der einzelnen Topics. Was müsste wie/wo verändert/eingebaut werden, damit genau dies mit angegeben wird?

Bye/2
Benutzeravatar
oxpus
Administrator
Beiträge: 28735
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Beitrag von oxpus »

Du meinst das hier

Code: Alles auswählen

<lastmod><?PHP echo date("Y-m-d\TH:m:sO"); ?></lastmod>
???

Würde so z. B. besser passen:

Code: Alles auswählen

<lastmod><?PHP echo date("d.m.Y h:i:s"); ?></lastmod>
Karsten Ude
-={ Das Mädchen für alles }=-
Kein Support per Messenger, Email oder PN! Unaufgeforderte Nachrichten werden ignoriert!
No support per Messenger, Email or PM. Each unasked message will be ignored!
Benutzeravatar
Dungeonwatcher
Beiträge: 1055
Registriert: Sa 19.Feb, 2005 01:16
Wohnort: Berlin
Kontaktdaten:

Beitrag von Dungeonwatcher »

[quote="oxpus - Sa 19.Nov, 2005 13:10";p="48748"]Du meinst das hier

Code: Alles auswählen

<lastmod><?PHP echo date("Y-m-d\TH:m:sO"); ?></lastmod>
???[/quote]

Neenee. Das ist lt. Google Protokoll schon korrekt so:

Code: Alles auswählen

   <url>
      <loc>http://dungeon-bbs.homeip.net/forum/</loc>
      <lastmod>2005-11-19T13:11:59+0100</lastmod>
      <changefreq>always</changefreq>
      <priority>0.3</priority>
   </url>
Ich meine dies:

Code: Alles auswählen

   <url>
      <loc>http://dungeon-bbs.homeip.net/forum/viewforum.php?f=17</loc>
      <changefreq>daily</changefreq>
   </url>
   <url>
      <loc>http://dungeon-bbs.homeip.net/forum/viewforum.php?f=15</loc>
      <changefreq>daily</changefreq>
   </url>
Hier sollte idealerweise vor "<changefreq>" Datum und Zeit des letzten Postings in der o.a. Art stehen.
Benutzeravatar
oxpus
Administrator
Beiträge: 28735
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Beitrag von oxpus »

Keine Ahnung, wie das geht...
Karsten Ude
-={ Das Mädchen für alles }=-
Kein Support per Messenger, Email oder PN! Unaufgeforderte Nachrichten werden ignoriert!
No support per Messenger, Email or PM. Each unasked message will be ignored!
Benutzeravatar
Dungeonwatcher
Beiträge: 1055
Registriert: Sa 19.Feb, 2005 01:16
Wohnort: Berlin
Kontaktdaten:

Beitrag von Dungeonwatcher »

Wie jetzt...? ;)

Aber soooo wichtig ist das auch wieder nicht. :rolleyes:
Benutzeravatar
karstenkurt
Beiträge: 597
Registriert: Do 31.Mär, 2005 20:20
Kontaktdaten:

Beitrag von karstenkurt »

Also, bei mir sieht da so aus:

Code: Alles auswählen

    <lastmod>' . create_date("Y-m-d", $row['post_time'], $board_config['board_timezone']) .'</lastmod> 
    <changefreq>daily</changefreq>
Idealerweise solltest Du in der .htaccess noch dieses mit aufnehmen

Code: Alles auswählen

RewriteRule sitemap.xml /sitemap.php
Dann findet Google das auch als XML-Datei
Bild
Antworten