Link to custom view

I have created a custom dexterity type, and a custom "view" following the example from:

[Custom views — Plone Documentation v5.2](Custom views — Plone Documentation v5.2)

After saving my dexterity object, i will be forwarded to my custom view with the adress .../[title]/view and everything looks fine.

Now Plone itself is storing this links to my dexterity objects with the path .../[title] and by clicking on them i will be forwarded to a broken page.
If i add the codeword "/view" to the broken url manually i can see my view of my custom dexterity object and everything looks fine again.

How can i tell plone to create the correct link to the url .../[title]/view after saving the dexterity object?

1 Like

You need to configure the proper view name as default_view in your FTI XML file (profiles/default/types/YourType.xml)

Hello zopyx

do you have an example how to do this?
is this not already done in the row default view = view ?

<!-- View information -->
  <property name="add_view_expr">string:${folder_url}/++add++myDexterity</property>
  <property name="default_view">view</property>
  <property name="default_view_fallback">False</property>
  <property name="immediate_view">view</property>
  <property name="view_methods">
    <element value="view"/> 
  </property>

As said: change view to the name of your custom view.
And note that the XML file is only used when you install your add-on.
In doubt: check the configuration of your content type in portal_types through the ZMI.

The name of my custom view is "view", like in the tutorial for Custom views

The view itself is defined in the conficure.zcml file in the browser folder.

<browser:page
      name="view"
	  for="myDexterity.ImyDexterity"
      class=".myDexterity_view.myDexterity_View"
      template="myDexterity.pt"
      permission="zope2.View"
        />

I'll try to check the configuration from my content type in portal_types the next days ...

Please give more details about this "broken page". What is in it? Are there errors in the console/log ?

There are no errors in the console Log. The page says this site does not exist

I solved the issue by just renaming my custom view from "view" to "ansicht"

The conficure file in browser/ looks like

	<browser:page
      name="ansicht"
	  for="myDexterity.ImyDexterity"
      class=".myDexterity_view.myDexterity_View"
      template="myDexterity.pt"
      permission="zope2.View"
    />

and the FTI XML file in (profiles/default/types/YourType.xml) looks like


  <!-- View information -->
  <property name="add_view_expr">string:${folder_url}/++add++myDexterity</property>
  <property name="default_view">ansicht</property>
  <property name="default_view_fallback">False</property>
  <property name="immediate_view">ansicht</property>
  <property name="view_methods" purge="false">
    <element value="ansicht"/> 
  </property>

  <!-- Method aliases -->
  <alias
      from="(Default)"
      to="(dynamic view)"
  />
  <alias
      from="edit"
      to="@@edit"
  />
  <alias
      from="sharing"
      to="@@sharing"
  />
  <alias
      from="view"
      to="(selected layout)"
  />

Now the link to the custom view is working and the object will be called by the url
.../[title]
instead of .../[title]/view or .../[title]/ansicht

That's what I/we always do. I can not recall having named any default view of my content-types view...no idea why :slight_smile: perhaps because of this reason

I always name the default view of a content type view and never had any issues :slightly_smiling_face: