victorjonsson / Arlima

Article List Manager - Wordpress plugin suitable for online newspapers that's in need of a fully customizable front page
28 stars 16 forks source link

Using file includes as child items in lists #59

Open aaslun opened 9 years ago

aaslun commented 9 years ago

We're looking at a way to have a file include to represent one or more articles by tags, providing tag-slugs as file arguments. This could be useful at times when no regular editors are in place to update the arlima lists, such as at night time. It could provide an easy way for any author to directly publish articles into an Arlima list without any knowledge of Arlima by simply tagging the article with an agreed tag, letting the file include do the work.

file include child

This concept works for top level file includes, but as soon as you place a file include as a child of an article in the list, no arlima_file_args arguments are passed to the php-file and does not seem to execute properly. It also triggers the following warning:

PHP Warning:  array_merge(): Argument #2 is not an array in /var/www/site/public/wp-content/plugins/arlima/arlima.php on line 322

...which is in this function...

/**
 * @param array $default
 * @return array|bool
 */
function arlima_file_args($default) {
    if( Arlima_FileInclude::isCollectingArgs() ) {
        Arlima_FileInclude::setCollectedArgs($default);
        return false;
    } else {
        return array_merge($default, Arlima_FileInclude::currentFileArgs());
    }
}

Is this something that you think can be fixed by intercepting a filter or action in Arlima or should it be considered a feature request?

victorjonsson commented 9 years ago

... it's maybe even a bug. I will look into it.

victorjonsson commented 9 years ago

Okey, I think I know what could cause this. I could try to explain it in words but a picture would be better suited to display the process behind this error.... and I don't have time for that :)

I think the problem here is that the current file arguments is stored in a static variable. What puzzles me is that you say that this only happens when the file is included in a child article.... I will investigate some more...

PS. Be aware of the risk of infinite loops when you have a file include that renders another list :)