I've built a content type to handle document upload. My content type uses a Book node to handle directories/subdirectories and I would like to show a couple of Views that shows the directories structure. When clicking on a directory I would like to show, in another view, all the documents inserted in that directory.
Do you know any existing examples of Views/Panels? That shows a similar structure, as in the Windows Explorer, using Views2?
You can use this module: views_tree
Also tree-like can be built via argument handlers...
Related
I have have made a folderish content type called supplier_folder, which displays a list of suppliers that can be added under it, and their information. I can add it through the navigation bar, but I would like to add it programatically during setup.
I have been following the tutorial on custom installer code (http://docs.plone.org/develop/addons/components/genericsetup.html#custom-installer-code-setuphandlers-py) and have looked at creating objects programatically (http://docs.plone.org/develop/plone/content/creating.html).
Unfortunately, the second article says I need to have a folder created. How can I get around this and add the supplier_folder object at the Plone Site outside of a folder?
IIRC, only users with role Manager or Site Administrator can add content to the root of the site; you can overcome this limitation in two ways:
by using the _constructInstance method as it bypasses the permissions when creating an item
by switching roles inside your code with plone.api.env.adopt_roles
I personally prefer the second one.
you can see an example of a pretty complex setuphandlers.py in interlegis.portalmodelo.policy package.
When you create a new Plone site, it's also creating some default content types.
Look at how Plone do: https://github.com/plone/Products.CMFPlone/blob/1471828ee97a8dd84396bad4a3286be514819869/Products/CMFPlone/setuphandlers.py#L119
There are a couple of ways to achieve this. The buildin mechanism is to use GenericSetup in combination with "structure" folder as described here: http://koansys.com/tech/create-plone-initial-content-with-generic-setup
In short you need the following:
Create a folder "structure" in your Generic Setup profile (in general, under profiles/default)
Create a .objects file with the following content: "suppliers,supplier_folder"
in "structure" create a folder "suppliers" with a .properties file and content:
[DEFAULT]
title = Suppliers
description = Some usefull description text
As far as I remember this is ok for simple structures likes your. If you have complex structures with folders and sub-folders and want more specific control you probably need to write python code. I made some stuff here: https://github.com/collective/zettwerk.setup/blob/master/zettwerk/setup/structure.py
But zettwerk.setup is not yet released, but you should be able to integrate the structure.py right into your project. Than you can the handle_structure method into your setuphandlers.py and passing a structure dict like this:
handle_structure(portal, [{'id': 'suppliers', 'portal_type': 'supplier_folder'}])
The advantage of this method is, that you can also control metadata like workflow state, default page setting, portlets, local roles and some others.
I created a content in my Plone 4.3 site (no grok here) with the very nice Dexterity through-the-web editor. Now I'd like to customize the default view for this content.
I've read Martn Aspelli's book but the problem is that through-the-web content does'nt have a specific interface (so I can't use it to create my specific view).
If you want to do this all through-the-web, then do the following:
Create a template for your view in the "custom" folder of
portal_skins (through the ZMI). You'll probably want to start with a
copy of something like the page template
(portal_skins/plone_content/document_view). Give it a name like
your_content_type_view. Test it by appending /your_content_type_view
to the URL for a sample object.
Edit the Factory Type Information (portal_types/your_content_type/Default
view method) to be your_content_type_view.
What you will have done is create a skin-level view for the type. This is different from the browser views that Martin is discussing, which do indeed require a class. The Dexterity development team is working on a way to provide TTW maintenance of browser views, but that's for a later version of Plone.
Meanwhile, if you later transfer your Dexterity content type to a Python add on, you'll be able to use your template, possibly unmodified for a browser view.
On a Plone site with the structure
root
+-topic1
| +-page1
| +-page2
|
+-topic2
+-page3
+-page4
I want to have a view for folder root that lists the contents of the subfolders, like:
[http://host/plone/root/]
TOPIC1
- page1
- page2
TOPIC2
- page3
- page4
with "TOPIC1" and "TOPIC2" as headings and "page1" etc. linking to the actual pages.
Simply using a collection aggregating the pages in the topic1 and topic2 folders is not enough since it doesn't generate the subheadings.
I have searched the Plone products repository as well as the web for an extension providing a view like this, with no success. There are sources saying this can be done with custom Display Views, but since I am new to Plone, I hesitate to dig into hacking these.
Is there a Plone product/extension that can provide such a view on subfolder contents?
Or is there even a built-in solution that I am not aware of?
I figured it out.
Basically, what you want to do is extend the folder_summary_view template to include a content list for folder and collection items.
Create a copy. In the ZMI, go to portal_skins/plone_content/folder_summary_view and hit Customize. Go to the copy at portal_skins/custom/folder_summary_view and rename it to (for example) list_contents.
Activate it as folder view. Go to portal_types/Folder and manually add list_contents to the list in Available view methods.
Make sure the view only shows folders and collections. Wrap the code that generates the entry details in <tal:general_check condition="python: item_type in ('Folder', 'Topic')"> GENERATE ENTRY </tal:general_check>
Add the code for listing the item contents. You can steal it from portal_skins/plone_content/folder_listing since this already does what is needed. Copy the <metal:listingmacro> ... <metal:listingmacro> part, but replace the folderContents definition in <tal:foldercontents> with this line to retrieve the contents:
folderContents folderContents|nothing;
folderContents python:item_object.queryCatalog(**contentFilter) or
item_object.getFolderContents(contentFilter, batch=True, b_size=limit_display or 100);
(all in one line)
Note: item_object is the name given to the item in the outer listing.
If you activate list_contents as a folder view now, it works exactly as demanded in the question.
Warning: This is a copy-paste-hack by a Plone novice that works for me™. Use at your own risk.
You can also achieve this just via the Plone-UI:
Install Products.ContentWellPortlets and assign two collection-portlets below the content to your portal's default-view-item (f.e. 'front-page' as by default).
You could use a Collection here, with the two paths configured as criteria.
And if you want to, you could use this collection as default view for "root". Have a look at the default "news" and "events" folders and collections, located in it.
http://plone.org/documentation/manual/plone-4-user-manual/using-collections/adding-collections
I have a cck-node with some node-references like PDF-files, videos and so on. Now I want to build a view that lists all those files, which i already have. Yet I can only get the links linking to the referenced node. I'd like to have them link to the file in the referenced node.
Hope a generic example makes it clearer:
--
A Sample Product
Lorem Ipsum…
Relating Files:
Manuals
Manual A (should link to file instead of node)
Manual B (should link to file instead of node)
Movies
Movie (should link to file instead of node)
--
Hope someone can help me with this.
Note: Client preferes to have it build only with views - no template files or such because he's familiar with drupal but not with templates etc.
Try this module: http://drupal.org/project/nodereference_views - lets you format a nodereference field to show different pieces of the referenced node.
I use the Remote File module for a cck field displaying a remote image. It works with a known issue: images are reloaded on every edit http://drupal.org/node/395256
And as i do tests with lots of nodes and delete them afterwards, the images cached in filesystem become deleted too. Is there a way to tell filefield(?) not to delete them?
edit
Meanwhile found http://drupal.org/project/filefield_sources which works very nice on manually created or edited nodes. But there is no way to make filefield fetch the image on assigning the url to the place where it shows up when i let print_r($node) show it to me.
See also my post to this (wont-fix)issue http://drupal.org/node/590756#comment-2774472
Yes, there is.
You'd need to create an interface between your node and the file so when you delete the node, the file stays in place. Effectively, you're just deleting the association, not the file.
Perhaps this module saves to the files table and the reference to the file exists already.
You could develop a third party module that stores all your external files and has a GUI or some other interface to select them again for new nodes
Or, you could create a specific content type and save the files as separate nodes. Then you'd use node reference to join them.
Alternatively, the developer of that module says he'll add features if you pay him. However he does not guarantee it from what I can see :)