How can I create a reusable panel based on http://getbootstrap.com/components/#panels-heading in Symfony 2 and Twig? I mean how to create resusable control that I can embed in my twig page and provide to it header text and body, which will contain html and some other twig components (e.g. form controls).
This control should contain all the HTML that come from bootstrap panel example and I will only provide header text and body ... and control put this in appropriate place.
http://twig.sensiolabs.org/doc/tags/extends.html
Are you talking about extending templates? That way you can reuse all the HTML that came from bootstrap and just overwrite the sections you need.
In Symfony2 the extends syntax is something like:
somefile.twig.html
{% extends 'AcmeSomeBundle:Default:bootstrap.template.html.twig' %}
Look at the documentation link above for more details.
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'm trying to override the FOSUserBundle Templates as show here:
https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_templates.md
I used the second method, I created my own bundle and put the templates in
myBundle/Resources/Views/Security/login.html.twig
and
myBundle/Resources/Views/Registration/register.html.twig.
both templates start with:
{% extends "::nologbase.html.twig" %}
where nologbase.html.twig is defined in app/Resourcer/views.
well, the first one (login) is correctly displayed but the second one (register) shows row html with no css.
I cleared the cache and I also tried to display only the extended template and compared the source code. it is exactly the same!
any idea?
thanks
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.
I'm trying to customize the framework.css for how high or low the sidebar appears on specific pages. Would it be possible to do this using a custom page template and a specific div class declaration? Such as creating a custom template and within that template creating a class to "override" the default css sidebar element settings for those pages? How would I go about doing this?
One option is to make sure the theme is using the function body_class() inside the <body> tag.
When I select the page template Sidebar Template (wp-content/themes/twenty-eleven/sidebar-page.php), the class page-template-sidebar-page-php shows up in the body tag:
According to brasofilo's answer, every page has its own class, in case of brasofilo's code, it is the page-id-674. It's generated by wordpress in general.
If you want to do styling on specific pages, you may use something like this:
body.page-id-674 div.specific-div-class {
/*code*/
}
Hope that helps!
I need to alter the output of a view that displays in a in a block in order to apply it to some format of a Jquery UI script so I need the following format for a grouped taxonomy query that I'va configured for some node type..
<div id="tab">
<ul>
<li>Tab1Title</li>
<li>Tab2Title</li>
<li>Tab3Title</li>
</ul>
</div>
<div id="tabs-1">Content2</div>
<div id="tabs-2">Content2</div>
<div id="tabs-3">Content3</div>
You need to create a Style Plugin, and expose it to views 2 API.
A complete style plugin is made up of these components:
An implementation of hook_views_api so Views will load your include
files;
An implementation of hook_views_plugins to declare your style
plugin;
An implementation of the views_plugin_style class;
A theme preprocess function for your style theme;
A theme .tpl.php page.
Here is good reference about extending views 2 with custom modules (from which I taken this component list):
http://groups.drupal.org/node/10129
You need to create your own views style-plugin. Look at views_plugin_style_default.inc in your views module folder.
Then go to Style plugins and find out more about how to implement a style plugin from your own module.
You basically implement the hook_views_style_plugins() and then create your own class that extends views_plugin_style.
Best of luck!