Re: Bulk excludeFromNav

classic Classic list List threaded Threaded
6 messages Options
Cyrille Bonnet Cyrille Bonnet
Reply | Threaded
Open this post in threaded view
|

Re: Bulk excludeFromNav

Hi Ian,

which version of Plone are you looking at?

The navigation has changed a lot in Plone 2.1 and should be much easier
to customize.

The default behaviour, though, is to exclude certain content types. So,
you would have to create a cusotm content type "HiddenDocument" and
exclude this type from the nav (rather than using a check box).

Cheers

Cyrille

Ian Brockbank wrote:

> Hi All,
>
> I've been playing around with Plone for the past year or so and I'm now in
> the process of setting up a public site.  What a great product!  However, I
> have a couple of questions I haven't been able to answer for myself either
> by searching in the code or the mailing lists.  (I'm sure the answers are
> there, but I'm not yet sufficiently conversent with python to see them).
> I'll send them in separate emails to keep the discussion threads clean.
>
> My second question is how can I hide multiple items from the navigation tree
> with a single operation?  I've found the excludeFromNav property, but I
> really don't understand how to access this from non-Archetypes code.  I
> found the "How to access Archetypes fields using Page Templates" on
> http://plone.org/documentation/archetypes/ArchetypesDeveloperGuide/index_htm
> l but I'm obviously missing something.
>
> I tried to modify content_status_history.cpt to add an "exclude from
> navigation" check box as follows:
>
> ------------------------------
>           <div class="field formSingleCheckbox">
>           <div tal:define="isExcluded python:getattr(here,
> here.Schema()['excludeFromNav'].accessor)">
>
>             <label for="exclude_from_nav"
> i18n:translate="label_exclude_from_nav">
>               Exclude from navigation
>             </label>
>
>             <div class="formHelp"
>                  i18n:translate="help_exclude_from_nav">
>               If selected, this item will not appear in the navigation tree.
>             </div>
>
>             <input type="checkbox"
>                    class="formElement"
>                    id="exclude_from_nav"
>                    name="exclude_from_nav"
>                    tabindex=""
>                    tal:attributes="tabindex tabindex/next;
>                       checked isExcluded"
>                    />
>
>           </div>
> ------------------------------
>
> but I get the following error:
>
> ------------------------------
> Site error
>
> This site encountered an error trying to fulfill your request. The errors
> were:
> Error Type
> AttributeError
> Error Value
> Schema
> Request made at
> 2005/10/15 16:00:26.315 GMT+1
> ------------------------------
>
> If I remove the isExcluded lines, I get a form with the checkbox, though it
> doesn't pick up the current value of that field.
>
> Of course, that's just the first step - having set that check box, how do I
> then put it back?  I assume it's something to do with the mutator.
>
> Alternatively, I thought of setting up a couple of actions to appear at the
> bottom of the folder contents page (include and exclude), but again, I
> really don't understand how to modify this field from outside the
> archetypes-generated forms.
>
> Any pointers greatly appreciated.
>
> I'm using Plone 2.1 with Zope 2.7.7.
>
> Thanks,
>
> Ian Brockbank
> Edinburgh, Scotland
> [hidden email]
> http://www.scottishdance.net/
>  
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Cyrille Bonnet Cyrille Bonnet
Reply | Threaded
Open this post in threaded view
|

Re: Bulk excludeFromNav

Hi Ian,

Pls stay on the mailing list for reference.

I haven't looked at Plone 2.1 yet, so don't know how the excludeNav
works there.

But to answer your more specific question: why do you want the check box
outside of the archetypes-generated forms? Is it a business need? Or is
it because it doesn't appear there at the moment?

For the latter, something can be done, probably. Send the content type
definition.

For the former, not quite sure how to do it. I've never had to do it.
You will need to look into how Plone handles forms (cpt, cpy, etc.)

In general, Plone users are encouraged to use archetypes-generated
forms, as it is less error prone, easier to maintain, etc.

Cheers

Cyrille




Hi Cyrille,

I'm using Plone 2.1 and Zope 2.7.7.  I have found that Plone 2.1 adds
the "excludeFromNav" property, which you can set on an individual item
via the properties pane.  What I want to do is control this in bulk.
However, this has been added via Archetypes, and I really haven't
managed to work out how to get the current value of an archetypes field
from (e.g.) content_status_history.cpt, and how to update it in (e.g.)
content_status_modify.cpy.

My code attempting to get the current value of the attribute (based on the
ArchetypesDeveloperGuide) is

<div tal:define="isExcluded python:getattr(here,
here.Schema()['excludeFromNav'].accessor)">
...
</div>

but, as I say further down the mail, I get an error when I try that.
Any ideas what I'm doing wrong?  Also, how do I then change the value?
Is it something like this?

python:setattr(here, here.Schema()['excludeFromNav'].mutator( newVal )

advTHANKSance,

Ian Brockbank
Edinburgh, Scotland
[hidden email]
http://www.scottishdance.net/




 > -----Original Message-----
 > From: [hidden email]
 > [mailto:[hidden email]] On Behalf Of Cyrille
 > Bonnet
 > Sent: 16 October 2005 20:51
 > To: [hidden email]
 > Subject: [Plone-users] Re: Bulk excludeFromNav
 >
 > Hi Ian,
 >
 > which version of Plone are you looking at?
 >
 > The navigation has changed a lot in Plone 2.1 and should be much
 > easier to customize.
 >
 > The default behaviour, though, is to exclude certain content types.
 > So, you would have to create a cusotm content type "HiddenDocument"
 > and exclude this type from the nav (rather than using a check box).
 >
 > Cheers
 >
 > Cyrille
 >
 > Ian Brockbank wrote:
 > > Hi All,
 > >
 > > I've been playing around with Plone for the past year or so
 > and I'm now in
 > > the process of setting up a public site.  What a great
 > product!  However, I
 > > have a couple of questions I haven't been able to answer
 > for myself either
 > > by searching in the code or the mailing lists.  (I'm sure
 > the answers are
 > > there, but I'm not yet sufficiently conversent with python
 > to see them).
 > > I'll send them in separate emails to keep the discussion
 > threads clean.
 > >
 > > My second question is how can I hide multiple items from
 > the navigation tree
 > > with a single operation?  I've found the excludeFromNav
 > property, but I
 > > really don't understand how to access this from
 > non-Archetypes code.  I
 > > found the "How to access Archetypes fields using Page Templates" on
 > >
 > http://plone.org/documentation/archetypes/ArchetypesDeveloperG
 > uide/index_htm
 > > l but I'm obviously missing something.
 > >
 > > I tried to modify content_status_history.cpt to add an "exclude from
 > > navigation" check box as follows:
 > >
 > > ------------------------------
 > >           <div class="field formSingleCheckbox">
 > >           <div tal:define="isExcluded python:getattr(here,
 > > here.Schema()['excludeFromNav'].accessor)">
 > >
 > >             <label for="exclude_from_nav"
 > > i18n:translate="label_exclude_from_nav">
 > >               Exclude from navigation
 > >             </label>
 > >
 > >             <div class="formHelp"
 > >                  i18n:translate="help_exclude_from_nav">
 > >               If selected, this item will not appear in the
 > navigation tree.
 > >             </div>
 > >
 > >             <input type="checkbox"
 > >                    class="formElement"
 > >                    id="exclude_from_nav"
 > >                    name="exclude_from_nav"
 > >                    tabindex=""
 > >                    tal:attributes="tabindex tabindex/next;
 > >                       checked isExcluded"
 > >                    />
 > >
 > >           </div>
 > > ------------------------------
 > >
 > > but I get the following error:
 > >
 > > ------------------------------
 > > Site error
 > >
 > > This site encountered an error trying to fulfill your
 > request. The errors
 > > were:
 > > Error Type
 > > AttributeError
 > > Error Value
 > > Schema
 > > Request made at
 > > 2005/10/15 16:00:26.315 GMT+1
 > > ------------------------------
 > >
 > > If I remove the isExcluded lines, I get a form with the
 > checkbox, though it
 > > doesn't pick up the current value of that field.
 > >
 > > Of course, that's just the first step - having set that
 > check box, how do I
 > > then put it back?  I assume it's something to do with the mutator.
 > >
 > > Alternatively, I thought of setting up a couple of actions
 > to appear at the
 > > bottom of the folder contents page (include and exclude),
 > but again, I
 > > really don't understand how to modify this field from outside the
 > > archetypes-generated forms.
 > >
 > > Any pointers greatly appreciated.
 > >
 > > I'm using Plone 2.1 with Zope 2.7.7.
 > >
 > > Thanks,
 > >
 > > Ian Brockbank
 > > Edinburgh, Scotland
 > > [hidden email]
 > > http://www.scottishdance.net/
 > >
 > >
 > >
 > >
 > >
 > >
 > >
 > > -------------------------------------------------------
 > > This SF.Net email is sponsored by:
 > > Power Architecture Resource Center: Free content,
 > downloads, discussions,
 > > and more. http://solutions.newsforge.com/ibmarch.tmpl
 >
 >
 >
 > -------------------------------------------------------
 > This SF.Net email is sponsored by:
 > Power Architecture Resource Center: Free content, downloads,
 > discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
 > _______________________________________________
 > Plone-users mailing list
 > [hidden email]
 > https://lists.sourceforge.net/lists/listinfo/plone-users
 >



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Ian Brockbank-2 Ian Brockbank-2
Reply | Threaded
Open this post in threaded view
|

RE: Re: Bulk excludeFromNav

Hi Cyrille,

> I haven't looked at Plone 2.1 yet, so don't know how the excludeNav
> works there.

excludeFromNav is defined in ATContentTypes/content/schemata.py:

-------------
# for ATContentTypes we want to have the description in the edit view
# just like CMF
ATContentTypeSchema = BaseSchema.copy() + MetadataSchema((
    BooleanField('excludeFromNav',
    default = True,
        required = False,
        languageIndependent = True,
        schemata = 'metadata', # moved to 'default' for folders
        widget = BooleanWidget(
            description="If selected, this item will not appear in the
navigation tree",
            description_msgid = "help_exclude_from_nav",
            label = "Exclude from navigation",
            label_msgid = "label_exclude_from_nav",
            i18n_domain = "plone",
            visible={'view' : 'hidden',
                     'edit' : 'visible'},
            ),
        ),
    ),)
--------------

> But to answer your more specific question: why do you want
> the check box
> outside of the archetypes-generated forms? Is it a business
> need? Or is
> it because it doesn't appear there at the moment?

I'm needing to exclude a whole load of items, and it's a pain to do each one
individually, so I'd like to be able to select multiple items in a folder
contents view and exclude or include them all in a single operation.  The
change state form seemed a reasonable place to put it, given what else is
there.  Another option would be if I could create a custom action with that
effect.

> For the latter, something can be done, probably. Send the
> content type
> definition.
>
> For the former, not quite sure how to do it. I've never had to do it.
> You will need to look into how Plone handles forms (cpt, cpy, etc.)
>
> In general, Plone users are encouraged to use archetypes-generated
> forms, as it is less error prone, easier to maintain, etc.

I can understand that...so are there any archetypes-generated forms which
act on multiple items simuiltaneously?

Thanks for taking the time over this,

Ian Brockbank
Edinburgh, Scotland
[hidden email]
http://www.scottishdance.net/



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Cyrille Bonnet Cyrille Bonnet
Reply | Threaded
Open this post in threaded view
|

Re: Bulk excludeFromNav

Hi Ian,

All right, I understand better now.

So, you have a custom folderish content type, for which you want to
"exclude from nav" all sub content. Is that right?

Well, I'd see two ways to do that:

1) create custom sub content type, e.g. mySubContentType, and allow only
this type in your custom folderish content type (this is really easy to
do with ArchGenXML). Then exclude mySubContentType from the nav.

2) customize method post_validate on your custom folderish content type
to "exclude from nav" all sub content. But that's assuming that all sub
content exists on folder creation.

Cheers

Cyrille Bonnet
Technical Architect
3months.com
Web: www.3months.com
Tel: + 64 4 381 2884
Fax: + 64 4 381 2894
Cell: 021 446 048

Ian Brockbank wrote:

> Hi Cyrille,
>
>
>>I haven't looked at Plone 2.1 yet, so don't know how the excludeNav
>>works there.
>
>
> excludeFromNav is defined in ATContentTypes/content/schemata.py:
>
> -------------
> # for ATContentTypes we want to have the description in the edit view
> # just like CMF
> ATContentTypeSchema = BaseSchema.copy() + MetadataSchema((
>     BooleanField('excludeFromNav',
>     default = True,
>         required = False,
>         languageIndependent = True,
>         schemata = 'metadata', # moved to 'default' for folders
>         widget = BooleanWidget(
>             description="If selected, this item will not appear in the
> navigation tree",
>             description_msgid = "help_exclude_from_nav",
>             label = "Exclude from navigation",
>             label_msgid = "label_exclude_from_nav",
>             i18n_domain = "plone",
>             visible={'view' : 'hidden',
>                      'edit' : 'visible'},
>             ),
>         ),
>     ),)
> --------------
>
>
>>But to answer your more specific question: why do you want
>>the check box
>>outside of the archetypes-generated forms? Is it a business
>>need? Or is
>>it because it doesn't appear there at the moment?
>
>
> I'm needing to exclude a whole load of items, and it's a pain to do each one
> individually, so I'd like to be able to select multiple items in a folder
> contents view and exclude or include them all in a single operation.  The
> change state form seemed a reasonable place to put it, given what else is
> there.  Another option would be if I could create a custom action with that
> effect.
>
>
>>For the latter, something can be done, probably. Send the
>>content type
>>definition.
>>
>>For the former, not quite sure how to do it. I've never had to do it.
>>You will need to look into how Plone handles forms (cpt, cpy, etc.)
>>
>>In general, Plone users are encouraged to use archetypes-generated
>>forms, as it is less error prone, easier to maintain, etc.
>
>
> I can understand that...so are there any archetypes-generated forms which
> act on multiple items simuiltaneously?
>
> Thanks for taking the time over this,
>
> Ian Brockbank
> Edinburgh, Scotland
> [hidden email]
> http://www.scottishdance.net/
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Ian Brockbank-2 Ian Brockbank-2
Reply | Threaded
Open this post in threaded view
|

RE: Re: Bulk excludeFromNav

In reply to this post by Cyrille Bonnet
Hi Cyrille,

Sorry, I'm afraid it's not that easy.

> All right, I understand better now.
>
> So, you have a custom folderish content type, for which you
> want to "exclude from nav" all sub content. Is that right?

I'm porting an existing site to Plone.  I have a folder with about 180
files.  I only want a few of these to appear on the navigation tree
(although the folder and files are completely normal).  The 2.1 navigation
tree respects this new attribute of "excludeFromNav", which you can set from
an item's properties page.  Unless I can find a way of doing it in bulk, I'm
going to have to go to each of those 170 items I want hidden and set this
value individually.

Hence why I thought I could extend the "Change State" action or add a custom
action which would set this property for a bunch of items simultaneously.

Any suggestions?  Or should I just bite the bullet and go through all those
items individually?

Thanks,

Ian Brockbank
Edinburgh, Scotland
[hidden email]
http://www.scottishdance.net/



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Cyrille Bonnet Cyrille Bonnet
Reply | Threaded
Open this post in threaded view
|

Re: Bulk excludeFromNav

Hmmm,

so I suppose you import the content from ZEXP?

If so, I'd change the default value for excluseFrom Nav to True, then
import the content. Finally, change 10 documents to True.

You can change the default back to False when you're done.

Cheers

Cyrille

Ian Brockbank wrote:

> Hi Cyrille,
>
> Sorry, I'm afraid it's not that easy.
>
>
>>All right, I understand better now.
>>
>>So, you have a custom folderish content type, for which you
>>want to "exclude from nav" all sub content. Is that right?
>
>
> I'm porting an existing site to Plone.  I have a folder with about 180
> files.  I only want a few of these to appear on the navigation tree
> (although the folder and files are completely normal).  The 2.1 navigation
> tree respects this new attribute of "excludeFromNav", which you can set from
> an item's properties page.  Unless I can find a way of doing it in bulk, I'm
> going to have to go to each of those 170 items I want hidden and set this
> value individually.
>
> Hence why I thought I could extend the "Change State" action or add a custom
> action which would set this property for a bunch of items simultaneously.
>
> Any suggestions?  Or should I just bite the bullet and go through all those
> items individually?
>
> Thanks,
>
> Ian Brockbank
> Edinburgh, Scotland
> [hidden email]
> http://www.scottishdance.net/
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users