I use keystone.js together with handlebars as template engine. Until now I had one .hbs-file for each page. However, HTML-Code is growing over time and I would like to split the HTML into several files. Does keystone.js offer a simple way to render multiple template files?
I'd prefer not to use technologies like webpack just for that "simple" task.
You can use partials to break up your templates, so you can include one .hbs file in another file.
Add a new file in the templates/views/partials directory, for example myPartial.hbs, and then you can include it in another file like so:
{{> myPartial }}
KeystoneJS will handle registration of .hbs files in the templates/views/partials directory.
You can read more here:
http://handlebarsjs.com/partials.html
If you use the KeystoneJS generator to set up your project, you can see this in action where pagination.hbs is included in blog.hbs.
Related
I'll change the template of the invoice pdf template in shopware 6.
The template self seems to be stored in the database in the table "document".
The pdf is generated by php.
Anyone knows, how to get a complete own customized template ?
The configuration in the backend is not enough.
Thank you.
I wrote an example Theme some time ago, that is extending the basic template: https://github.com/mnaczenski/SwagDocumentTemplate
The core template is located here:https://github.com/shopware/platform/blob/trunk/src/Core/Framework/Resources/views/documents/base.html.twig
So you can overwrite the file in your own theme like described in the documentation by extending the twig file and placing it in the right folder: https://developer.shopware.com/docs/guides/plugins/themes/theme-base-guide
Extend in Twig: {% sw_extends '#Framework/documents/base.html.twig' %}
Folder structure: /src/Resources/views/documents/base.html.twig
Generated PDFs are stored in the database due to German law, they can't be changed after generation. But new generated PDFs are based on the template.
The easiest way to customize your invoice templates is to use the WYSIWYG Document Editor. You can either customize an existing document or create a completely new document. Using one of the predefined document templates provides a good starting point for you to apply your customizations. But you can also start with a blank page.
With the visual editor, you can easily add new elements and variables and see your changes in the live preview. This will save you a lot of time in comparison to going back and forth hundreds of times between making adjustments in your Twig Files and generating new PDFs for testing.
Here is a YouTube Video, which shows you how easy and fast you can edit all your documents: https://youtu.be/fGBMDmVMPvA
I am the developer, which created the WYSIWYG Document Editor Shopware 6 App. Feel free to ask me any questions about the App. I am happy to help you.
I want to group components folder. But I can't group it because it looks for the folder name I named just below the components folder. I want to group like in the photos below:
#await Component.InvokeAsync("odemeSecenekleri")
but it is looking for "odemeSecenekleri" folder under components folder. I want " components > footer > odemeSecenekleri ". components > odemeSecenekleri not. I want to group components according to their pages.
I want to make a folders like in the photo above. Please help me.
It is really the .cshtml files which you have to be concerned about. Asp.Net Core does not care where you put the rest of the ViewComponent files.
To modify how your project searches for Views, you need to create a custom class which the implements IViewLocationExpander interface and configure it in Startup.cs
This link should help: https://stackoverflow.com/a/65983829/13550447
From what it appears you are trying to do, you may also want to consider creating Feature folders.
There are many examples if you search for Feature Folders in Asp.Net Core.
Here is one example: https://scottsauber.com/2016/04/25/feature-folder-structure-in-asp-net-core/
I'm using Pingendo V4 (not-beta).
I assume templates are partly completed pages that I can start with and modify, and that Themes are only selections of shapes, colors that I can use on my own pages. Is that correct?
Can I download a (I assume Bootstrap) theme or template, use it locally and then transfer the files to my web site? How is the download done and them integrated with Pingendo?
Thx.
Templates are completed pages that you can edit and customize to your liking. Themes are sets of customizations. Sometimes themes and templates are made for particular business types, for example pingendo has a app, resteraunt, and fasion templates complete with there coresponding themes. With Pingendo you can download your theme by doing the following: Go to the HTML tab, which gives you the HTML view of your page. Copy and paste that into your own index.html page. Secondly go to the sass view in Pingendo and copy and past it into a custom.sass file that you create. Keep in mind you will want to convert that sass to css, there are free tools that do this online. Depending on your webhost the method of putting them online will be different. Most of the time you will need to FTP your files on to the server, put your html into the main folder may be names something like public_html. Put your css into a folder in the main folder called css, make sure your link to the css in your index.html reflects the file path. Once you have it downloaded there is no need to reintegrate it into Pingendo, the only time you will need to go back there is if you need to make changes. Of course you could always hand code the changes as well.
In my MVC project I use both Web Optimizer and Cassette. The main reason I choose Cassette is because it has the ability to "inject" javascript and css to the html header/bottom body section from partial view or child action (or from anywhere). The reason I still use Web Optimizer is because it can have different bundles for files in the same directory (in comparison that Cassette default one bundle per folder, which does not work sometimes, for example, many different themes are in just one folder because they share files).
In my project I used a lot of third party jQuery plugins in different places. I bundled them together, and then in different pages I use the Bundles.Reference() to add to a page when it is needed. For example, in one page, I could use 5 plug-ins, and another page could use 6 plug-ins.
Bundles.Reference("content/plugins/plug1.js", "body");
Bundles.Reference("content/plugins/plug2.js", "body");
Bundles.Reference("content/plugins/plug3.js", "body");
When the page is rendered, Cassette would generate a tag for each of the references.
The main reason we use bundle is to try to reduce the requests to server whenever it is possible. But in this situation, the Cassette does not reduce the requests for javascript. It just like the same thing that I add the tag for each plugin (but I cannot inject to header/body bottom from partial view/child action).
So my question comes: is it possible that Cassette can "bundle" the different References that I use in different pages into just one single tag?
Many thanks in advance!
I want to create several javascript function that will be needed on different pages. Most will be relevant only to one page, but some to several. I know if I add general conversion functions, it would be a good idea to just create a new javascript file and put all these generic functions into that one file. Bringing me to my first question:
Where would you store the generic javascript file? In "protected"? Which subfolder?
Then, I need to address the placement of other javascript code.
If I have javascript that will only be used on one page, should I use this technique or should I stick to a similar approach as above?
The emphasis is on doing it correctly. I want to fall exactly in line with the yii framework.
store your generic javascript file in your_app/js folder
i.e js folder is at same level to protected.
if js is only used on one page than it will be better not to use generic file.
The best way to have you generic js code into /js/ or similar named folder under root of your app code. Personally I would separate my custom code files into one other subdirectory /js/custom/ and /js/vendors/ where in this vendor folder you can put ready js code such as jquery plugins etc.
Also don't forget to set this path to config file like this:
'components'=>array(
'clientScript' => array(
'coreScriptUrl' => 'path/to/js/lib/dir',
'enableJavaScript' => true,
),
),
where path/to/js/lib/dir is your final js folder name path