When using XPCollection as the collection of XPPageSelector, does the XPCollection load all the objects that satisfy the specified criteria or just a page?
The XPCollection will contain a Page.
Related
Have a requirement to create a WordPress dynamically based on multiple apis data, And we want to use that response data chunks as short code in page builder while designing backed with template.
We want to retrieve data only once in page template and how to make it available something $post without having to fetch on each short code.
Ex: $system_data -> which might contain name, description, performance etc, more attributes
And want to make common short code which takes attribute and get the relevant information.
[system-data attr="performance"]
What is the best way to achieve this, without loading whole data on each short code
you can use global variable to store data from first short code and use in other short code for entire page but you should check value is empty or not in every short code before use it
I have an entity type "Post" and I would like to create a view that will show one random Post with a given category. I created a Data pipeline that grabs all posts and I created a view with ListPresentation = a "TemplateSettings" entity type that lets me choose categories.
I planned to use the Razor template to filter the items for those matching the categories in List.Presentation.Categories. But, I can't seem to reference List.Presentation.Categories. I get an error that System.Collections.Generic.List doesn't contain an entry for "Presentation". When I use #ListPresentation, the whole object in null... so #ListPresentation.Toolbar, etc. all throw errors, despite me having set a "Demo Item".
Can anybody see what would be wrong with this setup? How do I reference List Presentation stuff in Razor?
Thanks.
I figured this out... The direct thing seems to be "ListPresentation", but the snippets use "List.Presentation". Still, it wasn't working in my case because I was using a data query that didn't include the module data. So, I had to modify that query to include the module data as well as the full list of entities, regardless of the module. Then, I got the full list from one data stream, and the ListPresentation fields were available.
Note also that you can use ListContent.Presentation - that would be the newest, most consistent API which always places Presentation information as a property of the entity it's describing.
I add a FieldIndex for my content type according to the Plone.org instructions.
In the ZMI, I can see the indexed items at /mysite/portal_catalog/Indexes/Building. My content type (providing IMyType, with one field building) is folderish and contains a Photo (providing IPhoto, without building field) as allowed_content_types in profiles/default/types/MyType.xml file.
I want indexing only for MyType's building field. However, it seems items of Photo type get indexed with the value from their parents. That's annoying. Does the code #indexer(IMyType) mean indexing for IMyType and its contained types? How can I index only for IMyType?
What an indexer does is to get the attribute directly from the object being indexed. In Plone that is as special wrapper, one that will use registered indexers (as created with the #indexer decorator) if they exist.
However, if you index happens to index building and that is also an attribute on your IMyType objects directly, any contained objects will have that attribute through acquisition as well. Registering an indexer for IMyType does not prevent this.
There are a few ways around this:
Use a different name for your indexer, one that doesn't match the attribute name. Note that if all you do is index an attribute the indexer is redundant though, the index could just as well retrieve the attribute directly.
Register a "catch all" indexer:
from zope.interface import Interface
#indexer(Interface)
def catchall_ignore(ob, **kw):
# Raising AttributeError means: do not index anything
raise AttributeError
Instead of direct attribute access, now this indexer method will be used instead for Photos, causing the indexer to not register a value for building.
This is how acquisition works.
here how to workaround this:
http://plone.293351.n2.nabble.com/how-to-prevent-portal-catalog-from-indexing-acquisition-values-td2650735.html
"use a custom indexer that does the aq_explicit check."
I need to pass a Infragistics ultrawebtree from a page to another. I used Session("data") for this and then I just access it from another page. But when I assign the session value after casting to a Infragistics ultrawebtree control in my second page, it doesnot build the tree structure and it is invisibile. Is I am wroung in this approach, is there any other way to pass the entire tree structure from one page and display it into another page. Any help is appreciated
If anything, I would store the datasource in session instead of the tree. Storing the entire control in session creates a lot of unnecessary overhead, and limits your options per implementation on the next page.
EDIT: You should be able to export the tree structure to XML format, and store the XML in session. According to the documentation there should be WriteXmlDoc() and WriteXmlString() functions available. There's also ReadXmlDoc() and ReadXmlString() functions you can use to repopulate the tree on the next page.
Here's the documentation for the UltraWebTree. You'll see these methods under the Public Methods section:
Only the data should be stored in session. Storing controls in session is likely to cause issues because the control will be disposed during page unload and controls shouldn't be accessed after being disposed which is what would happen when accessing the control from session. See Why Controls Shouldn't be Stored in Session for more details.
I would like to use collective.easytemplate to generate templated emails (for content rules). However, I am not sure if it can output an objects workflow state. Anybody know if it is possible and how it is done?
Thanks.
You can, it is possible, and one way is to use the portal_workflow tool e.g. from parts/omelette/plone/app/contentrules/tests/test_action_workflow.py:
self.assertEquals('published',
self.portal.portal_workflow.getInfoFor(self.folder.d1, 'review_state'))
More generally, something like:
context.portal_workflow.getInfoFor(context, 'review_state')
in a page template should work. Or use the portal_catalog as Spanky suggests e.g. if "obj" is a catalog "brain" (i.e. part of a result set from a catalog search) then:
obj.review_state
should work.
The portal_catalog also has an index of the workflow's Review State, so if you don't already have the object you're working on (e.g. context ≠ the object) you could use the catalog, look up the object and get the review state from the resulting "brains" object.
Apparently there are ALSO browser view methods available to you as well, and I notice that one of them is workflow_state. See:
http://plone.org/documentation/manual/theme-reference/page/otherinfo