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
zopyx
(Andreas Jung)
February 14, 2024, 8:41am
2
You need to configure the proper view name as default_view
in your FTI XML file (profiles/default/types/YourType.xml)
Hi all,
I have some folderish dexterity content where the default view was changed
e.g. /profiles/types/my_custom_type.xml contains
<property name="default_view">my_new_and_improved_view</property>
<property name="view_methods">
<element value="my_new_and_improved_view" />
<element value="my_custom_view" /> <!-- obsolete -->
<element value="view" />
</property>
Updating the default_view property to my new template and registering it zcml generally causes the new view to be …
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>
zopyx
(Andreas Jung)
February 15, 2024, 5:37am
4
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 ...
rafaelbco
(Rafael Oliveira)
February 15, 2024, 10:06pm
6
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
zopyx
(Andreas Jung)
February 16, 2024, 7:09am
9
That's what I/we always do. I can not recall having named any default view of my content-types view
...no idea why perhaps because of this reason
rafaelbco
(Rafael Oliveira)
February 21, 2024, 3:43am
10
I always name the default view of a content type view
and never had any issues