Raphael Ritz ha scritto:
Mirto Silvio Busico wrote:Hi all,Hi Mirto,
Hi Raphael,
I'm trying to create a custom view for a content type derived from atfolder.Hope you solved this in the meantime but if not and for the archive ...
Thanks a lot for your reply,Yes, in the meantime I solved this; but, for the history I'll write below how I have done it.
How can I put in the .pt file the data relative to the items contained in the folder?I looked at http://plone.org/documentation/manual/developer-manual but I was not able to find what I need.I tried to find the base_view.pt (well this was the name in plone 2.5 days) for atfolder between the plone eggs; but I found nothing. Probably it changed name and egg.'base_view' should still be around in the 'archetypes' skin layer (code base: the Product.Archetypes egg, portal_skins in ZMI) and it should be the default view for all AT-based content types (though I have to admit that I have no idea whether AGX messes with that). base_view in turn pulls in a bunch of macros: header, body, folderlisting, footer (or so) which can selectively be overridden on type basis (the <portaltype>_view.pt way as pointed out). If you do not see a folderlisting part for your type I would start by checking the conditions used by the folderlisting macro in your context. BTW: what do you get when you just append '/base_view' to the URL of an instance of your custom type? See http://www.zopyx.de/downloads/documentation/mysite.pdf/view and there in particular the 'Views' subsection in 'Basic customization' section of the 'Customizing Archetypes' chapter.
Thanks. I'll look at this asap.
Raphael
Regards Mirto ======================================================================================== [... how I solved ....]To be clear, I'll use the real paths I have on my machine; but these paths can be different on other installations.
I installed PLone 3.3.4 in /usr/local/plone334 with unified installer (zeo version)
The in the src directory I created a product named Products.gas3 (Products is needed for archgenxml)
dir: /usr/local/plone334/zeocluster/srccreate with ../bin/paster create -t archetype giving namespace "Products" and package "gas3"
In the dir /usr/local/plone334/zeocluster/src/Products.gas3/Products create an UML file gas3.zargo (I used argouml)
In the UML
* create a class gas3collection (stereotype <<atfolder>>) [well, my
diagram is more complex but for solving the problem this suffice]
* in this class set the tagged values for "base_view" and
"immediate_view" to "g3_coll_view"
* create a package named "browser"
* in this package create a class "g3_coll_view" with stereotype
<<view_class>>
* link this class with the class "gas3collection" with a
"dependence" arrow (dotted line arrow and the arrow pointing to
"gas3collection")
Now generate the the code with archgenxml
in the dir
/usr/local/plone334/zeocluster/src/Products.gas3/Products/gas3/browser
edit the file g3_coll_view.py
Add the lines ====================================================== ##code-section module-header #fill in your manual code here from plone.app.layout.globals.interfaces import IViewView from zope.interface import implements, Interface class Ig3_coll_view(Interface): """ g3_coll_view view interface """ def test(): """ test method""" ##/code-section module-header ====================================================== and in the class definition add the "implements" line ====================================================== class g3_coll_view(BrowserView): """ """ ##code-section class-header_g3_coll_view #fill in your manual code here implements(Ig3_coll_view, IViewView) ##/code-section class-header_g3_coll_view ======================================================At this point edit the g3_coll_view.pt file in /usr/local/plone334/zeocluster/src/Products.gas3/Products/gas3/browser/templates adding the content to the div:
================================ <div metal:fill-slot="main"> </div> ================================ I took the code from /usr/local/plone334/buildout-cache/eggs/Plone-3.3.4-py2.4.egg/Products/CMFPlone/skins/plone_content/folder_tabular_view.ptATTENTION: drop any reference to the "python:test" instruction: this causes a runtime error in this framework but still works in Plone framework.
Drop lines 40-42
==========================================================
tal:attributes="class python:test(here.Format() in ('text/structured',
'text/x-rst', ), 'stx' + kss_class, 'plain' + kss_class)">
==========================================================
Drop line 82
==========================================================
tal:attributes="class python:test(oddrow, 'even', 'odd')">
==========================================================
After this the custom view shows correctly.
USEFUL LINKS:
launchpad bug about python:test
https://bugs.launchpad.net/zope3/+bug/223528
Getting the Add… Menu in your custom browser views (content actions):
http://lionfacelemonface.wordpress.com/2010/03/11/getting-the-add-menu-in-your-custom-browser-views-content-actions/
<<attachment: mirtosilvio_busico.vcf>>
_______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
