Skip to content
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

Add breadcrumb in template #16

Closed
Mondane opened this issue May 26, 2014 · 6 comments
Closed

Add breadcrumb in template #16

Mondane opened this issue May 26, 2014 · 6 comments

Comments

@Mondane
Copy link
Contributor

Mondane commented May 26, 2014

I'm customizing the error template and want to add display a breadcrumb. Let's say for the 404-page, it should be:

Home > 404 page.

Is it possible to call your bundle in a template to add objects to the trail, if so, could you give an example?

@Abhoryo
Copy link
Member

Abhoryo commented May 26, 2014

You can try with the globals variables of twig:

#app/config/config.yml
twig:
    globals:
        breadcrumb_trail: "@apy_breadcrumb_trail"

After that you can call the service inside twig template.

{% app.breadcrumb_trail.add('404 page') %} 

@Mondane
Copy link
Contributor Author

Mondane commented May 26, 2014

Doing so ends up with this message:

Whoops, looks like something went wrong.

1/1HttpException:
in /home/woodworker/dweh/site/vendor/webfactory/exceptions-bundle/Webfactory/Bundle/ExceptionsBundle/Controller/TestController.php line 36
at TestController->testErrorPageAction('500')
at call_user_func_array(array(object(TestController), 'testErrorPageAction'), array('500')) in /home/woodworker/dweh/site/app/bootstrap.php.cache line 2951
at HttpKernel->handleRaw(object(Request), '1') in /home/woodworker/dweh/site/app/bootstrap.php.cache line 2923
at HttpKernel->handle(object(Request), '1', true) in /home/woodworker/dweh/site/app/bootstrap.php.cache line 3062
at ContainerAwareHttpKernel->handle(object(Request), '1', true) in /home/woodworker/dweh/site/app/bootstrap.php.cache line 2305
at Kernel->handle(object(Request)) in /home/woodworker/dweh/site/web/app_dev.php line 34

Is the naming incorrect?

@Abhoryo
Copy link
Member

Abhoryo commented May 26, 2014

Do you have more informations about the error because what you show me isn't very useful.
I'll try tonight and if this dosen't work, i'll create a new twig function to do so.

@Abhoryo
Copy link
Member

Abhoryo commented May 26, 2014

Ok the following code works for me:

{% do breadcrumb_trail.add('404') %}

@Mondane
Copy link
Contributor Author

Mondane commented May 26, 2014

Thanks, that works great!

@Mondane Mondane closed this as completed May 26, 2014
@Abhoryo
Copy link
Member

Abhoryo commented May 26, 2014

I've add some doc about this. Thanks for the idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants