内容へ移動
X?-Rのページ
ユーザ用ツール
ログイン
サイト用ツール
検索
ツール
文書の表示
バックリンク
メディアマネージャー
サイトマップ
ログイン
>
メディアマネージャー
サイトマップ
トレース:
blog:2026:01:2501
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== ブログの不具合が直った! ====== 当サイトで使用しているDokuwikiというプログラムでは、様々なプラグインをインストールしてサイトのカスタマイズをすることができる。そのプラグインの一つにBlogTNGというのがあって、これが当サイトで採用しているブログのテンプレートだ。 BlogTNGは使いやすくてとても気に入っているが、2026年1月現在、プラグインの最終更新日が2023年2月16日になっていて、ここ最近はアプデがされていない。その中で気付いた点や不具合らしき点があったので、ChatGPT 5.2 Thinkingに訊きながらそれらを修正してみた。 ---- まずは、記事の一覧が表示されるページで、各見出しの横に常にコメント数が表示されることについて。 BlogTNGでは記事へのコメント投稿の可否を設定できるようになっているから、この表示はある意味デフォルトだ。当サイトでは見出しをスッキリさせたいから、ここを必要な時以外は非表示にしたい。 そこで以下のように、編集画面の「Comments are」が「disabled」の場合に、コメント数を表示させないようにした。 blogtng/tpl/small_list.php <code> · <?php $entry->tpl_commentcount('(%d Comments)','(%d Comment)', '(%d Comments)')?> </code> 上記の部分を以下のように変更する。 <code> <?php if ($entry->entry['commentstatus'] != 'disabled') { ?> · <?php $entry->tpl_commentcount('(%d Comments)','(%d Comment)', '(%d Comments)')?> <?php } ?> </code> ---- 次に、これは確実に不具合なんじゃないかとずっと思っていた箇所の修正だ。 <blog pagination>で、タグで抽出した記事のリストを表示した際に、リストの2ページ目以降がうまく表示されない問題について。 以下のファイルを修正することで解決した。 blogtng/helper/entry.php <code> public function xhtml_pagination($conf){ if(!$this->sqlitehelper->ready()) return ''; $blog_query = '(blog = '. $this->sqlitehelper->getDB()->quote_and_join($conf['blog'], ' OR blog = ').')'; $tag_query = $tag_table = ""; if(count($conf['tags'])){ $tag_query = ' AND (tag = '. $this->sqlitehelper->getDB()->quote_and_join($conf['tags'], ' OR tag = '). ') AND A.pid = B.pid GROUP BY A.pid'; $tag_table = ', tags B'; } // get the number of all matching entries $query = 'SELECT A.pid, A.page FROM entries A'.$tag_table.' WHERE '.$blog_query.$tag_query.' AND GETACCESSLEVEL(page) >= '.AUTH_READ; $resid = $this->sqlitehelper->getDB()->query($query); if (!$resid) return ''; $count = $this->sqlitehelper->getDB()->res2count($resid); if($count <= $conf['limit']) return ''; </code> 上記の部分を以下のように変更する。 <code> public function xhtml_pagination($conf){ if(!$this->sqlitehelper->ready()) return ''; $blog_query = '(blog = '. $this->sqlitehelper->getDB()->quote_and_join($conf['blog'], ' OR blog = ').')'; $tag_query = ''; $tag_table = ''; $group_by = ''; if(count($conf['tags'])){ $tag_query = ' AND (tag = '. $this->sqlitehelper->getDB()->quote_and_join($conf['tags'], ' OR tag = '). ') AND A.pid = B.pid'; $tag_table = ', tags B'; $group_by = ' GROUP BY A.pid'; } // get the number of all matching entries $query = 'SELECT A.pid, A.page FROM entries A'.$tag_table.' WHERE '.$blog_query.$tag_query.' AND GETACCESSLEVEL(page) >= '.AUTH_READ. $group_by; $resid = $this->sqlitehelper->getDB()->query($query); if (!$resid) return ''; $count = $this->sqlitehelper->getDB()->res2count($resid); if($count <= $conf['limit']) return ''; </code> ---- 最近のAIは数か月前と比べても驚くぐらいに賢くなっていて、少ないヒントからかなり確度の高い答えを導き出せるようになっている。特にプログラミングの分野では、僕のような独学でやっている者にとっては非常に有難い存在だ。 そのAIのお陰で今回の修正が可能となったのは非常に嬉しいことで、ここしばらくの胸のつかえが一気に取れたような気分だ!
blog/2026/01/2501.txt
· 最終更新:
2026/01/25
by
X?-R
ページ用ツール
文書の表示
バックリンク
文書の先頭へ