Linking to a "File type" Dexterity Content Type - plone

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.

Related

Custom Template & Rapido Breaks URL Paths

Outline
I have a custom type (Dexterity) called "Gallery Profile", for this type I went into the ZMI (portal_skins/custom), created a new "Page Template" and wrote a custom template for my gallery. The gallery contains a bunch of lower down images and one main image of the owner of the gallery, like a News Item view but a gallery tacked on the bottom.
The customer wants this main image to be published to Facebook when someone hits 'Share' and some more specific info in the title when published.
Work carried out
Configured a Rapido script to write the 'og:image' meta data etc HTML that is required to get this to work (the default Plone stuff only publishes the sites logo unless you're viewing one Image type).
If I go to test the HTML coming out of Rapido via direct web address it works swimmingly. (site.com/##rapido/og_share/block/og_share) - I'm on the slightly older version of Rapido hence the non-plural version of block.
The problem
If you go to my gallery page where we have applied the template, then check the HTML, all of the OG meta data is pointing to the template instead of the current page its on.
This effects queries too (if for example you're using a script to find out what images are within a folder) - it searches /my_template instead of site.com/a_folder/my_template_is_on
In the Rapido Python file I've tried things like:
context.content.absolute_url()
context.content.absolute_url_path()
context.request['URL']
context.request['VIRTUAL_URL']
context.request['ACTUAL_URL']
... and probably more as I've been at this a while.
If you're not on the custom template, it works.
To Reproduce
Create a custom template
Assign it as the default view of a folder or any type.
In your template put <div tal:replace="structure python:context.REQUEST"></div> (just to see the difference)
In your Rapido try using context.app.log() and any of the above
Refresh your templated folder while checking the logs and the output from the context.REQUEST stuff.
You will see the differences and how Rapido is having a hard time getting the URL of the page you are on even though its there.
I've always had this problem with Rapido I just tend to work around it but in this particular situation I am stumped.
So in summary
Am I being an idiot and missing something obvious?
Is this possible?
Thank you for your time.

Prepopulate Content Type Args when going to /admin/content in Drupal 7

I created a Drupal site. The admins who will be using the site for content management have no Drupal knowledge and I have been tasked with making this as easy as possible for them. I'm creating an admin control panel and I want a quick link that takes them to the admin content page, but with the "content type" prefilled. For example, for content I have pages, events, resources, and testimonials. I want to provide them with a quick link for editing content type EVENTS only. So it would go directly to admin/content with the type filter set to "events". The URL does not currently add args or anything like that.
Anyone know of a way to do this?
yes you can do this- just use this module: Drupal admin views which supports a REGULAR VIEW for admin/content. The View is set to use ajax though- just remove this option and save it and call /admin/content then. There you will see the resulting filters in the URL (you can even set their keys to a value you like inside the view). Set back to use ajax (if you like) and use the keys in the URL for type it's simple just call /admin/content?type=YOURTYPE

plone: "to the top of the page"-link at the end of a collection list

how can I add a "to the top" link at the end of a collection in plone?
This collection is in a collage. I thought of adding the article type "page" in a new row where I could use the HTML-Editor and use there an internal link to the top of the page.. But it seems inconvenient to me.
Isn't there a better way?
A very simple way could be using the Plone inner feature of the document_actions (a tool still available but not used anymore from Plone 4.0 and up).
Go to ZMI, access the portal_actions tool, the document_actions. Now add a new "CMF Action" from the form on the right.
The important information for you is the "URL (Expression)", that must be something like string:#youranchortarget. To fill every other field copy from existing actions.
If you need this link only for a content type or something like this, just play with the "Condition (Expression)".
Links inside this tool are displayed in the plone.abovecontenttitle.documentactions viewlet.
If you want the link on every "page" item, then you could customize the default view's template.

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

Auto-associate page metadata?

Links require SDL Live Content login.
We can choose default schema (and a mandatory option) in folder properties. New components in these folders will have the schema selected with appropriate fields filled out.
We can choose default page template for structure group (SG) properties. New pages in these SG will have the page template selected.
Do we have a similar option for page metadata such that in a given SG, author gets both page template and predetermined page metadata (fields) for either:
page creation
page template selection
We can do this easily with Inline Editing (SiteEdit) and page prototypes. But how would you configure or implement this type of requirement with the Content Manager Explorer?
I'd say there are a number of ways to achieve this:
1) Using the UI 'Page Types' - If the page you are using as the page type this should keep that same metadata. *I've not tested this!!! maybe you could confirm?
2) GUI extension - When a page template is selected a page metadata is selected based on the page template.
3) Event system. I'm not sure how well this would work as it would likely have to be on the creation of the page (checking if a default template is used) or on save if a template is used and a metadata schema isn't selected... but then if there is mandatory metadata etc etc.
4) The page template. This will set the metadata (on publish or preview) - or warn a user that a specific metadata should be set for this given page template.
Hope this helps.
Thanks
John
Very interesting question and I can see the benefits of this functionality for Editors. I don't have the answer for you. But AFAIK, even event system might not be relevant here since there are no events fired when you start creating a page unless we save the page. GUI Extension a possibility?
When you create a new item, this takes place via the GetNewitem() method in the API (or GetNewObject() in old money). I always thought there should have been separate events system hooks for this activity than for that of modifying an existing item. I once suggested this on ideas.sdltridion.com with regard to Components, however someone referred me to the OnSchemaGetInstanceDataPost event hook, and the discussion was over.
So in the case of a new component, the schema is automatically queried, and via the hook, you can interfere with the default data. So far so good, but I still believe that it would be generically useful to be able to modify the default data of any item type when first created.

Resources