Is possible to push
Routing.generate()
to handlebars template ?
Related
hello I was wondering how to customize the form on symfony instead of having already a ready-made template (especially the bootstrap one).
Hello here is the solution to this problem :
To start, here is the place where you can change the theme of the forms to Symfony:
// project_name/config/packages/twig.yaml
twig :
...
form_themes: ['bootstrap_4_layout.html.twig']
if you want to see the default packages that are available you have to go to the following folder :
project_name/vendor/twig-bridge/Resources/views/Form
Now you can notice that twig file names match the style that you can add for your forms made with twig
so now if you really want to make your own style of form just create a twig file in that same folder 'project_name/vendor/twig-bridge/Resources/views/Form' and then replace that filename with 'bootstrap_4_layout.html.twig' in 'project_name/config/packages/twig.yaml'
I am new to Meteor. I have a website that I want to convert into meteor. Do I have to set up a router, and change all of the links? Or can I use the existing href links that navigate between the html pages? Will images be a problem? Will the css and javascript in each of the page headers work?
If you have Routes you should define it using the meteor package iron:router, here is common tutorial
so if you have something like myUrl/about.
you should do something in meteor like this.
Router.route('about',function(){
this.render('about') //and you should have a <template name="about></template>
})
About images, you should put images under the /public directory, check more on the official meteor docs structuringmyapp.
If you web use jquery plugins you should use a onRendered function
Template.example.rendered(function(){
//initialize jquery plugins
})
All this because like you say on the question, you have Routes, if you don't have routes.
If you want to test it on a live editor you can use Meteorpad.
I recommend you to read the discoverMeteor book or install the 2 example from meteor, also the Meteor tutorials Begginers its a good option here
Add iron:router to route your website.
// Router Example
Router.configure({
layoutTemplate: 'Layout' //Layout is a template for your website
});
Router.map(function() {
this.route('index', {path: '/'}); // Index is an another template
});
Layout template should have {{> yield}} tag
<template name="Layout">
// Include header in separate template
{{> yield}}
// Include footed in separate template
</template>
<template name="index">
<!-- Page content -->
</template>
to execute JQuery ready function by
Template.Layout.onRendered({
//JQuery content HERE
});
Hope this will enough for simple website
I'm learning symfony2 and like it very much (migrating from ZendFramework 1.x) but I'm stuck now with twig templating. Can you point me to the right direction?
My application has many customers and each has some customization (mostly templates, but also controllers, etc.).
I try to achieve this by bundle inheritance / I created ClientBundle which inherits from BaseBundle holding all basic code and templates... it works as I need for everything bud templates. When I create template in ClientBundle it overlays the template from BaseBundle and I cannot get access from the ClientBundle template to the original template from BaseBundle. I would like to extend the parent template, not overlay it... is this impossible?
Thank you!
Using the standard Symfony extends notation to reference a parent's bundle template results in fatal error. Symfony interprets your template reference to BaseBundle as ChildBundle as a result of bundle inheritance causing a function nesting level exception.
You can reference the parent's bundle template file directly using the following notation:
{% extends "#Client/Foo/bar.html.twig" %}
in replacement for:
{% extends "ClientBundle:Foo:bar.html.twig" %}
Twig's FilesystemLoader splits the reference string into namespace (Client) and path (Foo/bar.html.twig). Namespace is your bundle name without the Bundle suffix. Full path for each namespace is resolved by concatenating default <bundle_path>/Resources/views/ with supplied path.
The standard command in twig template for extention is:
{% extends 'BaseBundle::yourTemplate.html.twig' %}
You probably use the same name for template in your child bundle (you probably have a yourTemplate.html.twig in both your parent and your child bundle so the child template overrides the parent). In this case, you can rename your child template (yourTemplate2.html.twig) and then extend the child template from parent. More about bundles inheritance and twig templates extentions:
http://symfony.com/doc/current/cookbook/bundles/inheritance.html
http://symfony.com/doc/current/book/templating.html
I'm using SonataBlockBundle in my current project.
I create a SimpleBlock and render it in my twig template with something like
{{ sonata_block_render('name' : 'myBlock') }}.
But the block consists of title and body, is there a way to render title and body separately, like I can do with form fields?
Thank you in anticipation!
The best way to go there would be to create a custom BlockService (see http://sonata-project.org/bundles/block/master/doc/reference/your_first_block.html for instructions about that), with a custom twig template where you will be able to specify your title/body rendering.
For overriding Bundles template , at the first level Symfony search inside app/Resources/AcmeSampleBundle directory if it doesn't exist then it read template from src/Acme/SampleBundle.
Is there any way for customizing first level directory? for example : app/Resources/AllBundles/
You could use your custom template locator by change service 'templating.locator'. Let check how LiipThemeBundle do this.