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 [2]

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

Joost

  • Guest
Re: Integrating search results using ajax?
« Reply #15 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

  • sNews Dude
  • Full Member
  • *****
  • Karma: 30
  • Posts: 143
    • http://www.kendahlin.com/
Re: Integrating search results using ajax?
« Reply #16 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

bakercad

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 105
  • Posts: 1670
    • http://exit20.com
Re: Integrating search results using ajax?
« Reply #17 on: March 17, 2009, 06:41:55 PM »

I know it's been a while since I've post here, but.....i'm in love with jQuery.  :D

For work, I've built a AJAX search & a bunch of other things using jQuery, including inline editing....etc, etc.  jQuery is VERY capable.  When I eventually get some spare time, I'm definitely work on a jQueried version of sNews.
Logged
Pages: 1 [2]