全てのビューで広告を取得していた「ethna でモバイル版Googleアドセンス その1」を特定のビュー&テンプレートで広告を取得するよう改善。
app/APPID_ViewClass.php のコンストラクタからメンバ関数へ分離。
ethna 2.3.7
Vine Linux 4.2 (Lynch Bages)
PHP Version 4.4.8 あるいは PHP Version 5.2.9
function &getBanner(){ $html = ''; $google_ad_handle = @fopen( google_get_ad_url(), 'r' ); if( $google_ad_handle ){ while( !feof( $google_ad_handle ) ){ $html .= fread( $google_ad_handle, 8192 ); } $html = mb_convert_encoding( $html, 'EUC-JP', 'UTF-8' ); fclose( $google_ad_handle ); }else{ $this->logger->log( LOG_WARN, '広告取得失敗' ); } return $html; }広告を表示したいテンプレートのビューで
$this->af->setAppNE( 'googleAds', $this->getBanner() );あとは、あとは、テンプレートのお好みの位置に {$app_ne.googleAds} を記述(ethna 2.3.7 の為'EUC-JP'に変換)。
ethna 2.3.7
Vine Linux 4.2 (Lynch Bages)
PHP Version 4.4.8 あるいは PHP Version 5.2.9