[Product-Developers] Re: Calender widget in custom view.

Dorneles Treméa dorneles at x3ng.com.br
Fri Feb 29 20:13:36 UTC 2008


Hey swank,

> Is it possible to use any of the widgets of archetypes in a custom view?

in theory yes, you just need to supply the expected variables... :-)

> My view has some form inputs that let a user do some searching and
> filtering on the fields of a certain content type.  One of the fields of
> this content type is a date field, and I would like to use a calenderwidget
> to enable the user to choose the starting and ending date for the filtering. 
> I don't want to use formlib and autogenerate a form because I want the
> widget to appear in a table that I created as part of my view.

The calender widget macro, in truth, is not from Archetypes, but
from Plone itself.

This snippet allows you to use it anywhere:

    <div tal:define="inputname  string:your_field_name;
                     formname   string:edit_form;
                     formvalue  request/your_field_name | nothing;
                     fieldvalue here/your_field_name | python:'';
                     inputvalue python:formvalue and formvalue or
fieldvalue">
        <div tal:content="error">Validation error output</div>
        <div
metal:use-macro="here/calendar_macros/macros/calendarDatePickerBox">
            Gets the calendar code.
        </div>
    </div>

Of course, don't forget to add the necessary CSS/JS resources...

You can also set show_hm/show_ymd/... and all other parameters used
by the calendar, take a look at the Archetypes calendar widget:

Archetypes/skins/archetypes/widgets/calendar.pt

HTH,

-- 

Dorneles Treméa
X3ng Web Technology
http://nosleepforyou.blogspot.com





More information about the Product-Developers mailing list