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

Unable to use layout :( #237

Open
craph opened this issue Mar 7, 2018 · 11 comments
Open

Unable to use layout :( #237

craph opened this issue Mar 7, 2018 · 11 comments

Comments

@craph
Copy link

craph commented Mar 7, 2018

@shakaran , @kevinpapst ,

I create another issue because this bundle is very hard to use and the documentation is very weird.
I follow each step of the documentation to use this Bundle based on dev-master branch and it's always wrong...

I got the following error message :
Unable to find template "AvanzuAdminThemeBundle:layout:default-layout.html.twig" (looked into: C:\wamp64\www\project\app/Resources/views, C:\wamp64\www\project\vendor\symfony\symfony\src\Symfony\Bridge\Twig/Resources/views/Form) in base.html.twig at line 1

Test case to reproduce :

1/ symfony new <project_name> lts
2/ cd <project_name>
3/ composer update
4/ composer require avanzu/admin-theme-bundle dev-master
5/ Add new Avanzu\AdminThemeBundle\AvanzuAdminThemeBundle(), to AppKernel.php
6/ php bin/console avanzu:admin:initialize
7/ php bin/console assets:install --symlink
8/ php bin/console avanzu:admin:fetch-vendor
9/ add this {% extends 'AvanzuAdminThemeBundle:layout:default-layout.html.twig' %} to my base.html.twig under app/Resources/views

What I am doing wrong ??? and it's also the same with the version 1.3.x ....

Debug info

Component Version
Symfony version 3.4
AdminThemeBundle dev-master
Operating System Windows
@kevinpapst
Copy link
Contributor

kevinpapst commented Mar 7, 2018

I don't have a SF 3.4 installation to give it a try, so please check if

{% extends '@AvanzuAdminTheme/layout/default-layout.html.twig' %}

gives you the same result

@craph
Copy link
Author

craph commented Mar 7, 2018

@kevinpapst @avanzu ,
I already tried with the correct SF 3.4 syntax :

{% extends '@AvanzuAdminTheme/layout/default-layout.html.twig' %}

And it gives to me this error :
Unable to find template "AvanzuAdminThemeBundle:Partials:_head.html.twig" (looked into: C:\wamp64\www\project\app/Resources/views, C:\wamp64\www\project\vendor\symfony\symfony\src\Symfony\Bridge\Twig/Resources/views/Form) in @AvanzuAdminTheme\layout\default-layout.html.twig at line 11

There is a big gab in the documentation because I have done all that is speficied and nothing works ... I give all the command to start a blank project...

Can you try with all the command that I give to start a blank project ? @kevinpapst

@kevinpapst
Copy link
Contributor

kevinpapst commented Mar 7, 2018

Actually I am only a user of this bundle as well. Currently the focus of this bundle seems to be towards backward compatibility, but not being compatible with the newest versions of Symfony (unfortunately).

BUT: You can see from your error message that you are one step further!
It clearly states in the error in @avanzuadmintheme\layout\default-layout.html.twig at line 11 that its now loading the theme. Hooray! ;-)

But the problem is, that this bundle uses an invalid (deprecated) syntax for loading twig templates. So you have to adapt all shipped templates in this theme.
Or you read more in my PR #216 and try to use the linked branch there. Check the other open PRs as well, if you run into further problems with 3.4 - all PRs targeted towards newer Symfony version.

@shakaran I can split my PR if you want, only addressing the wrong twig loading syntax.

@craph
Copy link
Author

craph commented Mar 7, 2018

I have done all the modification that you have made on your PR #216 for the compatibility but there is another problem about routing ...

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "" as such route does not exist.")

in vendor\avanzu\admin-theme-bundle\Resources\views\layout\default-layout.html.twig (line 42)

<a href="{% block avanzu_logo_path %}{{ path('welcome'|route_alias) }}{% endblock %}" class="logo">

@kevinpapst
Copy link
Contributor

So you have no route welcome. Then overwrite the block:

{% block avanzu_logo_path %}/{% endblock %}

@craph
Copy link
Author

craph commented Mar 7, 2018

@kevinpapst its a blank SF 3.4 project.

Is that why I have no route ? This Bundle doesn't work with no route as a "welcome" page ?

I don't understand what I have exactly to overwrite ? is it to remove the block ?

@kevinpapst
Copy link
Contributor

Just place this block in your own layout twig file.
This will overwrite the original block which tries to create a URL for the route "welcome". But I don't understand the route_alias filter properly, which is provided by this bundle ...

@craph
Copy link
Author

craph commented Mar 7, 2018

By adding this block in my twig layout it works 😄

But why it's not describe in the documentation ? The documentation is not correct ... 😢

Where have you find that ? do you have any documentation ?

@kevinpapst
Copy link
Contributor

kevinpapst commented Mar 7, 2018

Glad it works now!

Try & Error is what I normally do. Also I am using Symfony for a longer time now, so I find my way around these little bugs ;-)

And no: there is no documentation, as this bundle is AFAIK not officially compatible with 3.4 and upwards.

@craph
Copy link
Author

craph commented Mar 7, 2018

I don't understand too the variable "route_alias"

how can I deal with it ?

@kevinpapst you doesn't have the same issue in your layout ?

is there any documentation that explain how to use all the AdminLTE layout functionnality ? I don't understand the advantages of using a bundle of AdminLTE ?

what is the best improvment by using AdminLTE as Bundle ?

and what are these (they contains some php code and I don't understand why php code is needed to use AdminLTE functionnality) :
Navbar User
Navbar Tasks
Navbar Messages
Navbar Notifications
Sidebar User
Sidebar Navigation
Breadcrumb Menu
Form theme

@kevinpapst
Copy link
Contributor

I had several issues with this bundle, but thats to be expected. Its a general purpose bundle that tries to make it easy for everyone, but it can't deal with all the possible use-cases. And yes, there are some problems as well - for example the route_alias is unnecessary from my pov but I see why it was introduced. You know: thats what open source is for. Contribute if you find spots that you think should be improved!

This bundle makes it easier to include AdminLTE in your app.
The PHP functions you mentioned allow you to hook into the rendering of the template, so you don't need to write all that frontend logic yourself.
You can instead overwrite the twig templates, then you don't need e.g. the NavBar listener. But then you could also directly include the AdminLTE HTML template instead of using this bundle.

Go ahead and play with it for 1-2 days and you will quickly see how it can help you and if it fits your needs.

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