Closed gleerman closed 11 months ago
Okay I seem to have fixed this by changing the field type to Plain text, saving it, and then to SEO again.
Thanks for the writeup and update @gleerman. Do you think we can put this error down to something not executing properly/fully when the filed was first created, or do you feel its' something that warrants further investigation on our side?
@alexjcollins I don't know what went wrong, honestly. The setup options in the CP are limited, so I don't think I misconfigured something. Either it was indeed a bug under the hood upon the SEO field creation, or it might be something more fundamental – even in Craft CMS – geven that this $roots
object was empty and not showing any path towards my installed plugins. Glad I got it solved, and the trick to change types might be helpful to others, but the root cause of the issue remains unknown.
I've definitely had issues in the past where a custom field doesn't get created properly - I wasn't sure at the time if it was Craft or the plugin. I'll close this for now, and at least the 'fix' is here if someone has a similar issue. Thanks again.
Description
For some unexplainable reason, I am getting the Twig Template Loading Error![image](https://github.com/ethercreative/seo/assets/5098787/b43a12a9-b4a3-415f-9f33-3cf2e25a6aa0)
Unable to find the template “seo/_seo/fieldtype”.
I was able to set up the SEO plugin correctly, complete its settings via the sidebar, and create a field of type SEO and add that field to an (existing) entry type. However, when I open an entry that of that entry type (or create a new one), the error occursI have been deepdiving in the code and been tweaking some things here and there to see what is going on. The error originates from the
getInputHtml
function in SeoField.php file. Theseo/_seo/fieldtype
template cannot be rendered.What I did to see what would happen: in the
getSettingsHtml
function of the same file, I changed the template fromseo/_seo/settings
toseo/_seo/fieldtype
and then navigated to the field settings in the Craft CP. I was baffled to see that the errors there were Twig Runtime Errors (Variable "id" does not exist) which proved that the template indeed was found and merely couldn't be rendered due to wrong parameters (hence expected behaviour after this debug change).So apparently the CP can find the
seo/_seo/fieldtype
template when in a setting path, but not in an entry. To further know why, my understanding of the Craft rendering mechanism is too limited. So I am reaching out for help.After some more debugging, I found that the
$roots
object in which the template resolver is looking, is empty when the error occurs, but has values when all is going fine. These values also include the paths towards the templates of Redactor, Typed Link Fields, and other plugins.Any input is appreciated, as I am stuck to set up SEO properly on my Craft website. Thanks a lot!
Steps to reproduce
Unable to find the template “seo/_seo/fieldtype”.
Additional info