Plone: default display for new created content - plone

I have a browser view my_custom_display, that can be selected for folders using the menu: Display -> my_custom_display.
The problem appears after I select the custom display and I'm trying to create new objects inside the folder with this custom display.
By default all new items seems to have my_custom_display and my solution is to manually fix it with /selectViewTemplate?templateId=folder_listing.
What is the better solution for this situations? (Set a display only for the item itself not any new child inside it.)
(It's annoying because my browser view generates errors if used in wrong place. Yes, I can improve it, but...)
Update:
In /portal_types/Folder/manage_propertiesForm I added my_custom_display in Available view methods. I need it only for specific folders.

Solved by forcing layout setting on folder creation:
<subscriber
for="Products.ATContentTypes.interfaces.IATFolder
Products.Archetypes.event.ObjectInitializedEvent"
handler="my.package.globalhandlers.set_folder_listing_by_default" />
added in configure.cfg.
Then:
def set_folder_listing_by_default(folder, event):
""" Set folder_listing as default Display for new created folders.
"""
folder.setLayout('folder_listing')
Seems not nice, but it solved my issue. :)

Related

adding new menu in Select (All,Inverted Selection) in Alfresco Share

I am newbie to the Alfresco.Now my requirement is how to add new menu[All(All pages)] in Select. wherever user perform search function lets say 250 results have found & user selects All in page 1 & its selecting only current page results and not selecting entire 250 records & then user goes page by page can edit the properties for the entire 250 records.in the new functionality if user selects [All(All pages)] then all records should be selected & edit the properties for 250 records at one go.So I want to add new menu with All(All pages) & change the existing menu current labels as All(Current Page).How to achieve this functionality and what files need to changed.How should i know that which files are currently used?Is there any debugger can be used to know the files?
Alfresco Version
4.2.e
My guess, is that if you go through this previous version of Jeff Potts' Tutorial you will be able to figure this out by yourself.
Simplest option is to edit label of that particular action in out of box property file.
You can find it under
<ALF_HOME>\tomcat\webapps\share\WEB-INF\classes\alfresco\messages\slingshot.properties
This entry
menu.select.all=All
Change label here and it will be reflected.
NOTE: It is not best way to implement this. Ideally you need to override property file and change label
The issue here is that only the items shown on the page have been loaded. This means that the metadata for the items not shown on the page won't be available. The metadata of each node is used to evaluate it's applicability to any action. If the node is locked or has had its permissions changed then it won't be possible to edit it. This is why "all" only means all items on the current page of data.

How to change the Apache Wicket's CSVDataExporter's link type to a button?

I have a Grid, which have a TopToolbar and BottomToolbar. In the BottomToolbar, I added a CSVDataExporter:
CSVDataExporter csvDataExporter = new CSVDataExporter();
csvDataExporter.setDataFormatNameModel(new ResourceModel("csv.export.link.name"));
csvDataExporter.setDelimiter('|');
addBottomToolbar(new ExportToolbar(this).addDataExporter(csvDataExporter));
I have the link, so I can export the table to CSV fine!
BUT! How could I change the CSV export link to be a Button, but do the same and be at the same place as it was? Thank you!
The Link is generated by your ExportToolbar using the createExportLink method. To generate something else (as in any other component) you can extend the ExportToolbar to override this method. If this is the only place where you need this functionality, you can do so by implementing an anonymous inner class.
Generally you'll want this method to return a Component that has it's own markup, like a Panel, that contains whatever you want to display as your Exportlink or -button.

Rendering a z3cform Wizard as a standalone view

Plone/Zope's z3cforms inherit from BrowserPage, and therefore should be able to be rendered without the use of an additional View and View Class. When I try to do this, the form renders fine, but none of the form's fields appear. I am trying to solve why this occurs. Keep in mind this example is using collective.z3cform.wizard, which essentially provides two classes, a Wizard and a Step. A Wizard is a Form (capital F) that mostly provides the machinery to glue the Steps together and maintain state with sessions, and a Step is just a Form.
To me, it feels like either the macro is incorrect, the context is wrong, or there needs to be some wrapping/unwrapping of the form. Basically, I feel like there's some one magic line of code or piece of information I'm missing, which is often the case with Plone.
When the form is wired up to use a separate view (which is redundant), the form renders fine with all the fields showing.
Since I understand this is complex, I've built an example-only standalone package on GitHub that showcases the problem. If you install this package into a stock Plone site with buildout, you will get three views:
http://localhost:8080/Plone/working
http://localhost:8080/Plone/almost
http://localhost:8080/Plone/broken
The working view requires a separate view and a whole-template-wrapping TAL tag, which is both kludge and redundant...but it works and renders the form with all of its fields.
The broken view is wired up how it should be, with the form instance representing the view itself, with the template defined in the Wizard class.
The almost view is identical to the broken view, except that the template is associated with the Wizard's Step rather than the Wizard itself. This results in a broken render, but the form renders with all of its fields.
I hope someone can help me trace down why exactly it is that the broken view renders the form, complete with buttons, but none of the form's fields.
Thank you in advance.
Your broken view does not render the fields because it does not try to render the current step. The default wizard template has something like this in it:
<div tal:define="form nocall:view/currentStep"
tal:replace="structure form/render" />
which looks up the current step and renders it. But you've overridden that with your own template which just calls the ploneform-macros, which is a generic z3c.form thing that knows nothing about the existence of steps.
You should stick with the default wizard template instead of overriding it, or if you need to customize it you should copy the default wizard.pt from collective.z3cform.wizard as a starting point.
Meanwhile, your 'almost' view is indeed almost working. The problem here is that the wizard's default template renders the step's template in the middle...but your step's template is set up to produce a full html page (because it uses the master macro from main_template). If you need to customize this template, I would again recommend starting by copying the default step template from c.z.wizard (wizard-step.pt)

Loop through child items and get image field for showing on parent's view/template

I have a parent content type RetailFont, it has child types, and one is called FontWeight.
Fontweight has an image field called WeightImage.
I have successfully added a new view and template for RetailFont (called FontWeightView). I would like to loop through and show some of the fields for all the WeightImage items inside it, such as its title and ImageField.
I tried copying folder_summary_view.pt contents to my template file but it generates errors.
Does it need something in my FontWeightView.py file to work? http://www.pastie.org/3286449
test() is a deprecated page template method and should no longer be used.
You can work around this with the logic:
<tal:something condition="python:somecond and ifistrue or ifisfalse" />

How to change the state in Adobe Flex, using ActionScript?

I`m really new to Flex and ActionScript so please be patient with me.
I want to implement this script: tinyurl.com/yafqrqb
...that is doing this "magic" : tinyurl.com/y9qg32r
...but I want to tweak it a little on InfoWindowTabbedComponent. To be more precisely I`m trying to insert links in that tabs, and when you click one the state will change.
You can see my custom InfoWindowTabbedComponent at the end of the post As you can see, right now I have 2 functions that open url`s.
What I`m trying to do is to change this:
var adobeURL:URLRequest = new URLRequest("http://www.microsoft.com" );
navigateToURL(adobeURL, "_self");
Into something that change the current state.
Can you please help me?
Here`s my custom InfoWindowTabbedComponent: http://pastebin.com/f387bc3b9
I'm not sure I understand what you want to do. If you just want to set the selected Tab, instead of calling navigateToURL() set myTabNavigator.selectedIndex (or selectedChild)
If you really want to change the state, each component has a currentState property, but then you would have to define the states first (via the tag)
And if you really want to navigateToURL() you could navigate to javascript:somefunction() and then set the application state via ExternalInterface, but that would be horribly circumstantial.
Cheers,
Jörg

Resources