Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: 1 ... 8 9 [10]

Author Topic: sNews 1.4 - General Bugs and Comments  (Read 66265 times)

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
sNews 1.4 - General Bugs and Comments
« Reply #135 on: May 14, 2006, 11:56:22 AM »

@bram:
Actually, these unpublished articles don't apear in archives section for me either, they're just brought up whenever I do a search and they contain the search term...
Thanks for trying, and I would try your suggestion with creating another database but unfortunatelly, I can have only two MySQL databases and both are taken...
For now I have simply stored these unpublished articles on my PC in a txt file instead on the server. Sometimes the simpliest solutions work the best ;) good thing this is only my sNews, which implies I somehow managed to broke it...
Logged

Rod

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 78
    • http://www.rjs-custom.com
sNews 1.4 - General Bugs and Comments
« Reply #136 on: May 14, 2006, 08:24:34 PM »

Just a posible solution with the search returning the unpublished articles.

Look for this line in the search function
Code: [Select]
$query = "SELECT * FROM " .s('prefix'). "articles WHERE title LIKE '$search_query_var' || text LIKE '$search_query_var' AND position <> 2 AND published = 1 ORDER BY id DESC";change it to this:
Code: [Select]
$query = "SELECT * FROM " .s('prefix'). "articles WHERE title LIKE '$search_query_var' || text LIKE '$search_query_var' AND position <> 2 AND position != 4 AND published = 1 ORDER BY id DESC";might be the solution to the problem.

cheers
Logged
Whatever went wrong, I am pretty sure I didn't do it!  Well atleast I think I didn't do it...

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
sNews 1.4 - General Bugs and Comments
« Reply #137 on: May 14, 2006, 09:33:23 PM »

Thanks dobey, but unfortunately this didn't solve the problem.

BTW, what does this do to the search engine?

Here is how my search function looks like now:
Code: [Select]
// SEARCH ENGINE
function search() {
$search_query = clean($_POST['search_query']);
$search_query_var = "%".$search_query."%";
echo "

". l(search_results) ."

";
if (strlen($search_query) < 4) {
echo "

". l(charerror) ."

";
} else {
$query = "SELECT * FROM " .s('prefix'). "articles WHERE title LIKE '$search_query_var' || text LIKE '$search_query_var' AND position <> 2 AND position != 4 AND published = 1 ORDER BY id DESC";
$result = mysql_query($query);
while ($r = mysql_fetch_array($result)) {
$num++;
$date = date(s('date_format'), strtotime($r['date']));
echo "

" .$r['title']. " > " . $date. "

";
}
if ($num == "") { echo "

". l('noresults') ." " . $search_query . ".

";
$num = "0";
} else { echo "

" . $num . " ". l('resultsfound') ." " . $search_query . ".

"; }}
echo "


". l('backhome') ."

";
}
Logged

bramsyuur

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 23
  • Posts: 900
    • http://snews.vietbee.net
sNews 1.4 - General Bugs and Comments
« Reply #138 on: May 14, 2006, 09:38:57 PM »

Hi Dom,
What about using prefixes in an existing database for make your new database and make your test whit it?
Only a suggestion...
Thanks,
bram.

Quote from: Dom
@bram:
Actually, these unpublished articles don't apear in archives section for me either, they're just brought up whenever I do a search and they contain the search term...
Thanks for trying, and I would try your suggestion with creating another database but unfortunatelly, I can have only two MySQL databases and both are taken...
For now I have simply stored these unpublished articles on my PC in a txt file instead on the server. Sometimes the simpliest solutions work the best ;) good thing this is only my sNews, which implies I somehow managed to broke it...
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Espaņol

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
sNews 1.4 - General Bugs and Comments
« Reply #139 on: May 15, 2006, 01:34:32 PM »

Thanks for the suggestion bram, but since I'm only a newbie in SQL, I'd need some help with it so I don't damage my existing data. Could you please provide me with the exact SQL query I should run in phpMyAdmin? I can assume how it should look like but I would like to be sure before I do anything.
Logged

bramsyuur

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 23
  • Posts: 900
    • http://snews.vietbee.net
sNews 1.4 - General Bugs and Comments
« Reply #140 on: May 15, 2006, 03:34:41 PM »

Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Espaņol

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
sNews 1.4 - General Bugs and Comments
« Reply #141 on: May 16, 2006, 06:04:00 PM »

OK, I have first created a set of new tables with a prefix which I defined in snews.php as per instructions. I used my current snews.php file for this test (copied it in a subfolder and edited the global settings).
Like that I couldn't create new articles - I'd login, create a new article (published) and there would be no article after that (checked the database - it was empty). Since I added some new functions like meta tags mod I thought maybe this mod is a problem since it enables writing information into two new fields, which I didn't create this time in the databse - so I moved the mod and tried again. Same result. I'd create an article and it wouldn't be written into the database.

I had to try it with the current snews.php file so I could determine whether the problem is in it or not. But I was now tired of this not working and I replaced the snews.php with the new one (fresh download).
I was now able to create articles and they would nicely show up immediatelly after being created so it was time to test - I created a new, unpublished article, searched for it, and guess what - it showed up in search results.

What does this tell us? The problem obvioulsy isn't in my modified snews.php file. So where is it? Could it be something server related?
Logged

bramsyuur

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 23
  • Posts: 900
    • http://snews.vietbee.net
sNews 1.4 - General Bugs and Comments
« Reply #142 on: May 18, 2006, 09:21:56 PM »

@Dom:
I've found a solucija!!!
Finding into this forum I've found a solution using a Matt's Search function and modified for not showing unpublished records in the search.
Try to change your SEARCH FUNCTION with this one:
Code: [Select]
function search() {
    $search_query = clean($_POST['search_query']);
    $search_query_var = "%".$search_query."%";
    echo "

". l(search_results) ."

";
    if (strlen($search_query) < 3) {
        echo "

". l(charerror) ."

";
    } else {
        // Matt 11/3/06 13:24 - build up the SQL query so we can use multiple keywords
        $keywords = explode(" ",$search_query);
        $query = "SELECT * FROM " .s('prefix'). "articles WHERE";
        if (count($keywords) >= 2) {
            for ($i=0;$i                $query = $query . " (title LIKE '%$keywords[$i]%' || text LIKE '%$keywords[$i]%') ||";
            }
            $j = count($keywords)-1;
            $query = $query . " (title LIKE '%$keywords[$j]%' || text LIKE '%$keywords[$j]%')";
        } else {
            $query = $query . " (title LIKE '%$keywords[0]%' || text LIKE '%$keywords[0]%')";
        }
        $query = $query . " AND position <> 2 AND position != 4 ORDER BY id DESC";
        // ttaM
        $result = mysql_query($query);
        while ($r = mysql_fetch_array($result)) {
            $num++;
            $date = date(s('date_format'), strtotime($r['date']));
            echo "

" .$r['title'].
"
> " . $date. "

";
        }
    if ($num == "") { echo "

". l('noresults') ." " . $search_query . ".

";
        $num = "0";
    } else { echo "

" . $num . " ". l('resultsfound') ." " . $search_query . ".

"; }}

    echo "


". l('backhome') ."

";
}
With this code, not only don't show unpublished articles in your search, apart, you can search multiple keywords, for example: snews templates
bram.
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Espaņol

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1746
    • http://www.snewscms.com
sNews 1.4 - General Bugs and Comments
« Reply #143 on: May 18, 2006, 09:40:05 PM »

Nice job :)
Logged

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
sNews 1.4 - General Bugs and Comments
« Reply #144 on: May 18, 2006, 11:12:35 PM »

Well done bram!
I applied this and it works.

Thank you very much!
Logged
Pages: 1 ... 8 9 [10]