Reputation: 2876
I need to add a condition to avoid the load of some javascript code when adding an object of my content type; the following condition only works when editing the object:
<?xml version="1.0"?>
<object name="portal_javascripts">
<javascript id="form_tabbing.js"
expression="python:object.portal_type != 'collective.nitf.content'" />
</object>
This javascript code is responsible for creating the tab interface but I want to bypass it for my use case.
Any hint?
Upvotes: 3
Views: 472
Reputation: 46
Actually, you can solve this in a different way.
Instead of avoiding the load of the Javascript file -- which would have nasty consequences when it comes to caching and so.. -- you could avoid it from acting on your form.
The *form_tabbing.js* will look for a form element with enableFormTabbing class:
<form class="enableFormTabbing">
<fieldset id="fieldset-[unique-id]">
<legend id="fieldsetlegend-[same-id-as-above]">Title</legend>
</fieldset>
</form>
So, all you need to do is avoid the form of getting this enableFormTabbing class.
As your content type is created with Dexterity, I suggest you to override the AddForm as follows:
class AddForm(dexterity.AddForm):
"""Default view looks like a News Item.
"""
grok.name('collective.nitf.content')
grok.layer(INITFBrowserLayer)
enable_form_tabbing = False
Thanks to plone.app.z3cform magic an enable_form_tabbing attribute will allow you to control tabbing on your form.
The same applies to the EditForm.
Hope that helps
Upvotes: 3
Reputation: 779
I have tried and you can also do this:
python:context.restrictedTraverse('@@plone_interface_info').provides('your.dotted.interface.IName')
Kudos Mikko! :-) http://readthedocs.org/docs/collective-docs/en/latest/components/interfaces.html?#plone-interface-info
Upvotes: 0
Reputation: 1879
Try portal_type, not meta_type with Dexterity types. All Dexterity items have the meta_type of 'Dexterity FTI.'. This also means that OFS methods filtering on meta_type will not work and you have to use list comprehensions instead.
Upvotes: 0