Tweaking Plone Dexterity Container View - dexterity

I have a custom plone dexterity content type which is a container of other dexterity types. I have added an additional view to recursively summarize the contents of this type.
I'm needing anonymous users to be able to navigate to the default view like normal, but then also be presented with a link to this summary view. I do not wish to rewrite the default view from scratch, but just add a simple hyperlink to it. I have read the dexterity manual, but I cannot seem to make the leap to how to pull off something like what I'm trying to do.
Any recommendations?

Related

Linking to a "File type" Dexterity Content Type

We're creating a database of files on a new Plone 4.3.2 website, using eea.facetednav as the main interface. In order to have multiple searchable "tags" plus additional information like publish year, article type, etc etc, we've created custom Dexterity content types for these "files". One of the fields on the Dexterity content type is to upload the actual file.
Everything was going swimmingly UNTIL I realized...
One of the basic functionalities of linking to "files" is now broken. Whereas we would expect creating an internal link to a file will prompt opening the file or downloading it when clicked, now it just takes you to the "view" for the new Dexterity content type, where there's a link to the actual file.
This is pretty cumbersome. Has anyone done this before, or found a way to have it automatically link to download the file? If we need to disable/scrap the Dexterity content type view in favor of the direct link, that's probably fine, but bonus points if you can think of a way to make this work both ways (i.e. have a linking method that takes it to the file and a linking method that takes it to the view).
This is the page I mean by "view", in case it's unclear:
... Off the top of my head, I can think of a weird Diazo solution of making a custom template that parses this view and automatically redirects to the file link, but that seems wrong/weird. Other thoughts?
I'll go for the bonus points, though I haven't fully tested this...
First, you have to designate your file field as the content type's "primary" field. Unfortunately this option doesn't show up in the UI so you have to edit the XML version of the schema (there's a button for this in recent versions of the dexterity control panel). Add xmlns:marshal="http://namespaces.plone.org/supermodel/marshal" as a namespace at the top, and add marshal:primary="true" to the field tag in question.
Then, find your type in portal_types and change the "Default view method" to ##download. (It usually starts out as view for Dexterity content types.) This should make the item's URL download the file rather than showing the normal view. It knows which field to use because you designated it as primary.
You can still access the normal view by adding /view to the end of the item's URL. If you want Plone to do this when linking to the type from navigation and folder contents (just like it does for built-in images and files), go to portal_properties/site_properties and add the type's id to the typesUseViewActionInListings list.
If I had to solve this problem, I'd take the "link" content type view in plone.app.contenttypes as a model.
When someone asks to see a link content type object, the view looks to see if the requestor has the Modify portal content permission on the link object. If they do, they see the conventional view, giving them the opportunity to edit. If they don't, the view returns a redirect to the target URL.
Your code would be simpler. After checking the permission, you'd only need to append ##download/field_name to get the redirect URL.

Create custom page template based on default for dexterity type

I have created a page template for my custom dexterity type.
The default view automatically shows all the fields, rather than my custom template which shows no fields.
I'd like to start my template by copying the default template. I have tried pasting in a copy of plone.app.dexterity.browser/item.pt however that gives me
LocationError: (<my.types.resource.ResourceView object at 0xb4d18bcc>, 'widgets')
I am not sure why.
I guess that using this template might not even be the best solution, if I need to change the way individual fields render. In that case I am wondering how I can start with a template which contains the fields in my type (in the past I used ArchGenXML). Is there an equivalent process for dexterity?
Derive your view class from dexterity.DisplayForm.
This may make your copy/pasted template work immediately by giving it the view methods and properties it needs. It will also make available variable like view.widgets, which contains a list of display widgets in schema order.
See http://developer.plone.org/reference_manuals/external/plone.app.dexterity/custom-views.html#display-forms for details.

Custom title for existing Dexterity content type

I have a Plone site using a local product which is common across several of our projects that provides a Dexterity content type which is entitled "Generic". I'm using it in a somewhat different way, however, so I'd like the content type to appear as "Specific" in the add content menu. (It's not necessary for the add/edit path to contain the adjusted type name.) Is there a programmatic way I can change the title for my installed version of the type?
Not sure if this is the best approach, but I've added an importStep that does:
portal_types['common.package.ContentTypeID'].title = 'Specific'

Drupal 7: Add view to content type

I've been making a template for a particular content type, but just ran into a problem: I need to embed a view into the content type.
I am aware this can be done via several different methods, but I don't see one that fits exactly my needs:
I need the view added automatically for all pages of that content type.
Using blocks in a region is not an option, as I want to avoid defining a region in the middle of a page that should only be available for a specific content type.
Translatable label.
Possibility to freely apply a template to all fields in the content type (excluding the embedded view).
I tried doing it via page layout (Panels) and simply adding node content fields and the view to my layout regions, but then I get another problem: I can't style my content fields without doing something that seems a bit over the top:
Currently I have about 20 different content fields in the content type that are wrapped in HTML and styled in my template file. I have a translated label for each of these in the template file. From what I can tell I'd have to add a template for each of the panes containing content fields to add my translated labels and HTML needed to style each field.
I'm not really fond of making 20 templates, 20 theme hook suggestions to get the templates to work and 20 regions in the panel layout just to get a view inserted in the content type.
Am I doing something terribly wrong here? Any suggestions?
You may want to try the Viewfield module or similar modules (search for "view field" or "view reference").
If you are doing something more complex like changing/filtering the view based on some value in your content type, then you may have to use Viewfield module in combination with something else that will help fill in the filter values.
I've never done something like this before so I'm not sure exactly what module combination would work but Rules or Computed Field come to mind as possible helpers.
You have to use "views node field" http://drupal.org/project/viewsnodefield, after installing this module you have to select the "Node content" in the display (like blocks,page). then click the add display. if you want to display the content like this page http://www.richtown.ae/?q=content/arabian-ranches then you have to download the views_galleriffic module and install it and choose the style option "Galleriffic Gallery". You can choose the content type by using the filter in the views.
That's it cheers
i implemented this in my website richtown.ae
if you still unclear please send me the email social#richtown.ae i will reply you & ready to help you we can share information
i am using this module in drupal 6.
I resorted to using the EVA module ( http://drupal.org/project/eva ).
In addition to Woodgnome's answer
Let's say you have a content type named 'Product'
You want to attach a view to it.
Here are the steps using the eva module :
On your view edit page :
Section Displays
+Add : Eva field
Section ENTITY CONTENT SETTINGS
Entity type:Node
Bundles:Product
That's it, going to a node product type will now display the view

Customize the way CCK Node Reference fields are displayed in Drupal

Node reference fields in Drupal are displayed as lists by default. Is there a way to change that?
I'd like to output them as JSON so I can create a fancy JavaScript visualization.
You can modify it in 2 ways: via custom module with function hook_form_alter or via theming (preprocessing form or templating form).
http://api.drupal.org/api/function/hook_form_alter/6
http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6
For AHAH: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#ahah
Also, nodereference already have little ahah: "autocomplete" in field editing of custom node type.
Consider the Content Templates (Contemplate) module. Here is a quote about it (from the module's project page):
... allows modification of Drupal's teaser and body fields using administrator defined templates. These templates use PHP code and all of the node object variables are available for use in the template. An example node object is displayed and it is as simple as clicking on its properties to add them to the current template.
This module was written to solve a need with the Content Construction Kit (CCK), where it had a tendency toward outputting content in a not-very-pretty way. And as such, it dovetails nicely with CCK, adding a "template" tab to CCK content-type editing pages and pre-populating the templates with CCK's default layout. This makes it easy to rearrange fields, output different fields for teaser and body, remove the field title headers, output fields wrapped for use with tabs.module (part of JSTools), or anything you need.
But Content Template can actually be used on any node type and allows modification of the teaser and body properties before they go out in an RSS feed, search index, or are handed off to the theme. Additionally, ConTemplate can choose to add any files, images, or other media to RSS feeds as an attachment.
Templates are normally stored in the database but it is also possible to create disk-based templates which live in your sites directory and can be inherited across multisite installations in the same way as themes or modules.
Try the Custom Formatters module, simply make a custom formatter to render the node out exactly how you want it, then output the formatter to code or to a Feature for deployment.

Resources