daspete / patternlab-twig-laravel

ServiceProvider for using patternlab in laravel with the twig engine
0 stars 1 forks source link

Example how to use from new laravel installation #2

Open edibez opened 8 years ago

edibez commented 8 years ago

Hi Thank you for the library. I am new to patternlab and I am trying to make patternlab work with laravel 5. I try your library but has no success so far making patternlab run with the laravel. Aside from the steps you describe in Readme.md , is there any previous step / extra step I need to do to make fresh laravel install work with your library ? (e.g. install patternengine ? install patternlab php twig ? ) . Much appreciated.

daspete commented 8 years ago

Hi there, thx for your feedback.

There should not be any extra step, to get this running. Do you get any errors?

Have you also copied the resources files into the resources folder?

edibez commented 8 years ago

Hi

Thank you for the reply, yes i have extracted and copied the resource files from your resource pack to the resources folder. Here is my laravel resources folder

screen shot 2016-11-20 at 11 51 38 pm

I have not done anything with those folder upon extracting except adding a file called 01-home.twig into the 04-pages folder. The content of that file is only one line of html code helllooo

In my controller here is my code

screen shot 2016-11-21 at 12 00 59 am

And I do get error like below

screen shot 2016-11-20 at 11 54 49 pm

I then i tried to add a file called 01-home.twig in resources/views folder , and i got this

screen shot 2016-11-21 at 12 04 43 am

Any suggestion what step am I missing here ?

daspete commented 8 years ago

Oh, right... thats a little bug, produced by a .gitkeep file...

Just delete the file /resources/styleguide/data/.gitkeep

I will update that package soon. It's been a while now :)

To get a pattern loaded in a view, you need to create a new twig file in the /resources/views/ folder.

For example:

create a home.twig file in the views folder, and in there, you can include a pattern, in your case: {% include "pages-home" %}

Now, in your controller, you can just call the view:

return view('home');

edibez commented 8 years ago

Thank you so much for the extra information . Now i manage to get the example page working ! The last part of the puzzle for me would be figuring out where do i put custom css ( i plan to use bootstrap) and include it in the pages and how to set my header and footer section of the pages.

daspete commented 8 years ago

Nice :)

Hmm... as far i understood patternlab, it is just for the html content, so you have to manage the CSS for yourself. If you use the sass branch from bootstrap you can just copy the pattern-structure and include all the css patterns in your main.scss file or something like that, maybe there is already a structure like that available in the net.

To have a footer and header on every page, you can create an organism pattern for the header and the footer. There is also a base.twig file in the resources folder. In there, you could include the header and footer pattern. And in the page pattern (in your case the home.twig) you could extend from the base.twig file (you can google: twig extend template or so) so, you will have a header and a footer on all pages, which extend the base.twig.

edibez commented 8 years ago

Thank you for all the suggestion and insight , really appreciated. I`ll be in touch if I found another bug or have a suggestion to improve your library. Have a good day !