dynamic_load()
dynamic_load(string $url, array $config = array(), $pass_get = false) : integer
Dynamically execute a subrequest and insert its output in place of the
function call.
Important Note As with the Midgard Parser, dynamic_load strips a
trailing .html from the argument list before actually parsing it.
It tries to load the component referenced with the URL $url and executes
it as if it was used as primary component. Additional configuration parameters
can be appended through the parameter $config.
This is only possible if the system is in the Page-Style output phase. It
cannot be used within code-init or during the output phase of another
component.
Example code, executed on a site's homepage, it will load the news listing from
the given URL and display it using a substyle of the node style that is assigned
to the loaded one:
$blog = '/blog/latest/3/';
$substyle = 'homepage';
midcom::get()->dynamic_load("/midcom-substyle-{$substyle}/{$blog}");
Results of dynamic_loads are cached, by default with the system cache strategy
but you can specify separate cache strategy for the DL in the config array like so
midcom::get()->dynamic_load("/midcom-substyle-{$substyle}/{$newsticker}", ['cache_module_content_caching_strategy' => 'public'])
You can use only less specific strategy than the global strategy, ie basically you're limited to 'memberships' and 'public' as
values if the global strategy is 'user' and to 'public' the global strategy is 'memberships', failure to adhere to this
rule will result to weird cache behavior.
Parameters
string |
$url |
The URL, relative to the Midgard Page, that is to be requested. |
array |
$config |
A key=>value array with any configuration overrides. |
|
$pass_get |
|
Returns
integer
— The ID of the newly created context.