XPressME Integration Kit

フォーラム

Re: category-iconsの「最近の記事内容」への反映について

#2887
toemon
キーマスター

テスト結果の報告をいたします。

結論からいうと、「最近の記事内容」ブロックへのカテゴリーアイコンの表示はとくに問題なく行えました。

ky982339さんがrecent_posts_content_block_theme.phpをどのように変更されたのかわからないのでなんとも言えませんが

たぶんsmarty変数にassignされない部分に

<?php if (function_exists(‘get_cat_icon’)) get_cat_icon(); ?>

コードの挿入を行っているのではないでしょうか?

以下簡単な説明です。

recent_posts_content_block_theme.phpなどのthemes/xpress_default/blocks内にあるphpファイルは各ブロックのテーマで使用するsmarty変数にassignされるデータを作成しています。

recent_posts_content_block_theme.phpがassignするsmarty変数の詳細については、「最近の記事内容ブロック」を参照ください。

ここでXPressMEのrecent_posts_content_blockのDBテンプレートはデフォルトで

<div class="xpress_block"><br />
<{$block.err_message}><br />
<div class="xpress_recent_post_content_block"><br />
<ul><br />
<{foreach from=$block.contents item=content}><br />
<{$content.all_in_one}><br />
<{/foreach}><br />
</ul><br />
<br />
</div><br />
</div>

となっており、「all_in_one」smarty変数の表示だけが行われています。

「all_in_one」表示内容は

themes/xpress_default/blocks/recent_posts_content_block_theme.php上では109行目あたりから定義されており

// all_in_one<br />
ob_start();<br />
?><br />
<div class="xpress-post" id="post-<?php the_ID(); ?>"><br />
<div class ="xpress-post-header"><br />
<?php if (function_exists('hotDates')) { hotDates(); }?><br />
<div class ="xpress-post-title"><br />
<?php if(function_exists('the_title_attribute')) : ?><br />
<h2><a>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'xpress'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2><br />
<?php else : ?><br />
<h2><a>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'xpress'), the_title('','',false)); ?>"><?php the_title(); ?></a></h2><br />
<?php endif; ?><br />
<br />
</div><br />
</div><br />
<div class="xpress-post-entry"><br />
<?php	echo $post_content; ?><br />
</div><br />
<div class="xpress-link-pages"><?php wp_link_pages() ?></div><br />
<div class ="xpress-post-footer"><br />
<?php<br />
the_time('Y/m/d l');<br />
echo ' - ';<br />
the_author_posts_link();<br />
echo ' (' . xpress_post_views_count('post_id=' . $post->ID . '&format=' . __('Views :%d', 'xpress'). '&echo=0') . ')';<br />
<br />
echo ' | ';<br />
// echo the_tags(__('Tags:', 'xpress') . ' ', ', ', ' | ');<br />
printf(__('Posted in %s', 'xpress'), get_the_category_list(', '));<br />
echo ' | ';<br />
edit_post_link(__('Edit', 'xpress'), '', ' | ');<br />
comments_popup_link(__('No Comments »', 'xpress'), __('1 Comment »', 'xpress'), __('% Comments »', 'xpress'), '', __('Comments Closed', 'xpress') );<br />
?><br />
</div><br />
</div><br />
<?php<br />
$all_in_one = ob_get_contents();<br />
ob_end_clean();<br />

上記の

ob_start()

 ・

 ・

$all_in_one = ob_get_contents();

ob_end_clean();

の間に

<?php if (function_exists(‘get_cat_icon’)) get_cat_icon(); ?>を導入することで、「all_in_one」smarty変数へカテゴリーアイコンの出力を追加することができます。

またカテゴリーアイコンだけのsmarty変数を作成する場合、

ループのどこかに

if (function_exists('get_cat_icon')){<br />
ob_start();<br />
get_cat_icon();<br />
$cat_icon = ob_get_contents();<br />
ob_end_clean();<br />
}<br />

とかを置いて

$row_data の配列に

‘cat_icon’ => $cat_icon を追加することで テンプレート側から <{$content.cat_icon}>という形で使用することも可能です。