Forums / Cotonti / Support / Ajax pages, lists, etc

tensh
#1 2012-12-10 10:03

Hello;

I'm currently developing a mobile theme for Cotonti using jQuery mobile. For flawless functioning, it requires linking to pages without header and footer (content delivered by ajax).

I remember there was once a view module, did it support displaying Cotonti content like this? 

Is there a ready-to-go solution or will I have to write some kind of plugin for this?

When I'll be ready, I'll publish the theme with some plugins if there will be any needed.

Trustmaster
#2 2012-12-10 11:05

View module can only display plain output of .txt and .html files.

What you need is AJAX mode. When a page is requested via AJAX, the constant is defined:

define('COT_AJAX', true);

and header/footer are not printed.

May the Source be with you!
tensh
#3 2012-12-10 11:47

Thank you :)

Is it only for pages, or can this be set globally for any pages, plugins, modules??

Trustmaster
#4 2012-12-10 12:13

It is absolutely global.

May the Source be with you!
tensh
#5 2012-12-10 12:19

Hmm, I made a test plugin like this:

<?php

/* ====================
[BEGIN_COT_EXT]
Hooks=global
[END_COT_EXT]
==================== */

 
defined('COT_CODE') or die('Wrong URL');

define('COT_AJAX', true);

?>

... yet it still displays the header and footer everywhere. I purged the cache. What am I doing wrong? How to tell Cotonti that something is requested via ajax?

Trustmaster
#6 2012-12-10 14:29

Oh, sorry, COT_AJAX is a constant and it is always predefined in common.php line 190:

define('COT_AJAX', !empty($_SERVER['HTTP_X_REQUESTED_WITH']) || !empty($_SERVER['X-Requested-With']) || $_GET['_ajax'] == 1);

So changing it doesn't really work. Instead, you have a few options:

  • Request a page via XHR (AJAX).
  • Pass _ajax=1 in the URL.
  • Hack index.php and put $_GET['_ajax'] = 1 at the top of it.
May the Source be with you!