Plone: dexterity content type default view template - plone

I created a new dexterity content type (named Report) using schema interface. Also I defined a custom view having a template report_view.pt.
I need some content from the original/default template to use in my custom template. Where can I find the code used for default view template of a dexterity content type?

https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/browser/configure.zcml
The default view for Dexterity content uses a WidgetsView and renders all widgets in display mode.
The standard view definition in browser/configure.zcml references the page template involved:
<browser:page
for="..interfaces.IDexterityContent"
name="view"
class=".view.DefaultView"
template="item.pt"
permission="zope2.View"
/>
Additionally, the plone.app.dexterity package overwrites the default view for containerish content types with:
<browser:page
for="plone.dexterity.interfaces.IDexterityContainer"
name="view"
class="plone.dexterity.browser.view.DefaultView"
template="container.pt"
permission="zope2.View"
/>

Related

How do I set Ghost Blog Custom Routes.yaml Collection Title / Meta Description in my custom template?

Using the Ghost blog routes.yaml file it is possible to use the collections block to create a custom collection made from some tag(s) and / or other data. You can also tell this collection to use a custom theme template see:
https://docs.ghost.org/tutorials/creating-content-collections/
https://docs.ghost.org/concepts/routing/#content-structure
For instance:
collections:
/example/:
permalink: /example/{slug}/
controller: channel
filter: tag:example-tag
template:
- example
All of the above works and my collection properly uses my new example theme file.
The issue is that unlike the tag page (for example-tag) my new custom collection does not have a readily documented way to work with the title etc.
It does not pull the title / meta description from the tag used to build the collection (which would be great for collections built from single tags). In an attempt to work around that I tried some {{#has}} statements but I can't figure out what context the custom route would fit into.
With the above example routes.yaml the title for the custom collection ends up as 'My Site Name (Page 1)' — and there is no Meta Description.
This issue also extends into the Open Graph data which lists an identical title as well as no description for the custom collection.
My guess is that it may be possible to use a data property attached to the routes.yaml file to achieve this (see: https://docs.ghost.org/concepts/routing/#data) but I haven't found a solution as of now.
While my initial attempts at googling for a solution came up empty, this is the best reference I have seen to the issue:
https://forum.ghost.org/t/dynamic-routing-page-post-data-context-in-default-hbs-nested-navigation-on-custom-collections/4204
https://github.com/TryGhost/Ghost/issues/10082
I found a way to work around.
You create a page called example in the Ghost Admin tool.
Customize routes (instead of collections) in the routes.yaml as following:
routes:
/example/:
controller: channel
filter: tag:example-tag
template: example
data: page.example
The page.example will use the metadata of this page in the Ghost.
This is possible only with workaround described in issue: https://github.com/TryGhost/Ghost/issues/10082
Generally do following:
create page Example (with slug example) and fill metadata title & description you want
in routes.yaml alter your collection definition /example/ add following:data: page.example to link your collection root with specified page
now in your template definition example.hbs you could use e.g. {{#page}} {{content}} {{/page}} tag to insert content from your page. You can do it also in default.hbs template which is included from your example.hbs. So replace: <title>{{meta_title}}</title> in default.hbs with following:
{{#unless page}}
<title>{{meta_title}}</title>
{{else}}
{{#page}}
<title>{{meta_title}}</title>
<meta name="description" content="{{meta_description}}"/>
{{/page}}
{{/unless}}
This will set specific title/description for your collection root pages in general way. It is possible to generate schema.org metadata in the similar way. Unfortunately Facebook and Twitter metadata is not so simple to do because, {{ghost_head}} tag in default.hbs already inserts site metadata to this page. Last note: besides {{meta_title}} and {{meta_description}} I suppose you could use all metadata fields defined here.
In default.hbs I added the following block:
{{{ block "metaTitle"}}}
and eg. in post.hbs I filled that block as follows:
{{!< default}}
<div class="content-area">
<main class="site-main">
{{#post}}
{{#contentFor "metaTitle"}}
<title>{{title}}</title>
{{/contentFor}}
...
For other pages like page.hbs, blog.hbs, author.hbs I did the same. I think that solution is more flexible because we have more control over title value.

Drupal theme naming conventions for comment types

I set up a Drupal page, which has two different content-types. One is "articles", one is "reviews".
In my theme folder, I set up two node templates for these content types. node.html.twig (standard template - articles), and node--reviews.html.twig.
When I add an article, node.html.twig is used, when I add a review, node--reviews.html.twig is used.
Now, it's possilbe to have different comments types too. I want to add the standard comment (comment.html.twig) for articles, and a custom comment type to reviews.
In Drupals theme naming documentation it's written, to name a template override like this: comment--node-type.html.twig. So I named my comment template comment--node-reviews.html.twig.
Is there anything else I have to do - apart from clearing the cache?
Because I simply cant get it to run.
Enable Twig Debugging, then you'll get template suggestions printed as HTML comments directly into the markup.
I did that and got the following output:
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'comment__field_my_comment_field__article' -->
<!-- FILE NAME SUGGESTIONS:
* comment--field-my-comment-field--article.html.twig
* comment--field-my-comment-field.html.twig
x comment.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/classy/templates/content/comment.html.twig' -->
So, the templates are supposed to be named like the following pattern:
comment--field-name-of-the-comment-field-in-the-content-type--content-type.html.twig
comment--field-name-of-the-comment-field-in-the-content-type.html.twig

Looping component links in an Embedded field

We have a "component A" , which has a multivalue field of type 'embedded field'.
The embedded field in turn has a multivalue field of type 'Component Link'.
This looks like:
Component A -> Embedded Shcema Fields -> Component Links
How to iterate and access the fields of 'Component Links'in dreamweaver?
Also the component field supports three different schemas and We want to check on these schema names in dreamweaver.
I found this post useful. But more details would be indeed great.
Have a look at these questions:
How to handle nested repeating regions in Dreamweaver TBBs in SDL Tridion 2011 SP1
Retrieving values of a linked component in Dreamweaver TBB - and making it SiteEditable
And this page from the Tridion practice cookbook:
http://code.google.com/p/tridion-practice/wiki/IteratingOverMultivalueEmbeddedFields
They cover the most common problems you may have with accessing fields in a DWT.
If these don't answer your question, update your question with:
the relevant XML fragment of your Component
the DWT fragment showing what you already tried
You can easily iterate through component link of multi value embedded field but there is no direct way to get component link values, you have to use either dwt extension, or .net tbb. There are some available on sdltridionworld.com.
I did this earlier with nested template. You may also try nested/sub template from your main dwt tbb based on schema of component link field component in the loop.
Also I would suggest to use razor templates.
You can iterate through the multi-value field paragraph in the embedded schema field paragraphs as follows:
<!-- TemplateBeginRepeat name="Component.Fields.paragraphs" -->
<h2>##Field.header## (##TemplateRepeatIndex##)</h2>
<!-- TemplateBeginRepeat name="Field.paragraph" -->
<p>##Field##</p>
<!-- TemplateEndRepeat -->
<!-- TemplateEndRepeat -->
As Vikas previously mentioned, repeating over the multivalued component link field of a multivalued embedded schema field is relatively simple. Your DWT code should follow this form:
<!-- TemplateBeginRepeat name="XML Name of Embedded Schema Fields" -->
<!-- TemplateBeginRepeat name="XML Name of multivalued Component Link field" -->
##Field## - Should write out the TCM ID of your linked component
<!-- TemplateEndRepeat -->
<!-- TemplateEndRepeat -->
You can not, however, access the fields or schema details of these components with "out of the box" Dreamweaver Templates.
You can:
install the Dreamweaver Get eXtension on your Content Manager server, which will allow you to retrieve fields of linked components (amongst other things) using the ##Get(...)## syntax
Use the "Get Linked Components" .Net TBB from the Generic SDL Tridion 2011 Template Building Blocks before your Dreamweaver Template, which will place the linked components into the templating package so that you can iterate over them directly
Write your own .Net TBB to handle your specific business logic related to these links and output html (not recommended) or a named package item, items or array of items that you can handle from your DWT.
Call another (nested) component template from your DWT with ##RenderComponentPresentation(Field, "tcm:x-xx-32")##
Any combination of the above
Please try using below code:
<!-- TemplateBeginRepeat name="paragraphs" -->
<!-- TemplateBeginRepeat name="Internal_Link" -->
<!-- TemplateBeginIf cond = "Internal_Link != ''" -->
<p> ##Component.ID## </p>
<!-- TemplateEndIf -->
<!-- TemplateEndRepeat -->
<!-- TemplateEndRepeat -->
To check for zeroth component you can use below code:
<!-- TemplateBeginRepeat name="paragraphs0.Internal_Link" -->

How to define default views in Plone

I have already a page template for the default view of a Plone site (main page).
How to define the default view of a folder? This default view should use a page template.
Try this:
navigate to the desired folder
add "/manage_propertiesForm" at the end of the url
in the resulting form add this property:
name: "layout"
type: "string"
value: the page template name without extension
Use the answers above if you want to set one of the default views (tabular, thumbnail, etc), but if you want to choose a particular content item for the default view of the folder, you can do it in the ZMI as suggested:
navigate to the desired folder
add "/manage_propertiesForm" at the end of the url
in the resulting form add this property:
name: "default_page"
type: "string"
value: the id of the content item
or do it programmatically in Python:
content_id = "Name of the Content Item"
folder.manage_addProperty('default_page', content_id, 'string')
Hope this helps!
Using the information and links send both by Giacomo Spettoli and by Mikko Ohtamaa, another guy from my work team was able to find a solution for our case:
do as indicated by Giacomo (navigate to desired folder, etc.)
include a new directive in the configure.zcml file (this was found by on of my team mate Mr. Mariano):
<browser:page for="OFS.interfaces.IFolder" name=<name of the page template file> class=<name of the class used by the above template file> permission="zope2.View" />
Thanks to Giacomo and to Mikko; their answers helped us solve this issue.

How to set the title of a browser page in Plone

I'm trying to find how I can set the title of a browser:page. The main goal is to have it in the drop down "display" menu on my content type.
I have take a look in the code of CMFDynamicViewFTI. The only example there use browser:view and I don't know what it is, I have never seen browser:view. Is this the solution ? Does browser:view support customerize (The browser:view directive doesn't support the template parameter in zcml).
So is there anyway to set the title (as listed in the "display" menu) of a browser:page?
A browser:page is essentially just a browser:view directive with added support for templates. You can set a title using the zcml directive, just as you can for browser:view.
To set a title for the display menu, add the menu and title attributes to the browser:page directive:
menu="plone_displayviews"
title="title goes here"
You may also need to explicitly include the ZCML for plone.app.contentmenu first to make sure that the plone_displayviews menu is defined:
<include package="plone.app.contentmenu" />

Resources