GetSimple Support Forum
AJAX Dataload API - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Developer Discussions (http://get-simple.info/forums/forumdisplay.php?fid=8)
+--- Thread: AJAX Dataload API (/showthread.php?tid=2553)



AJAX Dataload API - SiL3NC3 - 2011-12-30

Hi All,

I plan to use GetSimple with a js project which should load the contents without page reloads. In that case it would be important to load the content data without the layout.

Is there any AJAX solution planned. Havent got any search results for searching the forum for AJAX.
This would be a big improvement to designers!

I'm able to code some lines by myself, and I think this would not be to hard. But with some dev hints it would be a small job to get this done.

Got any tips for me?

Here a jquery example how this will be done:

Code:
$('.link').click(function() {
        var link_href = $(this).attr('href');
        var link = link_href.replace(/#/g, '');
        $.get('dataload/content/'+link, function(data) {
            $('.result').html(data);
            $('#content_block').html(data);
        });
    });

Sidebars could also be loaded totally free with jquery in background.
//SiL


AJAX Dataload API - mvlcek - 2011-12-30

SiL3NC3 Wrote:Hi All,

I plan to use GetSimple with a js project which should load the contents without page reloads. In that case it would be important to load the content data without the layout.

Is there any AJAX solution planned. Havent got any search results for searching the forum for AJAX.
This would be a big improvement to designers!

I'm able to code some lines by myself, and I think this would not be to hard. But with some dev hints it would be a small job to get this done.

Got any tips for me?

Here a jquery example how this will be done:

Code:
$('.link').click(function() {
        var link = $(this).attr('href');
        $.get('dataload/content/'+link, function(data) {
            $('.result').html(data);
            $('#content_block').html(data);
        });
    });

Sidebars could also be loaded totally free with jquery in background.
//SiL

Assuming that your template(s) wraps the content in a <div id="content">...</div>, you can simplify your code to
Code:
$('.link').click(function() {
  var link = $(this).attr('href');
  $('#content').load(link + ' #content');
});

If all pages but the index page are loaded with Javascript, you should give all pages but index a simple template.
You might also need to adjust the currently highlighted menu item.

But overall, I don't see any reason for avoiding page loads.


AJAX Dataload API - m1k3y - 2011-12-30

why dont you use the plugin simple page content... it only returns the content of a page with a specific slug


AJAX Dataload API - SiL3NC3 - 2011-12-30

to keep the html code slim Wink

i think a plugin could do the job. will have a look at it and spread the details when there any ... Smile


... on the other hand: loading data in background is more important when using modal forms processing data, imho.


AJAX Dataload API - SiL3NC3 - 2011-12-30

m1k3y Wrote:why dont you use the plugin simple page content... it only returns the content of a page with a specific slug

thx dude. will have a look at it. maybe it could help this out. Wink
(right now, i'm not too familiar with all plugins)



COMMENTS:
tried it out, but havent got it to work (no clear output)
maybe, i've done something wrong ... Sad
>>>> see my solution WORKAROUND below ...


AJAX Dataload API - SiL3NC3 - 2011-12-31

... figured out a WORKAROUND:

i placed a file "dataload.php" within the templates folder, with the following code:

Code:
<?php
if (!defined('IN_GS')) {die('you cannot load this page directly.');}
get_page_content();
?>

... so only the page content will be shown up.
Now set the page settings default template to this file (dropdown menu - choose dataload.php).

So I can load different block (pages) dynamically to the content div.

Okay, the content pages have to be set up twice. First for the default loading via url and second for dynamic loading.

Example pages:
- dynamic-instructions (page option: default template - dataload.php)
- dynamic-samples (page option: default template - dataload.php)
- instructions
- samples


The use of an identical prefix like "dynamic" (or anything else) will keep the clear content off the browsing users, and on the other hand will be automatically sorted within the pages admin section, for easy viewing and locating handling.

This will do the job ... the quickest and slickest way, imho Wink

(If somebody is interested in)

PS: Extended menu editing options would be helpful, also like using external links.
(will use a static navigation to solve that by now)


AJAX Dataload API - 5wooley4 - 2012-03-30

SiL3NC3 Wrote:to keep the html code slim Wink

i think a plugin could do the job. will have a look at it and spread the details when there any ... Smile


... on the other hand: loading data in background is more important when using modal forms processing data, imho.

I just wrote a plugin to do exactly this. http://get-simple.info/extend/plugin/pajax/412/