dglee87 / get-simple-cms

Automatically exported from code.google.com/p/get-simple-cms
GNU General Public License v3.0
0 stars 0 forks source link

suggestion: pretemplate hooks in admin or ajax.php that is hookable #82

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I ran into a interesting issue where I needed to populate a jquery plugin with 
json data but due to the way you can't directly call plugins and theres no hook 
in admin to inject json, it makes creating advanced plugins rather complicated.

Could we maybe get a standard ajax.php that just loads core/settings and has a 
hook for output? or even having a pretemplate hook in the load.php would be 
great.

Original issue reported on code.google.com by talkingt...@gmail.com on 1 Nov 2010 at 9:00

GoogleCodeExporter commented 9 years ago
I think a load-ajax.php would make sense so that we could maybe pass something 
like:

load-ajax.php?id={plugin}&func={plugin_function}

This way it keeps the same concept by loading a specified function from the 
loaded plugin file.

Original comment by talkingt...@gmail.com on 1 Nov 2010 at 9:07

GoogleCodeExporter commented 9 years ago
Example of what I have done to create this functionality:

load-ajax.php

<?php
/**
 * Load Plugin Function via AJAX
 *
 * Loads the plugin function pass to it
 *
 * @package GetSimple
 * @subpackage Plugins
 */

// Setup inclusions
$load['plugin'] = true;

// Include common.php
include('inc/common.php');

// Variable Settings
login_cookie_check();

// Setup this plugin
$plugin_id = $_GET['id'];
global $plugin_info;

if (function_exists($_GET['func'])) {
    call_user_func_array($_GET['func'],array());
} else {
    echo 'Invalid Function';
}
?>

Original comment by talkingt...@gmail.com on 1 Nov 2010 at 11:47

GoogleCodeExporter commented 9 years ago
this looks ok, but im having trouble seeing why this is needed. Im sure you can 
present a good case for this, but can you explain it a little more?

Original comment by ccagle8 on 7 Nov 2010 at 1:10

GoogleCodeExporter commented 9 years ago
sure.

I ran across a position where i needed to get json back for a jquery plugin I 
was using with my plugin. While I know most have made workarounds to do such 
things (working out of plugin folder directories and including files, etc..), I 
really just saw a way to keep security high while giving developers much more 
built in flexibility. in this case I simply could make a single function that 
outputted json and have native access to all the things that the plugin would 
normally have.

Basically, it picks up where load.php can't help (since it outputs template). A 
simple native way to communicate via ajax could be very helpful towards future 
development.

Original comment by talkingt...@gmail.com on 7 Nov 2010 at 9:26

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r267.

Original comment by ccagle8 on 12 Nov 2010 at 6:51