Ticket #433 (new defect)

Opened 15 years ago

Last modified 14 years ago

widget_id is set even if the "Depends on value display widget" is not selected

Reported by: jmorliaguet Owned by: fguillaume
Priority: P2 Milestone: CPS 3.5.7
Component: CPSDocument Version: unspecified
Severity: normal Keywords:
Cc:

Description (last modified by fguillaume) (diff)

in layout_lib/default_view the widget's id is always written in the <div> tag even if the "Depends on value display widget" option is not selected.

<div tal:define="dm options/datastructure/getDataModel;"

tal:attributes="class python:test(widget.depends_on_field_id == or ((not

widget.display_if_depends_equals) (dm[widget.depends_on_field_id] == widget.depends_on_field_value)), widget.css_class or 'visible', 'hidden');

id python:widget.widget_group_id or widget.getHtmlWidgetId()+'_widget';">

a tal:omit-tag="..." is probably missing

Change History

comment:1 Changed 15 years ago by fguillaume

  • Cc edegoute@… added
  • Summary changed from widget_id is set even if the "Depends on value display widget" is not selected to widget_id is set even if the "Depends on value display widget" is not selected

comment:2 Changed 15 years ago by edegoute

It was volonteer. Every widget have an id to be catch in future javascript stuff. It must be here even if a widget depends on nothing, but a more complex condition that depends_on use case cannot handle.

comment:3 Changed 15 years ago by jmorliaguet

OK I understand. The assumption is that only one CPSDocument is displayed per page. The only problem is that CSS IDs are supposed to be unique on a same page and nothing guarantees that the same widget will not be used several times. So ideally the document id should be prepended as in 'docid_widgetportlet_widget'

At least in CPSPortlet with the Document Portlet I can see:

<div class="visible" id="widgetportlet_widget">

several times in the same page --- which will defeat javascript.

comment:4 Changed 15 years ago by edegoute

Normally widget.getHtmlWidgetId give an uniq id for a widget in a render mode.

Why does it fail ?

Is there something specific for widget in CPSPortlets ?

comment:5 Changed 15 years ago by jmorliaguet

It fails with the Document Portlet that renders the current document by calling a doc.render(). All portlets use their own 'layout_portlet_' without the widget id code but the Document portlet does a second rendering with layout_default_ (or with the template associated):

.... getContent = getattr(context_obj.aq_explicit, 'getContent', None) if getContent is not None:

doc = getContent() # try to render the specified layout try:

rendered = doc.render(proxy=context_obj, layout_id=layout_id)

except ValueError?:

rendered = doc.render(proxy=context_obj)

so it occurs because widget ids are unique per layout and per document but there can be several rendered documents in a same page for instance if the front page displays a collection of documents not as links to the documents but as a preview of the documents (as on the front page of a newspaper). Then several documents are rendered simultaneously.

another plan is to allow the Content Portlet to render the results of catalog queries instead of simply showing links to them.

comment:6 Changed 15 years ago by edegoute

Ok, I see. It's more complicated that I have hoped.

We can prefix html id with layout id and portlet id. I haven't take a look to CPSPortlets, Can a widget know by what portlet it be render?

comment:7 Changed 15 years ago by jmorliaguet

it is one of limitation that I see right now: that a widget has no knowledge of the layout or of document above it, so treating this kind of logic on a widget-level is rather difficult. I am not even sure that it will work with multi-layout documents.

I am going to use widget ids to do javascript image rotation, and there can be many images used on a same page, but prepending the document / portlet id as in:

'docid_widget_widgetid' should be enough since document ids are unique.

this can be done in the layout renderer, but not inside Widget.py.

comment:8 Changed 15 years ago by fguillaume

docids are unique but several documents can have the same docid but be in different revisions (versions).

comment:9 Changed 15 years ago by jmorliaguet

yes indeed, it should be possible to show two versions of a same document side by side on a same page, so the revision id should be included too if there is more than one revision...

comment:10 Changed 14 years ago by fguillaume

  • Description modified (diff)
  • Milestone changed from unspecified to CPS 3.5.0
Note: See TracTickets for help on using tickets.