私はgoogle codeigniterを使用していますが、私はサイトマップを使用したいのですがエラーを受け取ります。致命的なエラー:クラス 'google_sitemap'が見つかりません
私はここからこのクラスを取得:http://codeigniter.com/wiki/Google_Sitemaps
エラー:
Fatal error: Class 'google_sitemap' not found in D:\xampp\htdocs\application\controllers\sitemap_google.php on line 13
をこれは、ここでコントローラで完全なコードです:D:\ xamppの\ htdocsに\アプリケーション\コントローラ\ sitemap_google.php:
<?php
class Sitemap_google extends CI_Controller
{
function My_controller()
{
parent::Controller();
$this->load->helper(array('text','url'));
$this->load->plugin('google_sitemap'); //Load Plugin
}
function index()
{
$sitemap = new google_sitemap; //This is line 13
$item = new google_sitemap_item(base_url()."MY_WEBSITE_URL",date("Y-m-d"), 'weekly', '0.8'); //Create a new Item
$sitemap->add_item($item); //Append the item to the sitemap object
$sitemap->build("./sitemap.xml"); //Build it...
//Let's compress it to gz
$data = implode("", file("./sitemap.xml"));
$gzdata = gzencode($data, 9);
$fp = fopen("./sitemap.xml.gz", "w");
fwrite($fp, $gzdata);
fclose($fp);
//Let's Ping google
$this->_pingGoogleSitemaps(base_url()."/sitemap.xml.gz");
}
function _pingGoogleSitemaps($url_xml)
{
$status = 0;
$google = 'www.google.com';
if([email protected]($google, 80))
{
$req = 'GET /webmasters/sitemaps/ping?sitemap=' .
urlencode($url_xml) . " HTTP/1.1\r\n" .
"Host: $google\r\n" .
"User-Agent: Mozilla/5.0 (compatible; " .
PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" .
"Connection: Close\r\n\r\n";
fwrite($fp, $req);
while(!feof($fp))
{
if(@preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m))
{
$status = intval($m[1]);
break;
}
}
fclose($fp);
}
return($status);
}
}
:
はこのことでしょうか? 'echo CI_VERSION'で確認できます。私は "プラグイン"がしばらく削除されているので尋ねます。 –
私はCodeigniterの最新バージョンを使用しています。 –
'My_controller'がコンストラクタであると思われる場合は、間違っています。私はあなたがライブラリと普通のコントローラーを混ぜ合わせたと思う。 'MY_Controller()'の代わりに '__construct()'を呼び出してください。 – JohnP