Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: Integrating search results using ajax?  (Read 8679 times)

amak

  • Newbie
  • *
  • Karma: 4
  • Posts: 40
Integrating search results using ajax?
« on: August 09, 2008, 09:56:14 am »

Hi,

I've found this today ... what do you think about integrating this as mod for snews?
Logged
Regards,
Amak

Ken Dahlin

  • Full Member
  • ***
  • Karma: 30
  • Posts: 139
    • http://www.kendahlin.com/
Re: Integrating search results using ajax?
« Reply #1 on: August 10, 2008, 11:14:08 pm »

Hi,

I've found this today ... what do you think about integrating this as mod for snews?

I recommend http://jquery.bassistance.de/autocomplete/demo/, an autocomplete plugin for jquery. A minor bug prevents the code you cited from running... not that it won't run, it's just not well tested or documented. If you have some time look at some of the other cool things jquery can do.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Integrating search results using ajax?
« Reply #2 on: August 13, 2008, 09:02:35 pm »

@Ken....sine I've been at this new job, I'm using jQuery a lot.  I LOVE IT for admin side options.  Not sure how much I'd want to use javascript on the site visitor side though (for those that have js disabled).  But when I have more time, I'm planning on making a AJAXed version of the sNews admin panel using jQuery.

I'll look forward to that Bob.  ;D
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

jared351

  • Sr. Member
  • ****
  • Karma: 4
  • Posts: 276
Re: Integrating search results using ajax?
« Reply #3 on: August 14, 2008, 01:37:55 am »

Me three!  ;)
Logged

Ken Dahlin

  • Full Member
  • ***
  • Karma: 30
  • Posts: 139
    • http://www.kendahlin.com/
Re: Integrating search results using ajax?
« Reply #4 on: August 14, 2008, 03:52:33 am »

@Ken....sine I've been at this new job, I'm using jQuery a lot.  I LOVE IT for admin side options.  Not sure how much I'd want to use javascript on the site visitor side though (for those that have js disabled).  But when I have more time, I'm planning on making a AJAXed version of the sNews admin panel using jQuery.

This is exactly what I had in mind when I started looking into jQuery and with all the practical experience you're getting on the job, an ajax sNews admin should come fast. I was surprised at how fast coding in this framework goes. Very exciting news, good luck with this!
Logged

Joost

  • Guest
Re: Integrating search results using ajax?
« Reply #5 on: August 14, 2008, 04:09:07 am »

I am always skeptic about hyped techniques. So here is a question. How will sNews benefit from Ajax?
Logged

Ken Dahlin

  • Full Member
  • ***
  • Karma: 30
  • Posts: 139
    • http://www.kendahlin.com/
Re: Integrating search results using ajax?
« Reply #6 on: August 14, 2008, 07:00:32 am »

I am always skeptic about hyped techniques. So here is a question. How will sNews benefit from Ajax?

Me too, I remember being very skeptical about GUI during the transition from text based programs and command lines to the graphical. In the end I had to admit that the benefit of convenience and speed outweighed whatever benefit felt I had with pure text. In the same way, Ajax would (or should) make the admin interface more like a desktop program. So If for no other reason, reducing the number of full page refreshes during an admin session would make the technology worth it.

I should add that I don't think something like this should be built into the core of a standard release of sNews, but only as a mod for the admin side of things.
Logged

Joost

  • Guest
Re: Integrating search results using ajax?
« Reply #7 on: August 14, 2008, 08:00:37 am »

There is not much significant to refresh in the backend (as there is usually only one administrator), only a few kilobytes. In most cases it is not the bottleneck anyway. "refreshments" are most likely coming from the database and need to be processed by php. Since we are talking about the backend, we need to take into account that it is a two-way process (updating first and then viewing the result).
 If any bottlenecks, slowing down refreshing pages, I would look there first.

Maybe I need to rephrase my question: What needs to be done, that needs ajax, or jQuery in particular, so badly?
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Integrating search results using ajax?
« Reply #8 on: August 14, 2008, 09:01:32 am »

I faced the problem for a friend website who had to use recently a lightbox for displaying images.
But the script weighs 100 kb :o.
For a Lightbox (no as much bling bling as the original, I must admit) there are other ways.
I recently wrote 2 articles:
That one just using DOM:
A light box without framework
That other with no Javascript at all. Only 1 image and pure CSS:
A Lightbox without Javascript
Lightweight!


Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Integrating search results using ajax?
« Reply #9 on: August 14, 2008, 02:25:56 pm »

Maybe I need to rephrase my question: What needs to be done, that needs ajax, or jQuery in particular, so badly?

Well... to be accurate... no one was suggesting Ajax or jQuery is "badly needed" in sNews. When I read Bakercad's statement...
       when I have more time, I'm planning on making a AJAXed version of the sNews admin panel using jQuery.
I took this to mean he wants to explore how jQuery functions might improve the sNews Administration panels... not that sNews needed jQuery.
While the jQuery Library includes several functions that might not be used... it is a Library and it is really up to the developer/programmer to learn how to put them to good use. The jQuery site does provide numerous examples and tutorials on how its included functions can be put to use. The end result is yet to be discovered.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Integrating search results using ajax?
« Reply #10 on: August 14, 2008, 05:47:06 pm »

7. Managing mass content (articles/comments) ...

This MOD can beat any records on downloading/applying it....

And here is a great paradox:
We keep user area for us as programmers (the code) and offer the admin area to the users(clients) (as interface).... if you know what I'm talking....
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Integrating search results using ajax?
« Reply #11 on: August 14, 2008, 07:43:24 pm »

I like your ideas Mr. Baker... these are worth exploring indeed.
Perhaps... as Funlw65 seems to be suggesting (above)... we can have the admin function-set separated into its own file away from the front-end function-set.
Maybe doing the separation first with the default file-set then it would be a matter of substituting one admin function-set for the other with minimal (or no) changes to the front-end function-set.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Joost

  • Guest
Re: Integrating search results using ajax?
« Reply #12 on: August 16, 2008, 07:29:30 am »

Maybe I need to rephrase my question: What needs to be done, that needs ajax, or jQuery in particular, so badly?

Well... to be accurate... no one was suggesting Ajax or jQuery is "badly needed" in sNews.
Neither did I say someone did, to be accurate. It was a question in response to Ken's post, the only response to my initial question at that time. Didn't know whether the question was clear to Ken, so I rephrased it for that matter. It is the type of question I  ask (mostly asking myself, that is) to enforce weighing the pros and cons of a certain approach or tool.
Philippe's  example is great for that matter: A generic purpose script, is not always the right solution for one specific task. At the same time can be said, that when a bunch of features depend upon one script, that might be an ideal situation.

As for Bakercad's ideas:
1) - Ordering *: I would definitely like to see this in a core distribution. I believe however, that a simple (small) drag and drop script, can do the trick. No ajax needed here, just let the administrator press the submitbutton after finishing  the order.
Everything else I consider fit for the mod section.
2) - Autosave: Quite some changes might be needed in the core (function processing). Consider the following:
- Author (actor) starts with content and leaves the title empty, untilll finishing the content (not an unusual approach).
- Author (actor) changes title to an already existing title, while content is already inserted.
3 + 4) Should be no problem.
5)  I guess a lot of user want that as a core feature. Very user friendly, But then they would want a wisiwig editor as well, I guess. Some of the major wisiwig editors have got such feature included.
6) Adds an extra step (mouse click). I don't see the purpose of doing that. It reminds me however, that a navigational menu for admin pages might be usefull.

*) TIP: Some of you might know this already:

It is allowed to use arrays in name attributes which can be send through $_POST or $_GET and is understood by PHP
You can have php sent the following  form to the client (editor). 'value' contains the current value of field `artorder`:

<label><input type="hidden" name="new_order[]" value="1" />Content title1</label> // php receives: new_order[0] = 1
<label><input type="hidden" name="new_order[]" value="2" />Content title2</label> // php receives: new_order[1] = 2
<label><input type="hidden" name="new_order[]" value="3" />Content title3</label> // php receives: new_order[2] = 3
<label><input type="hidden" name="new_order[]" value="4" />Content title4</label> // php receives: new_order[3] = 4

The order can be changed client side ( jQuery or any javascript that handles drag & drop), the key order remains the same without recalculating.

<label><input type="hidden" name="new_order[]" value="4" />Content title4</label> // php receives: new_order[0] = 4
<label><input type="hidden" name="new_order[]" value="1" />Content title1</label> // php receives: new_order[1] = 1
<label><input type="hidden" name="new_order[]" value="2" />Content title2</label> // php receives: new_order[2] = 2
<label><input type="hidden" name="new_order[]" value="3" />Content title3</label> // php receives: new_order[3] = 3

The browser then sends the (reordered)  form back to the server. There it is processed like:

$category =  (int) $_POST['category']) ;
foreach ($_POST['new_order'] as $new => $old) {
if( (int)$new === (int)$old) continue; // Move to next loop. No query needed
mysql_query('UPDATE articles SET artorder='.$new.' WHERE category ='.$category.' AND artorder='. $old);
}
(not tested, not even seen in a syntax highlighter)
« Last Edit: August 16, 2008, 07:59:47 am by Joost »
Logged

Ken Dahlin

  • Full Member
  • ***
  • Karma: 30
  • Posts: 139
    • http://www.kendahlin.com/
Re: Integrating search results using ajax?
« Reply #13 on: August 17, 2008, 02:31:58 am »


Maybe I need to rephrase my question: What needs to be done, that needs ajax, or jQuery in particular, so badly?


Obviously things can be done (and are being done to a certain extent) without the overhead of a javascript framework but it's really nice, I think, when a multitude of features are added (like Bakercad's ideas) and then the code can be reused. My preference for jQuery is probably not as well informed as it should be because I've only looked into that and http://script.aculo.us I've found jQuery to be better for browser compatibility, code size and ease of use. Maybe others could weigh in on their experiences.
Logged