Forums / Cotonti / Core Labs / Archive / Core AJAX support

Selectable AJAX/normal behavior implementation

Trustmaster
#1 2008-10-23 00:44
The modern Web 2.0 tendencies require that more and more actions on site can be performed without reloading the page: navigating between pages, sending forms and viewing results.

On the other hand, most of websites must be easy to crawl for a search engine. And some users have JavaScript switched off for security. So it is also a must to have a normal, synchronous requests available for them.

Combining both, CMS architects have come up to the idea of duality in CMS behavior, so that there are 2 methods to get the same page: in a traditional full-HTML way and in AJAX contents-only. Of course, it requires much more changes on a client side and the changes are not so dramatic in the core.

Implementing this feature in Seditio-N contains 3 parts:
[list=1]
  • Adding the appropriate logical switches and layout control, depending on presence of AJAX flag in script parameters, in the core PHP scripts.
  • Providing strong core JavaScript API for this AJAX feature (using jQuery).
  • Making skins with support of this feature, utilizing the API.

  • As Seditio layout templates are not XML-based and all the generated output is (X)HTML, such formats as XML or JSON would require massive changes of all the existing code to support AJAX. That is why I think the output format should stay the same (XHTML), what's different is that the core invokes and returns only those parts of the page which are expected to change.

    I would call this feature experimental and I'm going to implement it on a live site first during November and then merge a working version of it into the core.

    And now let the brainstorm begin.
    May the Source be with you!
    Lombi
    #2 2008-10-23 02:46
    This sounds awesome. The only things I'm worried about is:

    - crawler compatibility (which you already covered)
    - page changing without reloading and it's effects on the publishers that are funded by PPC companies like google/yahoo/adbrite/whatever
    <a href="http://www.domenlo.com">Surreal Art</a>
    Dayver
    #3 2008-10-23 03:44
    If I understood it to perform this function in Seditio-N plans to implement the switch that will be available to visitors to the site (more so is it for him) to switch between AJAX / "traditional full path"? Or, this switch will be automatic that reacts to the "inclusion" JavaScript on the client side (and/or the fact whether the visitor search bot)?

    I think the switch should be automatic
    Pavlo Tkachenko aka Dayver
    Trustmaster
    #4 2008-10-23 13:08
    Lombi:
    page changing without reloading and it's effects on the publishers that are funded by PPC companies like google/yahoo/adbrite/whatever
    This means that you will have to put your PPC ads into page bodies rather than header/footer on AJAX websites.

    Dayver:
    If I understood it to perform this function in Seditio-N plans to implement the switch that will be available to visitors to the site (more so is it for him) to switch between AJAX / "traditional full path"? Or, this switch will be automatic that reacts to the "inclusion" JavaScript on the client side (and/or the fact whether the visitor search bot)?
    I think the switch should be automatic
    Yes, it will be automatic. Crawlers and other javascript-less machines won't even know that the site can act in AJAX mode. And as for browsers, AJAX mode will be enabled only if available.
    May the Source be with you!
    Orkan
    #5 2008-10-23 19:11
    Trustmaster:
    And as for browsers, AJAX mode will be enabled only if available.
    This is rather easy to implement by constructing links as follows:

    <a href="forums.php?m=topics" onclick="$.get('forums.php?m=topics&ax=1', ...); return false">Topics</a>

    Also note, we need a way to update the address bar so each ajax call can be bookmarked :)
    Perl - the only language that looks the same before and after RSA encryption.
    This post was edited by Orkan (2008-10-23 19:18, 15 years ago)
    Trustmaster
    #6 2008-10-23 23:46
    As far as I know, you can't update the address bar without reloading the page.
    May the Source be with you!
    medar
    #7 2008-10-24 00:26
    I think no need ajaxing all links on site.
    Ajax must be used only for interactive response, for changing elements of page but not for reload entire page.

    API for AJAX features (using jQuery) - enough.
    rangjungyeshe.ru
    oc
    #8 2008-10-24 01:16
    I agree with medar.

    We need to use AJAX only needed, like, maybe, post editing/login process vs.vs.

    And, AJAX will be outdated too, so we should not build this cms on AJAX.
    Trustmaster
    #9 2008-10-24 03:12
    You guys have skipped something. Nobody says switching Seditio to AJAX. We talk of special response mode for AJAX and optional features for those who want to make sites partially or entirely with AJAX.
    May the Source be with you!
    Orkan
    #10 2008-10-24 21:49
    # Trustmaster : As far as I know, you can't update the address bar without reloading the page.

    You can modify location.hash without reloading the whole page, eg: http://lvlworld.com/
    Perl - the only language that looks the same before and after RSA encryption.
    Trustmaster
    #11 2008-10-25 03:30
    Well, I'm quite skeptic about this idea, because it means that there will be at least 2 kinds of links to the same page: traditional and hash-based. It makes things easy to be messed for both devs and users.
    May the Source be with you!
    medar
    #12 2008-10-28 22:39
    May be now integrate phpQuery to core Seditio-N ? (http://code.google.com/p/phpquery)
    Easy jQuery manipulation and Ajax interface..
    # Adding the appropriate logical switches and layout control, depending on presence of AJAX flag in script parameters, in the core PHP scripts.
    It is too big task, we will write it very long.
    rangjungyeshe.ru
    Trustmaster
    #13 2008-10-29 01:50
    I wonder how phpQuery helps, because we don't actually need CSS3 selectors for XTemplate files :D

    As for AJAX mode, I it's much easier than you may think and I'm sure some of us have already done it before ;)
    May the Source be with you!
    Orkan
    #14 2009-06-15 05:18
    # Trustmaster : Well, I'm quite skeptic about this idea, because it means that there will be at least 2 kinds of links to the same page: traditional and hash-based. It makes things easy to be messed for both devs and users.

    no, the "hash" part will only define the "page state". For example, if you have an ajax driven gallery, the hash part will define which photo you are currently viewing, so you can use this link later and share with others.
    This is nothing new. I will implement this on my Star Rating widget Demos tab soon, where I have two nested ajax tabs. There is a jQuery plugin to handle this easily: jQuery Address

    # medar :
    # Adding the appropriate logical switches and layout control, depending on presence of AJAX flag in script parameters, in the core PHP scripts.

    It is too big task, we will write it very long.

    there is a spacial Header sent with all ajax calls, which can be used as a "logical switch",
    eg. to exclude header.php from parsing in ajax call:

    if(empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
     require_once $cfg['system_dir'] . '/header.php';
    }

    plugins can use the same technique to modiffy the output as required

    Most, well designed PHP frameworks, utilizes "heplers" to package and abstract JavaScript behaviors into small PHP functions. To use it you dont even need to know JavaScript.
    echo javascript_tag(
      remote_function(array(
        'update'  => 'myDivId',
        'url'     => sed_url('users', 'm=edit&id='.$urr['user_id']),
      ))
    );

    The helpers deal with browser consistency, complex limit cases, extensibility, and so on, so the amount of JavaScript code they contain can be quite impressive. They also create an abstraction layer over a JavaScript library you are currently using. So it's possible to switch to YUI instead of jQuery without modiffing a single line in your plugin.
    Perl - the only language that looks the same before and after RSA encryption.
    This post was edited by Orkan (2009-06-15 08:02, 14 years ago)