Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AJAX Dataload API
#1
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
Reply
#2
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.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
why dont you use the plugin simple page content... it only returns the content of a page with a specific slug
Reply
#4
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.
Reply
#5
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 ...
Reply
#6
... 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)
Reply
#7
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/
www.ericwooley.com
5wooley4@gmail.com - Let me know if you need any help with any of my plugins, or just help in general. I'll always help if i can.

Beware, Im just a drunken college student. I may throw up at any time.
Reply




Users browsing this thread: 1 Guest(s)