0
我想,如果下面的語句只出現在某些頁面(例如,我不希望他們圍繞整個結構,如果這是一個用戶頁面):將php if語句應用於另一個if語句?
<div class="mainbar">
<?php if /* I don't want this and... */ (bbp_has_topics($bbp_loop_args)) : ?>
<?php while (bbp_topics()) : bbp_the_topic(); ?>
<div class="topic-wrapper">
<div class="topic-left">
<h2><a href="<?php bbp_topic_permalink(); ?>" title="<?php bbp_topic_title(); ?>"><?php bbp_topic_title(); ?></a></h2>
<span><?php printf(__('Started by: %1$s', 'bbpress'), bbp_get_topic_author_link(array('size' => '14'))); ?></span>
<?php if (!bbp_is_forum() || (bbp_get_topic_forum_id() != bbp_get_forum_id())) : ?>
<span class="bbp-topic-started-in"><?php printf(__('in: <a href="%1$s">%2$s</a>', 'bbpress'), bbp_get_forum_permalink(bbp_get_topic_forum_id()), bbp_get_forum_title(bbp_get_topic_forum_id())); ?></span>
<?php endif; ?>
<?php bbp_topic_tag_list(); ?>
</div><!-- #topic-left -->
<div class="topic-right">
<div class="topic-like-count">
<h4><?php // bbp_topic_reply_count(); ?><?php if(function_exists('the_ratings')) { the_ratings(); } ?></h4>
<span><?php _e('likes'); ?></span>
</div>
<div class="topic-reply-count">
<h4><?php bbp_topic_reply_count(); ?></h4>
<span><?php _e('replies'); ?></span>
</div>
<div class="topic-freshness">
<h4><?php bbp_topic_freshness_link(); ?></h4>
<span>
<?php bbp_author_link(array('post_id' => bbp_get_topic_last_active_id(), 'size' => 14)); ?>
</span>
</div>
</div><!-- #topic-right -->
</div><!-- #topic -->
<?php /* this to appear in an user page */ endwhile; ?>
<?php endif; ?>
</div><!-- #mainbar -->
這是if語句我應該用來確保if語句不包圍用戶頁面中的整個結構:
<?php if (! is_single('user')) : ?>
<?php endif; ?>
但是我不知道如何或在何處放置它。
有什麼建議嗎?
對不起,我不明白你的意思。 – phant0m
@ phant0m if語句'<?php while(bbp_topics()):bbp_the_topic(); ''不應該只在某些頁面中圍繞整個結構。如果結構中沒有if語句,則某些頁面纔有效。 – alexchenco
「if語句:while」 - 什麼是while語句?所以基本上,你希望某些控制結構只能在特定的頁面上工作。你需要檢查他們。假設你有一個允許的站點數組和一個當前站點的變量:'if(in_array($ site,$ allowed_sites)&&())' –
phant0m