ExpressionEngine用户组模块的搜索功能
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ExpressionEngine用户组模块的搜索功能相关的知识,希望对你有一定的参考价值。
This is a simple search function for the [User Groups](http://www.dabbledoo.com/design/docs/User-Groups-Module/) module for ExpressionEngine. It searches groups (names and descriptions) as well as topics and topic replies. It respects group types as well - results from private groups will not show up in the topic or topic replies search results."groups/search.php" is below - it relies on the search form at the very top.
<form id="group_search" method="post" action="{homepage}/groups/search/"> <input type="text" id="group_search_box" name="group_search_box" /> <input type="hidden" id="member_id" name="member_id" value="{member_id}" /> <input type="radio" name="search" value="search_discussions" id="search_discussions" checked>Discussions <input type="radio" name="search" value="search_groups" id="search_groups"> Groups<br> <input type="submit" value="Submit"/> </form> <?php { global $DB, $REGX; $_POST = $REGX->xss_clean( $_POST ); $_POST = $REGX->strip_quotes( $_POST ); if ($_POST['search'] == 'search_groups') { $query = $DB->query("SELECT user_group_name, user_group_description, user_group_status, user_group_type, user_group_id, user_group_url_title FROM exp_user_groups WHERE (user_group_name LIKE '%".$_POST['group_search_box']."%' OR user_group_description LIKE '%".$_POST['group_search_box']."%') AND user_group_status='open'"); $num_rows=$query->num_rows; if ( $query->num_rows == 0 ) { echo "No groups could be found matching your search."; } else { echo "<p>You searched Groups for "<strong>".$_POST['group_search_box']."</strong>".<br />"; echo "There are ".$query->num_rows." results.<br>"; foreach($query->result as $row) { ?> <a href="{homepage}/groups/<?php echo $row['user_group_url_title'];?>/<?php echo $row['user_group_id'];?>/"> <?php echo $row['user_group_name'];?></a> - <?php echo $row['user_group_description'];?><br> <?php } } } if ($_POST['search'] == "search_discussions") { /* Topic Search*/ $query = $DB->query("SELECT exp_user_groups_topics.user_group_id, exp_user_groups_topics.topic_id, exp_user_groups_topics.subject, exp_user_groups_topics.entry_date FROM exp_user_groups, exp_user_groups_topics WHERE ( exp_user_groups_topics.subject LIKE '%".$_POST['group_search_box']."%' OR exp_user_groups_topics.body LIKE '%".$_POST['group_search_box']."%' ) AND exp_user_groups_topics.status = 'open' AND ( exp_user_groups.user_group_type = 'public' OR exp_user_groups.user_group_type = 'moderated' ) AND exp_user_groups.user_group_id = exp_user_groups_topics.user_group_id" ); $num_rows=$query->num_rows; if ( $query->num_rows == 0 ) { echo "No discussion topics could be found matching your search."; } else { echo "<p>You searched Discussions topics for "<strong>".$_POST['group_search_box']."</strong>".<br />"; echo "There are ".$query->num_rows." results.<br>"; foreach($query->result as $row) { ?> <a href="{homepage}/groups/talk/<?php echo $row['user_group_id'];?>/<?php echo $row['topic_id'];?>/"> <?php } } /* Reply Search */ $query = $DB->query( "SELECT exp_user_groups_topics.user_group_id, exp_user_groups_replies.reply_id, exp_user_groups_replies.body, exp_user_groups_replies.entry_date, exp_user_groups_topics.subject, exp_user_groups_topics.topic_id FROM exp_user_groups, exp_user_groups_replies, exp_user_groups_topics WHERE exp_user_groups_replies.body LIKE '%".$_POST['group_search_box']."%' AND exp_user_groups_replies.status = 'open' AND ( exp_user_groups.user_group_type = 'public' OR exp_user_groups.user_group_type = 'moderated' ) AND exp_user_groups.user_group_id = exp_user_groups_topics.user_group_id AND exp_user_groups_topics.topic_id = exp_user_groups_replies.topic_id" ); $num_rows=$query->num_rows; if ( $query->num_rows == 0 ) { echo "No replies could be found matching your search."; } else { echo "<p>You searched Discussion replies for "<strong>".$_POST['group_search_box']."</strong>".<br />"; echo "There are ".$query->num_rows." results.<br>"; foreach($query->result as $row) { ?> <a href="{homepage}/groups/talk/<?php echo $row['user_group_id'];?>/<?php echo $row['topic_id'];?>/<?php echo $row['reply_id'];?>/" /> Permalink</a> - <?php echo date("Y-m-d H:i:s", $row['entry_date']);?> in the <a href="{homepage}/groups/talk/<?php echo $row['user_group_id'];?>/<?php echo $row['topic_id'];?>/"> <?php echo $row['subject'];?></a> topic.<br> <?php } } } } ?>
以上是关于ExpressionEngine用户组模块的搜索功能的主要内容,如果未能解决你的问题,请参考以下文章
JavaScript ExpressionEngine的实时评论预览
ini 扩展ExpressionEngine .htaccess / apache conf
ini 扩展ExpressionEngine .htaccess / apache conf
Expressionengine 上一个 下一个 仅显示 1 个类别
php https://expressionengine.com/forums/topic/160486/views-unable-to-load-the-requested-file#773142