Posted by loze on November 25, 2009 at 4:18pm
1 follower
| Project: | Simple CDN |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
First of all, this is a great module. Very simple to implement in a custom mod. Thanks!
I think a nice feature would be the ability to define multiple mirrors per module.
for example:
I have a custom module that outputs urls for several seperate function calls.
I would like to be able to assign a different mirror (or turn off cdn completely) in the admin, for these individual elements.
if you were able to define these elements by returning an array of arrays in hook_simplecdnapi()
Something like:
<?php
/**
* Implementation of hook_simplecdnapi().
*/
function mymodule_simplecdnapi($op) {
switch ($op) {
case 'load':
$data[] = array(
'eid' => 'mymodule_some_element',
'name' => 'My Module: Element 1',
);
$data[] = array(
'eid' => 'mymodule_some_other_element',
'name' => 'My Module: Element 2',
);
return $data;
break;
}
}
?>and then invoke it with:
<?php
if (module_exists('simplecdn')) {
$url = simplecdn_rewrite_url($url, 'mymodule_some_element');
}
?><?php
if (module_exists('simplecdn')) {
$url = simplecdn_rewrite_url($url, 'mymodule_some_other_element');
}
?>from within the same module wherever appropriate.
I guess i could make a separate plugin module for each case, but that seems excessive, no?
thoughts?
thanks again!
Comments
#1
The attach patch has worked well for me and does exactly what you have described. The
simplecdn_invoke_simplecdnapiwill handle returns from modules implementingsimplecdnapias follows:<?phparray(
'eid' => 'some_element',
'name' => 'some element name',
)
?>
<?phparray(
array(
'eid' => 'some_element_1',
'name' => 'Some element 1 name',
),
array(
'eid' => 'some_element_2',
'name' => 'Some element 2 name',
),
)
?>
The 2nd option above allows you to put all of your elements in one module which enables reuse of hooks for preprocessing, etc.