The @images bit is actually a shorthand for a custom twig namespace that is defined in the quark.php file:
// Add images to twig template paths to allow inclusion of SVG files
public function onTwigLoader()
{
$this->grav['twig']->addPath(__DIR__ . '/images', 'images');
}
I think perhaps I need to redefine this function to find a better way to get the current theme path.
Try replacing the quark.php function with this:
I think this:
// Add images to twig template paths to allow inclusion of SVG files
public function onTwigLoader()
{
$theme_path = Grav::instance()['locator']->findResource('theme://');
$this->grav['twig']->addPath($theme_path . '/images', 'images');
}
Should do the trick. (btw, you will probably also need to add use Grav\Common\Theme at the top too.
I changed the function in the origin quark.php and added the include instruction in the child’s theme base.html.twig again.
The error ist still the same.
the child’s php is still very slim and just looks like this:
<?php
namespace Grav\Theme;
use Grav\Common\Theme;
class Mytheme extends Quark
{
// Add images to twig template paths to allow inclusion of SVG files
}
?>
it doesn’t matter if the your provided function ist inserted here - and for my understanding it should be inherited from the parent theme anyway. … or am I wrong?
However - it is in fact more important to me to understand, what the problem ist, than to include the inherited logo.
Perhaps you could provide a link where i can find a more detailed description to this than i found on https://learn.getgrav.org/themes/ ?
Ok, I hadn’t tested it, and I was on the right track, but needed a smidge more logic:
// Add images to twig template paths to allow inclusion of SVG files
public function onTwigLoader()
{
$theme_paths = Grav::instance()['locator']->findResources('theme://images');
foreach(array_reverse($theme_paths) as $images_path) {
$this->grav['twig']->addPath($images_path, 'images');
}
}
is the final method that gets all the theme paths (including inherited ones) and only includes paths that exist. However, for this to work in your inherited theme, you must extend the base theme:
<?php
namespace Grav\Theme;
use Grav\Common\Grav;
use Grav\Common\Theme;
class QuarkChild extends Quark
{
}
If you simply extend the Theme class, you would need to copy over the contents of the quark.php class to this one.
oops - as i mentioned before, i am really a newbie on this.
first of all, thank you for your patience!
I am afraid, my mistakes startet even earlier.
In fact when i set up the child theme i did not name it in the childTheme.php - instead i litterally used the mytheme as name.
however, if i insert the name of the child in the php file, the site does not show anything but errors.
I thought, it worked with just this setup:
after disabling the grav-logo.png import anything behaved, as i expected and I was able to use any template or partial - if a *.html.twig was available in any of the template folders.
with the suggested changes built in , the site does not work at all - so i am afraid, i got most of the explanation on expanding themes wrong. Last not least when i did not gave the right theme name, the jschell.php did nothing at all - and i now wonder why and how this worked … but i will find out ^^
so i will first read the docu yet another time before wasting more of your time.
nevertheless - thank you once again for your time
… i am afraid i will be back very soon for further questions
in any case - with or without the two use Grav\Common\Grav|Theme lines i get an error saying:
Whoops \ Exception \ ErrorException (E_ERROR)
Class 'Grav\Theme\Grav' not found
might there be anything else relevant that changed in the beta version not mentioned in the documentation ( for obvious reasons the doc is partially still on v0.9x)
for now i stick with this state i have, as it still does the mean parts of what i want, but it really would be nice to understand what’s going on.
using the Devtools plugin leads to the same or similar errors - it works fine with any other theme i tried - so i suspect beside all mistakes i made, there could still be an issue with the theme.
for now i will stick with another theme and come back to quark later on because i really like it as a starting theme.
I’m trying to make a child of the Quark theme but I also always run into a “RuntimeException (400) Template “@images/grav-logo.svg” is not defined”.
What I did is create a ‘myquark’ folder in ‘themes’ and /user/themes/myquark/myquark.yaml like showed in https://learn.getgrav.org/themes/customization (just with quark / myquark) and then changed user/config/system.yaml to the myquark theme.
=> Runtime Error
What did I do wrong?
Is there something special about the quark theme?
Shall I put more stuff into the myquark.yaml?