Skip to content

Instantly share code, notes, and snippets.

@victorjonsson
Created February 27, 2014 08:14
Show Gist options
  • Save victorjonsson/9246285 to your computer and use it in GitHub Desktop.
Save victorjonsson/9246285 to your computer and use it in GitHub Desktop.
arlima, inline-articles
<?php
$current_renderer = false;
// Always catch which renderer that is at work
add_action('arlima_list_begin', function($renderer) use($current_renderer) {
$current_renderer = $renderer;
});
// Move "children" into "inline-children" and create their template object
add_filter('arlima_template_object', function($tmpl_data, $article, $list, $context) use($current_renderer) {
if( $context == 'creating-inline-child' )
return $tmpl_data;
if( article-template-support-inline-childs ) {
$obj_creator = $current_renderer->getTemplateObjectCreator();
if( !empty($tmpl_data['children']) ) {
$tmpl_data['inline_children'] = array();
foreach( $tmpl_data['children'] as $child ) {
$tmpl_data['inline_children'][] = $obj_creator->create($child, false, get_post($child['post']), 0, false, 'creating-inline-child');
}
unset($tmpl_data['children']);
}
}
return $tmpl_data;
}, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment