I’m sure this question does not deserve it’s own topic but I’ve failed to find a satisfying answer on the forums and Stack Overflow.
I have three templates. I’ll try to be clear and simple about what I’m trying to do.
Page
{exp:channel:entries channel="page" dynamic="yes"}
{!-- 'pages_module' is a matrix field --}
{page_modules}
{!-- The field 'module' is returning the entry_id from SP Table Select --}
{embed="module/index" id="{module:value}"}
{/page_modules}
{/exp:channel:entries}
Module - Index
{exp:channel:entries channel="module" dynamic="no" entry_id="{embed:id}" site="main_site"}
{if module_type == "building"}
{embed="module/building" id="{building_id}"}
{/if}
{!-- Other module type checking here... --}
{!-- Note this following line --}
{entry_id} - {embed:id}
{/exp:channel:entries}
Module - Building
{exp:channel:entries channel="building" dynamic="no" entry_id="{embed:id}" site="main_site"}
<h1>{title}</h1>
<p>{building_description}</p>
{/exp:channel:entries}
So basically, in this setup you can attach “modules” to pages entries. In this particular case, I’m trying to look if any {module_id} was set on the page. If so, pass {module_id} to the main module template, which will get the module entry, compare the {module_type} and send {building_id} to a third template. Then the building information is fetched and displayed.
In the module template, where I wrote a note, {entry_id} and {embed:id} does not match. {entry_id} equals the ID of the first page entry that was fetched dynamically. I assume this is happening because since it’s embedded templates and not snippets, it results in three nested {exp:channel:entries} tags. But then again, I can’t pass IDs to a snippet, can I?
Also worth noting that I’m using MSM, and since I have 8 sites running on it, I wanted “modules” to be, well, modular and all reside under the “main site” for convenient maintenance.
I hope someone can clarify this and/or correct me if I’m wrong.
As cited in the documentation:
Embedding Templates from Another Site
To embed a template from another Site, simply prefix the template group and template specified with the short name of the site you wish to pull the template from as follows:
{embed="site_short_name:template_group/template"}
But!
Specifying Multiple Sites (prepare for a head trip)
Note: Specifying multiple Sites does not work with the
{embed=”“}
tag.
Then I thought I could play around this limitation with PHP but it seems even the basic...
$output = $this->EE->TMPL->parse_variables('{exp:channel:entries channel="module" dynamic="no" site="main_site"}{entry_id}{/exp:channel:entries}', array());
...wouldn't return the expected values. It seems there is no way to embed a template that itself fetches data from a different site. This is disappointing since getting data from other since while not repeating channels/templates is, to me, the exact reason why you want to use the multi-site manager...