You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!! I'm currently developing a Gantry 5-based site and need to implement breadcrumb navigation into the TWIG files. To create the breadcrumbs, I'm using Yoast SEO's built-in function for this.
In order to implement this in Gantry/TWIG, I'm attempting to follow your instructions for adding functions using theme.php. Here is the code I am attempting to add:
class karma {
public function getBreadcrumb() {
if ( function_exists('yoast_breadcrumb') ) {
$breadcrumb = yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
echo $breadcrumb;
}
}
}
$gantry['karma'] = new karma();
Whenever I try to call this new object/method in my TWIG file, by adding {{ gantry.karma.getBreadcrumb() }} to the template, I get this error message:
Fatal error: Uncaught Twig_Error_Syntax: Unexpected "gantry" tag (expecting closing tag for the "block" tag defined near line 4). in /Applications/MAMP/htdocs/karmacoop/wp-content/themes/g5_hydrogen-child/custom/views/partials/content.html.twig:19 Stack trace: #0 /Applications/MAMP/htdocs/karmacoop/wp-content/plugins/gantry5/src/vendor/twig/twig/lib/Twig/TokenParser/Block.php(40): Twig_Parser->subparse(Array, true) #1 /Applications/MAMP/htdocs/karmacoop/wp-content/plugins/gantry5/src/vendor/twig/twig/lib/Twig/Parser.php(190): Twig_TokenParser_Block->parse(Object(Twig_Token)) #2 /Applications/MAMP/htdocs/karmacoop/wp-content/plugins/gantry5/src/vendor/twig/twig/lib/Twig/Parser.php(103): Twig_Parser->subparse(NULL, false) #3 /Applications/MAMP/htdocs/karmacoop/wp-content/plugins/gantry5/src/vendor/twig/twig/lib/Twig/Environment.php(692): Twig_Parser->parse(Object(Twig_TokenStream)) #4 /Applications/MAMP/htdocs/karmacoop/wp-content/plugins/gantry5/src/vendor/twig/twig/lib/Twig/Environment.php(750): Twig_Environment->parse(Ob in /Applications/MAMP/htdocs/karmacoop/wp-content/themes/g5_hydrogen-child/custom/views/partials/content.html.twig on line 19
Can you please explain what I'm doing wrong?? I could swear I'm following all of the instructions in the Gantry Docs. If I could get some guidance I would be eternally grateful!! Besides this issue, I'm really enjoying developing with Gantry! :)
The text was updated successfully, but these errors were encountered:
Hello!! I'm currently developing a Gantry 5-based site and need to implement breadcrumb navigation into the TWIG files. To create the breadcrumbs, I'm using Yoast SEO's built-in function for this.
In order to implement this in Gantry/TWIG, I'm attempting to follow your instructions for adding functions using theme.php. Here is the code I am attempting to add:
Whenever I try to call this new object/method in my TWIG file, by adding
{{ gantry.karma.getBreadcrumb() }}
to the template, I get this error message:Can you please explain what I'm doing wrong?? I could swear I'm following all of the instructions in the Gantry Docs. If I could get some guidance I would be eternally grateful!! Besides this issue, I'm really enjoying developing with Gantry! :)
The text was updated successfully, but these errors were encountered: