Integrating HerzultForumBundle in Symfony2 - php

I have installed the HerzultFourmBundle into my Symfony2 application, added the calls in the app kernel and auto load and extended the base classes. The problem i am having is i have a site layout that is applied to every page in the application and i want to render the forum within this.
I am very new to Symfony and PHP, but i have tried a few ways to get this working. I have a controller method set up that will render the forum page correctly which is set through the normal routing configuration, i can also set it up so that is routes to the index method in the Forum controller in the Herzult forum bundle. However this renders the default styles for the forum index page and is not contained by the layout i require.
Can someone provide me with an example of how to implement the forum and integrate it into a site? A simple example would point me in the right direction.

If you look at bundle's main layout file you'll notice that it extends '::base.html.twig' template:
{% extends '::base.html.twig' %}
This is an application level template located in apps/Resources/viewsbase.html.twig file.
You should be able to define your custom stuff as long as you're using this template.
This is a convention called "Three level template inheritance". Read more about it in the documentation: http://symfony.com/doc/2.0/book/templating.html#three-level-inheritance
Note that HerzultForumBundle is currently under intensive development. Some features might be missing.

Related

Symfony EasyAdminBundle custom view

I'm starting with EasyAdminBundle for Symfony.
For default usage it is perfect, but what if I wanna create custom view and use for it custom controller?
Let's say I have a task to load json file, display all his data and user then can edit data and save them.
Ok, I have my own custom controller, no big deal, data are loaded, I have custom view, data are there. I can click on link in left menu and see them. Ok. But I can't put together this view with EasyAdminBundle. To show view in a this nice theme. What I have to extend?
'#EasyAdmin/default/layout.html.twig'?
Yes, if you want to extend the default layout you can extend EasyAdminBundle's layout.html.twig like this:
{% extends '#EasyAdmin/default/layout.html.twig' %}
You can also check out the default templates e.g. for lists, but unfortunately the are a bit hard to read due to the high level of abstraction.

Symfony2 error page won't extend base.html.twig

My problem is the same as in this question but my error page won't extend base.html.twig. base.html.twig doesn't seems to be the problem. When i try to extend base layout, I get ResourceNotFoundException. In other twig layouts specific to a ceratain bundle, it works but if I try to override error template, it throws this error.
The key problem is probably the ResourceNotFoundException but i know I'm extending it the right way...
extends '::base.html.twig'
I'm not new to Symfony2 and I've used template inheritance quite alot. If i try to run the error page without extending the base layout, the error page shows. I've done all the cache clearing, I've run it in the prod environment but the page won't extend the base layout.
Anyone knows what could be the problem? Is there any other way that i could get the resource to the error template or debug to see what path is Symfony looking for when searching base.html.twig but cannot find one?

Overriding Joomla 3.0 components. Possible to override model and controller too? Not just views?

I understand the ability to overide core views in Joomla using overides, but how about the models and controllers? I would like the ability to add a field to the core user registration form, but Joomla pulls all the fields from an xml located in the models folder. I could just create a plugin, but that creates its own section, and I need it to go exclusively in the main registration form, as I am creating a tiered registration.
My question is exactly how the title implies, can you create component overrides of model and controller files in joomla, rather than just views?
Further, I know I "could", but in the event of an update I want to make sure this is an acceptable override solution - not just a hack that will be subject to be overwritten.
Thanks!!
Yes it can, i used MVC Override 1.0.11, is Joomla 3.x compatible.
in my case i used to override /models from component com_tag
structure in your template in this form:
/code/YOUR_COMPONENT/models/tag.php
above is my example
and you can do override correctly. the link is:
http://gruz.org.ua/en/extensions/joomla-mvc-override/1_0_11.html

Integrate non-admin page in sonata admin project

I need to put a non-admin page/view inside my admin project build using Sonata Admin Bundle. Is there a correct or standard way to integrate an independent page within the admin, make it accesible trough the dashboard or menu, and display it using the layout and all styles of the whole backend admin (including form styles)?
The only way I imagine how to do it is create a custom controller, an make the views use the same twig layout of the admin, but I think of it as a "brute force" way.
The way you stated seems the best one indeed. By taking a look at the dashboard page in the Admin, it is simply a controller rendering a template that extends the base_template of the sonata.admin.pool service.
You may then override the standard_layout.html.twig template to throughout the admin (don't forget to put it in the sonata_admin configuration as well) to customize the menus and add your link.

Symfony2 organize code used for ever page request

I'm programming my first site in symfony2, a site including some bundles for handling articles and static pages or contact page. I'e also created a bundle (backend only for now) for handling ads to show in the site, but this ads must to be shown in ever frontend page request, so I need to understand how to execute the necessary code to retreive the ads to show and pass this information at all the frontend controllers I have in mine bundles.
Can you help me?
Thanks in advance
Robert
Depends where do you keep your ads, but sounds like a job for service container.
Basically you need to write a service that implements method to fetch the required ads and then call that service in the controllers ($this->get('service_name'))
See Embedding controllers within a twig template.
http://symfony.com/doc/current/book/templating.html#embedding-controllers
Basically if you want to include a global widget, you'll have to add it to the parent twig template in which your controller's template inherits.

Categories