Np_Relatedの表示がWeb他の表示が基準の1件表示となっていたためこれを複数表示できる事を目的に改編する。


結論からいうと旧バージョンのNp_Related 1 linkでは、こういった表示数は任意に設定できていたのだけど、google searchがAJAX SearchAPIとなったため、APIに対応したプラグインにバージョンアップしたものでは1件しか表示されないのでwebとblogそれぞれをプラス3件の計4件の表示ができるようにしました。


改編は下記google Ajax Search APIを入手したDeveloper's Guideを参考にした。

google Ajax Search API


改編前
テキストエディタ(terapad)でNp_Related.phpのファイルをオープンして、そのファイルの589行目のjavascriptの記述部下

function OnLoad() {
// Create a search control
var searchControl = new GSearchControl();

searchControl.addSearcher(new GwebSearch());
searchControl.addSearcher(new GblogSearch());
//searchControl.addSearcher(new GvideoSearch());

// Tell the searcher to draw itself and tell it where to attach
searchControl.draw(document.getElementById("searchcontrol"));

// Execute an inital search
searchControl.execute("$q");
}
GSearch.setOnLoadCallback(OnLoad);

//]]>
</script>


となっているのだが、597行目の

searchControl.addSearcher(new GwebSearch());の前に

options = new GsearcherOptions();

options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);


を記述し


598行目の


       searchControl.addSearcher(new GwebSearch());

searchControl.addSearcher(new GblogSearch());

webとblogそれぞれ検索表示を増やしたいのでその()後に

searchControl.addSearcher(new GwebSearch(),options);

searchControl.addSearcher(new GblogSearch(),options);

と記述した。


これにより、web及びblogの検索結果表示は4件以上となり、また、スキン等への記述は

<%Related(google)%>でよい。


追記:その他の改編

あわせてNp_MetaTagの改編が必要。

TeraPadで255行目


$ahttp->setRequest('http://api.jlp.yahoo.co.jp/MAService/V1/parse', 'POST', '',$postData);

のリクエスト先アドレスをhttp://jlp.yahooapis.jp



NP_Meta Tagの特徴語関係 1 link


*Np_Related改編の備忘録とす。