@pamtbaau:
I copied a vanilla sidebar.html.twig to my theme
- There is no such thing as a vanilla template. No one will know what you have copied.
- Where from? Do you have a link to the file on Github?
- Does all work fine using the template?
By Vanilla - I mean the twig file that is from the repo - no changes. Here is the file.
The Quark theme works out of the box (i.e. without modification from the repo).
@pamtbaau:
Please also know that you cannot copy a template from another theme and expect it to work. Each and every theme and its templates have specific requirements and expectations about the configuration and structure of the site, folders, pages etc.
I appreciate this fact. In this case I am working with an inherited theme - inherited from Quark. I might be wrong in my thinking, but I believed that an inherited theme will use the parent theme files if there are not over-riding files in the inherited theme. Assuming that was the case I believed that just copying the source file from the parent theme to the inherited theme should not result in any change to the inherited theme. That is why I was surprised that it crashed the site.
@pamtbaau:
- What code?
- Did the error disappear after removing your own code?
- Did the unaltered sidebar.html.twig template run fine?
I knew that my own code could be responsible for the crash, but since the crash occurred in the unaltered twig file I felt that my code was a red herring in this discussion. I only mentioned it to help explain how I got to where I was.
No the error did not go away after removing my code. Although I did not actually remove my code - so to speak, but rather replaced the altered file with a fresh copy of the unaltered file. I felt that was safer.
No the unaltered sidebar.html.twig file did not work. It produced the same error.
@pamtbaau:
- Stop
- If an error occurs, do not stack more changes on top of that.
- Go back to the state where everything worked. (That’s were Git comes in very handy.)
- Make changes step-by-step until you can reproduce the error.
I was hoping to convey that this is exactly what I did. The issue really occurred with another inherited theme file that I created a week ago. I was just not sure how much I had changed and how much was original, and was unable to walk it back safely - that is why I decided to systematically build a second inherited theme - this time using the dev tools (in case the manual process I used the first time was the issue). I added small changed - tested, and them repeated until I realized the sidebar.html.twig was causing issues,
@pamtbaau:
Look at the last error in the error log. (You may first want to delete the error log and reproduce the error again to trim down the error log).
- Look at the last few steps of the trace of the error (starting with
Trace #0, then #1, #2 etc.) to see where the error originated. It usually contains a file name from your site (template or php file) and a line number.
- Share that error information.
I tried this but I have to admit that the error logs look like Greek to me. In this case the error log had 66 steps and was 60,000 characters long. I could not make heads or tails of it.
So this morning - with a fresh head I decided to dissect the twig file. I enclosed each section of code that displayed content in comments removing it from being processed. The sidebar.html.twig file had just two lines in it that were actual code:
{% set feed_url = blog.url == '/' or blog.url == base_url_relative ? (base_url_relative~'/'~blog.slug) : blog.url %}
{% set new_base_url = blog.url == '/' ? '' : blog.url %}
I then uncommented a section at a time and refreshed the page to see if the server error was reproduced. After uncommenting all the code the page was working fine.
Now I am really scratching my head. So I saved that file elsewhere (since it works) and repeated my earlier step of copying an unaltered version of sidebar.html.twig from the repo into my inherited theme partials folder. This is what I did before and it had caused a server error. This time testing the page there were no issues.
A ghost in the machine? Something is going on - but I am hard pressed to understand it.
Thanks to @pamtbaau for pointing out some things to help me and the community. I guess the problem fixed itself, but I do not know how.