WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.9 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Search News Posts Only From News Page
  • Print
Pages: [1]   Go Down

Author Topic: Search News Posts Only From News Page  (Read 13375 times)

Offline gillweb

  • Posts: 83
Search News Posts Only From News Page
« on: October 28, 2007, 10:08:12 PM »
I can't say this is the PERFECT solution but it seems to work for me  :-D

Make a new CODE page that is hidden name "search news" (i added it as a child page of my news page).  Add this code to this page
Code: [Select]
$string = @$_POST['string'];
$query = "SELECT * FROM mod_news_posts WHERE content_long LIKE '%$string%'";
$result = mysql_query($query);
$rows=mysql_num_rows($result);

if ($rows == 0) { echo" No Results"; }

   $error = mysql_error();
      if (!$result = mysql_query($query)) {
           print "$error";
       }

while($data = mysql_fetch_object($result)){
$title = $data->title;
$link = $data->link;
$short= $data->content_short;

echo '<p>';
echo '<b>'.$title.'</b><br />';
echo ''.$short.' ';
echo '<a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'">Read More...</a></p>';

}
Then add a Code sectin to you main news page where you want your search box to show and enter this code:
Code: [Select]
echo "<br /><center><form method=\"post\" action=\"";
echo WB_URL;
echo "/pages/news/search-news";
echo PAGE_EXTENSION;
echo  "\">";
echo "<input type=\"text\" maxlength=\"64\" name=\"string\" />&nbsp;&nbsp;&nbsp;";
echo "<input type=\"submit\" value=\"Search News\" />";
echo "</form></center><br />";
You should be good to go now  :mrgreen:
Logged

jar

  • Guest
Re: Search News Posts Only From News Page
« Reply #1 on: June 27, 2008, 10:55:16 AM »
i have a error


Fatal error: Cannot redeclare search_highlight() (previously declared in /home/tusirom1/public_html/framework/frontend.functions.php:70) in /home/tusirom1/public_html/framework/frontend.functions.php on line 92
Logged

thorn

  • Guest
Re: Search News Posts Only From News Page
« Reply #2 on: June 27, 2008, 07:12:16 PM »
Hello,

there is a handy - yet not(?) documented - new search-feature since wb2.7:
see https://forum.WebsiteBaker.org/index.php/topic,10058.msg59052.html#msg59052

To search in news-postings only you can do this to add a search-box: (if the news-pages appears as http://www.example.org/pages/news.php)
Code: [Select]
<form name="search" action="<?php echo WB_URL.&#39;/search/index&#39;.PAGE_EXTENSION; ?>" method="get">
  <input type="hidden" name="search_path" value="/news">
  <input type="text" name="string" value="search" /><br />
  <input type="submit" value="Search" /><br />
  <input type="radio" name="match" id="match_all" value="all" checked="checked" /><label for="match_all">All Words</label>
  <input type="radio" name="match" id="match_any" value="any" /><label for="match_any">Any Words</label>
  <input type="radio" name="match" id="match_exact" value="exact" /><label for="match_exact">Exact Match</label>
</form>

thorn.
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Search News Posts Only From News Page
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2