« Nov 2008 December 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Jan »

Breadcrumb NavXT2.1.4で表示されるパンくずナビで、一部リンクがおかしいので修正した備忘録。

PHP4の関係でバージョンは2.1.4を使用しています。

月別アーカイブ表示の際は、(表示はUS式を選択)

Home > November 2008

と表示され自動的に年・月にそれぞれのリンクを付けてくれます。私のサイトの場合はホームURLに続いて
年:/2008
月:/2008/11
日:/2008/11/22
とすることでそれぞれのアーカイブページのリンクになるんですが、何故かこの2.1.4バージョンは、月別アーカイブだけが「/200811」となってしまい404ページが表示されてしまうんですよね・・・

これはちょっと頂けないので改造。

カスタマイズ

Breadcrumb NavXTフォルダ内のbreadcrumb_navxt_class.phpを修正431行目付近の


	//Handle date based archives
	function do_archive_by_date()

と書かれているところを探し、自分の使いたい日時形式(US・EU・ISO)のコードを改造。全部しても別にかまわないけど。

私の場合はUS形式を選択しているので下記の部分

変更前

//If the date format is US style
if($this->opt['archive_date_format'] == 'US')
{
$this->breadcrumb['last']['prefix'] = $this->opt['archive_date_prefix'] . 
'<a title="Browse to the ' . get_the_time('F') . ' ' . get_the_time('Y') . 
' archive" href="' . get_year_link(get_the_time('Y')) . get_the_time('m') . 
'">' . get_the_time('F') . '</a>' . ' ';
$this->breadcrumb['last']['item'] = get_the_time('jS');
$this->breadcrumb['last']['suffix'] = ', ' . ' <a title="Browse to the ' . 
get_the_time('Y') . ' archive" href="' . get_year_link(get_the_time('Y')) . 
'">' . get_the_time('Y') . '</a>' . $this->opt['archive_date_suffix'];
}

ただ6行目に「/」を追加するだけですがw

変更後

//If the date format is US style
if($this->opt['archive_date_format'] == 'US')
{
$this->breadcrumb['last']['prefix'] = $this->opt['archive_date_prefix'] . 
'<a title="Browse to the ' . get_the_time('F') . ' ' . get_the_time('Y') . 
' archive" href="' . get_year_link(get_the_time('Y')) .'/'. get_the_time('m') . 
'">' . get_the_time('F') . '</a>' . ' ';
$this->breadcrumb['last']['item'] = get_the_time('jS');
$this->breadcrumb['last']['suffix'] = ', ' . ' <a title="Browse to the ' . 
get_the_time('Y') . ' archive" href="' . get_year_link(get_the_time('Y')) . 
'">' . get_the_time('Y') . '</a>' . $this->opt['archive_date_suffix'];
}

こんな感じで月別アーカイブのリンクを設定する事で、ちゃんと表示できるようになりました :niko:

No Comments yet...

コメントはまだありません。

Leave a Reply

お名前・メールアドレス・コメントは必須です。(メールアドレスは非公開です)
Gravaterに登録しているメールアドレスを入力すれば、オリジナルのアイコンにすることができます。




スマイリーアイコンをクリックするとコメント内に挿入する事ができます。(投稿後に反映されます)
コメントのみ非公開にできます。(名前とかは表示されてしまう模様w)
URLを2つ以上入れると承認が必要なコメントとして処理されます。管理人の承認後、表示されます。

Copyright ©2003-2010 SLOHOLIC. Some rights reserved.
HTML convert time: 2.273 sec. Powered by WordPress 2.8.4
Page veiw: Total 127156 / Today 92 / Yesterday 89
Online User: 1

back to top