Search form for entries
-
Is there any chance to add a search form for the guestbook entries? Is this somehow included in the add-on?
(I’m trying to use this plugin as a wiki-notes for some of mine authorized users)
-
Hi, it’s the first time I get this question ??
I assume you mean on the frontend, right?
Maybe there could be a widget that searches on the content and autor name of the entry.
It might be that if I add it, it will be added to the add-on.
I will think about it. It won’t be built this month, I am a bit tied up.
Any more feedback or idea is always welcome.Hi Marcel, thank you for your flash reply!
Yes, frontend.
I’m going to try with my own solution, I’m not a coder but I can share my work with you if I’ll be able to get what I need.
It’s the first time of this request probably because I’m trying your plugin for a quite specific use case: I need a single-page wiki with some of my users over a specific topic (exchange of acupuncture recipes!).. a search form is mandatory for this as you can figure out !I coded my own solution (my variables between ++). I put into a wordpress template the search module and results display:
SEARCH FORM
<?php echo '<form role="search" method="get" id="searchform" class="searchform" action="+my_page_url+"> <h4>CERCA TRA LE RICETTE</h4> <input type="text" value="'; if( isset( $_REQUEST['cerca'] ) ) : echo $_GET['cerca']; endif; echo '" name="cerca" id="cerca" autocomplete="off"/><input type="submit" id="invia" value="CERCA" /> </form></br>'; ?>
RESULTS
<?php if( isset( $_REQUEST['cerca'] ) ) : $str = $_GET['cerca']; $servername = "+my_localhost+"; $username = "+my_username+"; $password = "+my_pwd+"; $dbname = "+my_dbname+"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); $conn->set_charset("utf8"); // Check connection if ($conn->connect_error) { die("Ho un problema con la connessione al Database: " . $conn->connect_error); } $sql = "SELECT author_id, author_name, content FROM wp_gwolle_gb_entries WHERE author_name LIKE '%".$str."%' OR content LIKE '%".$str."%'"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<div id='gwolle_gb_write_button'> <a class='button btn btn-default' style='color:#000;' href='+my_page_url+'>Torna Indietro</a> </div></br>"; while ($row = $result->fetch_assoc()) { echo " <div id='gwolle_gb_entries' class='gwolle_gb_infinite gwolle-gb-infinite' data-book_id='1'> <div class='gb-entry gb-entry_2 gb-entry-count_1 gwolle_gb_uneven gwolle-gb-uneven gwolle_gb_first gwolle-gb-first'> <article class='button' style='color:#000;'> <div class='gb-author-info' style='font-weight:bold;'> <span class='gb-author-name'><i class='gb-moderator'>".$row['author_name']."</i> </span> </div> <div class='gb-entry-content'>".$row['content']."</div> </article><br> "; } //end while $result->free(); } else { echo "Mi dispiace, non ho trovato niente con questi termini di ricerca !"; } $conn->close(); else : if( have_posts() ) : the_post(); the_content(); endif; endif; //fine if request cerca ?>
Now I’m buying your add-on because I’d like to have a simply way to customize strings. Hope this little contribution will help and will give some credits to me, to spend in future occasions in which I could need your help! ??
Okay, hope it works for you.
If it is build into the plugin it has to be done in a different way. I cannot add a page template.For database acces, it is almost always a good idea to use $wpdb and its methods. That way you are independant of the underlying functionality, whether you use mysql or mysqli module.
Thank you Marcel. I’m just a good copypaster ?? but I know I should try to follow your suggestion.
In the meanwhile, I’ve changed the search query, using the natural language search in mysql
So I added a fulltext index to the guestbook entries table and used this query:SELECT id, author_id, author_name, content FROM wp_gwolle_gb_entries WHERE MATCH (author_name, content) AGAINST (‘”.$str.”*’ IN BOOLEAN MODE)
This made my day. And in fact it’s midnight here ??
- This reply was modified 6 years, 1 month ago by carloeucandido.
Other suggestion for the AddOn: give some tool to assign moderate_comments rights to some user groups or user roles other than administrator/editor/author
Thanks.
I do think this is covered by the plugin User Role Editor, where you can create new roles and adjust capabilities for those roles.Yes, I came up just with that solution, thank you Marcel! ??
Moreover, I overwrote some strings added by the AddOn (e.g. “Admin Reply”, frontend) in the language .po file, because that strings replacement is not covered by your AddOn tool
- The topic ‘Search form for entries’ is closed to new replies.