avanzu / AdminThemeBundle

Admin Theme based on the AdminLTE Template for easy integration into symfony
MIT License
281 stars 149 forks source link

Unable to use layout :( #237

Open craph opened 6 years ago

craph commented 6 years ago

@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 lts 2/ cd 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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

{% block avanzu_logo_path %}/{% endblock %}
craph commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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.