Overriding portlet templates with z3c.jbot - plone

Is it possible? Do portlet renderers satisfy necessary conditions for z3c.jbot to kick in?
If so... what's the correct syntax to refer portlet renderer via z3c.jbot filename?

Yup, it's possible.
The filename is just the package name plus the original template file name, just like other z3c.jbot files. For example, the manage-contextual.pt template in plone.app.portlets.browser.templates becomes plone.app.portlets.browser.templates.manage-contextual.pt to override the original.

Related

template twig not found

I have a problem with a render function in my controller.
I have:
a bundle, named CoreBundle
a controller named DefaultController
in which I have an action named loginAction
in which I am trying to render a template twig with this line
return $this->render('FooCoreBundle::Default:layout.html.twig', array());
I am always having the same not found error for the template. I have tried with an other template twig it is the same problem. In my views folder I have a Accueil folder in which i have put the login.html.twig template I want to render.
I tried to replace it directly in views folder but no changes. Sorry for my english hope you can help. Thank You.
A worth-while reading piece of info from the documentation:
Symfony uses a bundle:directory:filename string syntax for
templates that live inside a bundle. This allows for several types of
templates, each which lives in a specific location.
Supposing:
FooCoreBundle is your bundle -> src/Foo/CoreBundle
Default is the template directory -> src/Foo/CoreBundle/Resources/views/Default
layout.html.twig is your file -> src/Foo/CoreBundle/Resources/views/Default/layout.html.twig
Then the route you should use would be 'FooCoreBundle:Default:layout.html.twig' without the :: you're using in 'FooCoreBundle::Default:layout.html.twig'
The :: refers to a base template specific to the bundle. If you used FooCoreBundle::layout.html.twig then your template should live at Resources/views/layout.html.twig inside FooCoreBundle.
Hope this clarifies things.
You should use
return $this->render('NeobeCoreBundle:Default:Accueil:layout.html.twig', array());
No double colon, add the Accueil subfolder
It is not really an answer, but it could be handy for those who arrives here with symfony 4.
In documentation authors says do not organize your business logic into bundles.
In modern Symfony applications, it's no longer recommended to organize your business logic using bundles.
Of course you can, just not recommended. See here.

magento - layout update xml to add remove or modify element class names

I've been trying to figure out some layout update xml directives to add, remove or otherwise modify css attributes for elements. Something like:
<reference name="breadcrumbs">
<action method="setElementClass"><value>light</value></action>
</reference>
But without any luck at all.
Why do this? - because, in this case and for some pages, I want to handle the breadcrumbs differently. I spose I could make a few different breadcrumb templates and update them on a page by page basis, but this seems like overkill.
Given the Googles silence on this subject makes me wonder if I'm the only one to ever need this seemingly reasonable behavior.
Is there a way to elegantly modify classes for template blocks via update xml?
cheers -
b[]x
You need to understand the purpose of the command you are running,
<action method="setElementClass">
Which means that on the breadcrumbs block, you are calling the function setElementClass. The set and get functions are a standard call of the Varien Object, it is just a way to set a variable in the class instance.
So what you are doing above is the equivalent of doing:
$class->setElementClass('myvalue')
Now, you can set whatever variable you like, but unless the block/phtml file actually use that variable, it isn't going to do anything.
In order to modify the CSS classes via XML, you'll also need to edit the corresponding .phtml file and include:
class="<?php echo $this->getElementClass(); ?>"
Wherever you plan on using it. There is nothing wrong with hardcoding CSS classes in the phtml files - that's what they are they for. Using XML to update these values is a bit long winded - UNLESS you are making a white-label store and wish to use a simple XML swap to make changes quick and simple.
I dont think there is a way to modify css classes through xml in Magento. Class names are hardcoded in .phtml files. So i guess the only(actually 2) way to change your styles is either to overwrite .phtml files with your new .phtml files with updated css classes or change stylesheet style definitions for already existing class names in styles.css

Unable to hide Products.Carousel.viewlet in version 1.1

Products,Carousel adds a viewlet to the plone.contentviews manager using some funky inline code in setuphandlers. I am trying to hide this viewlet. I have tried various techniques such as:
overriding the template in my configure.zcml
using the <hidden> tag in my viewlets.xml
But nothing seems to take effect. However if I go into ##manage-viewlets, I am able to hide it by hand.
How can i do this automatically on startup?
Not very elegant, but you could override the viewlet template using z3c.jbot if you're really desperate. Just provide an empty template called Products.Carousel.browser.viewlet.pt in your z3c.jbot templates folder, inside your custom product.

Drupal theme files outside of theme folder

Is there a place where I can place override theme files other than a theme's folder? For example, if I wanted to override the appearance of a view's row in the same style for more than one theme without having to use more than one file.
If there isn't a generic way to do this (for any theme file), is there a way to do it for a view's theme files?
In your module, you can use hook_theme to declare a theme function or template for your view's row. This way, your single template will be used by all your themes without any special code in them. See the Theming your views in your module section in the Views's API Advanced Help page.
You could include an include_once type statement in your tpl.php file and just import the code from where ever. This way you have any number of files that refer to one.
It is not recommended though since if you move your theme folder or rename anything this can be harder. Also if you put your theme in another site you need to keep track of all of these off-theme hacks.
I think views seeks tpls inside of the theme folder. It's be nice to have something like that though.

Using directives in new files

Is it possible to have additional "using" directives automatically added to my new aspx.cs files so that I do not have to keep typing the same ones over and over again (i.e. custom namespace using directives)
You can edit the files that are used by the template. Better yet, create your own. File + Export Template.
You don't have to type them in. When writing the code, type in the name of the class (without the namespace). Then hit CTRL+.. That will open up the resolve type intellisense helper. It will add the using statement to the top of the file. No scrolling necessary.

Resources