-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Context missing from dynamicInclude
in multisite
#60
Comments
@mattgrayisok this issue is still happening, but one update is that this seems to only be a problem in local development. The dynamically included template loads just fine on staging and production. Also, I have other dynamically included bits of UI that work just fine locally in this second site, but these are elements that do not have a For reference, I'm doing something like:
Take an example block type of
The dynamic file looks like:
To test that it's not just an issue with this one particular block, I created dynamic versions of a handful of different blocks, and all of them fail the same way: The And again, this is only happening in this second site. Everything (even the above tests I tried) works as expected in the default site. Let me know if there is any other detail I can track down to help here. |
Hi @chrismlusk I've just been trying to recreate this but haven't had any luck yet. It's odd that it isn't working in local dev but is working in staging/prod - I'd imagine the code running in both should be the same. Could you try running in local with Dev Mode disabled as that's the only thing I can think of that might change behavior between the two? I have one other potential theory but debugging will involve editing some files in |
So, with Dev Mode disabled locally it sort of works. The My template: <h2>{{ block.headline }}</h2> The output with Dev Mode disabled: <h2></h2> |
Let's edit some vendor files then! You should have a file at For reference, the file in this repo is: https://github.com/servdhost/craft-asset-storage/blob/craft-4/src/StaticCache/Twig/IncludeNode.php We're interested in the final function We can test that by adding a few LOC at the very bottom of the
That should cause the |
@mattgrayisok, OK I tried that and ... nothing happened. So, I started moving that debug conditional around, and when I place it within the
|
I kept poking around in the vendor files while following the stack trace I'm seeing, and I found myself in In the So, I double checked the settings for that Neo field. The propagation method is set to |
Thanks for that. We're definitely getting closer. The Since Elements have a unique ID, I had assumed that you could just pull them by ID, regardless of which site they belonged to, but perhaps the unique key for elements is actually ID + SiteId, in which case we need to account for that. I'll get a test set up to recreate and then do... something... to sort that out! |
I've just been trying to recreate with a setup that's pretty much identical to your own and still having no luck. I also had a look over the Craft source to see if that siteId is required and it doesn't seem to be - it just acts as an optional filter. Can you confirm whether you're still only seeing the problem in local and staging/production are ok? If so I'm inclined to think that it might be some data corruption in the local database around the neo blocks. We should be able to test that by downloading a database dump from a working staging/production env and importing into local and seeing if the problem persists. |
Ah, I might have spoke too soon earlier when I said it was working in production/staging. Like I said in a previous comment, it only sort of works. For reference, this block renders a template that includes an element query. In the CMS, editors can configure filters that are passed into the query, but the null coalescing operator sets a default so the block can still render with results.
Turns out, the block in question had no filters applied, so everything seemed as if it was working, but when I set filters, the output is an unfiltered list of results — so I assume However, I'm getting different results in production and staging 😬 Here's what I'm seeing in the secondary site for each environment: Production
The dynamic include renders the block markup, but the Staging
Everything works as expected for both sites. Local
Nothing renders from the dynamic include (the placeholder is still there). |
I've replaced my local DB with one from production and staging, but the problem persists. |
I thought of another difference between production and staging. Not sure if it's meaningful, but... On production there is only one dynamic include on the page (this problem block). On staging there are two. This block, and a debug utility we have to test geolocation features in staging. |
I'm having issues with dynamically including a template in a multisite setup.
Take the following example, which is being used in a
for block in blocks
loop:In the primary site, everything works great. In my second site, however, my
block
variable is missing from the context. The?p=actions/servd-asset-storage/dynamic-content/get-content
request comes back with the following Twig runtime error:And that's because within my
productList.twig
template, I'm callingblock.headline
.While investigating the issue, I tried replacing the dynamic include with a default include, and everything worked fine on my second site.
Versions
The text was updated successfully, but these errors were encountered: