collective.nextprev
The collective.nextprev package extends Plone’s next/previous navigation for folders to collections (AKA topics or smart folders). If a listing view is visited for a collection which has next/previous navigation enabled, a cookie is set to remember the collection used and any relevant query terms. When a content item in the result set is visited, this cookie will be used to determine the next and previous item links.
Start with the a folder, some content, and a collection.
>>> folder <ATFolder at /plone/Members/test_user_1_> >>> folder.contentValues() [<ATTopic at /plone/Members/test_user_1_/foo-topic-title>, <ATNewsItem at /plone/Members/test_user_1_/foo-news-item-title>, <ATDocument at /plone/Members/test_user_1_/bar-page-title>, <ATNewsItem at /plone/Members/test_user_1_/baz-news-item-title>, <ATNewsItem at /plone/Members/test_user_1_/qux-baz-news-item-title>]
One item is a page and so doesn’t show up in the collection listing.
>>> folder['foo-topic-title'].queryCatalog(full_objects=True) [<ATNewsItem at /plone/Members/test_user_1_/foo-news-item-title>, <ATNewsItem at /plone/Members/test_user_1_/baz-news-item-title>, <ATNewsItem at /plone/Members/test_user_1_/qux-baz-news-item-title>, <ATNewsItem at /plone/news/blah-news-item-title>]
Next/previous navigation is enabled for the folder but not for the topic.
>>> folder.getNextPreviousEnabled() True >>> folder['foo-topic-title'].getNextPreviousEnabled() False
Open a browser at the folder.
>>> from Products.Five.testbrowser import Browser >>> browser = Browser() >>> browser.handleErrors = False >>> browser.open(folder.absolute_url())
Visit one of the news items, the next link points to the next item in the folder but not the next item in the collection.
>>> browser.getLink('Foo News Item Title').click()
>>> browser.getLink('Next')
<Link text='Next: Bar Page Title Right arrow[IMG]'
url='http://nohost/plone/Members/test_user_1_/bar-page-title'>
Open a browser, log in as some one who can enable the next/previous navigation for the collection, and do so.
>>> from Products.PloneTestCase import ptc
>>> owner_browser = Browser()
>>> owner_browser.handleErrors = False
>>> owner_browser.open(folder['foo-topic-title'].absolute_url())
>>> owner_browser.getLink('Log in').click()
>>> owner_browser.getControl(
... 'Login Name').value = ptc.portal_owner
>>> owner_browser.getControl(
... 'Password').value = ptc.default_password
>>> owner_browser.getControl('Log in').click()
>>> owner_browser.getLink('Edit').click()
>>> owner_browser.getControl(
... 'Enable next previous navigation').selected = True
>>> owner_browser.getControl('Save').click()
>>> print owner_browser.contents
<...
...Changes saved...
Now that next/previous navigation is enabled, visiting the collection listing will set the cookie.
>>> browser.open(folder.absolute_url()) >>> browser.headers['set-cookie'] 'nextprev.collection="/plone/Members/test_user_1_/foo-topic-title"; Path=/, nextprev.form="test="; Path=/'
Visit an item again and now the next link will be the next item in the collection.
>>> browser.getLink('Foo News Item Title').click()
>>> browser.getLink('Next')
<Link text='Next: Baz News Item Title Right arrow[IMG]'
url='http://nohost/plone/Members/test_user_1_/baz-news-item-title'>
If the folder listing is visited again, the next/previous links reflect the folder contents instead of the collection results.
>>> browser.open(folder.absolute_url()+'/folder_listing') >>> browser.headers['set-cookie'] 'nextprev.collection="deleted"; Path=/; Expires=Wed, 31-Dec-97 23:59:59 GMT; Max-Age=0, nextprev.form="deleted"; Path=/; Expires=Wed, 31-Dec-97 23:59:59 GMT; Max-Age=0'>>> browser.getLink('Foo News Item Title').click() >>> browser.getLink('Next') <Link text='Next: Bar Page Title Right arrow[IMG]' url='http://nohost/plone/Members/test_user_1_/bar-page-title'>
Search criteria submitted in the request are also preserved in the cookies so that the next/previous links will reflect the correct result sets.
>>> browser.open(folder.absolute_url()+'?SearchableText=baz')
>>> browser.getLink('Baz News Item Title').click()
>>> browser.getLink('Previous')
Traceback (most recent call last):
LinkNotFoundError
>>> browser.getLink('Next')
<Link text='Next: Qux Baz News Item Title Right arrow[IMG]'
url='http://nohost/plone/Members/test_user_1_/qux-baz-news-item-title'>
Items outside the current set can be safely viewed.
>>> browser.open(folder['foo-news-item-title'].absolute_url())
>>> browser.getLink('Previous')
Traceback (most recent call last):
LinkNotFoundError
>>> browser.getLink('Next')
Traceback (most recent call last):
LinkNotFoundError
A topic which is contained in a folder but is not in the current set can also be safely viewed.
>>> browser.open(folder.absolute_url())
>>> browser.getLink('Previous')
Traceback (most recent call last):
LinkNotFoundError
>>> browser.getLink('Next')
Traceback (most recent call last):
LinkNotFoundError
Though next/previous navigation is not available on large folders, the next/previous links will still be rendered when a collection lists items inside a large folder.
>>> browser.open(folder.absolute_url())
>>> browser.getLink('Blah News Item Title').click()
>>> browser.getLink('Previous')
<Link text='Left arrow[IMG] Previous: Qux Baz News Item Title'
url='http://nohost/plone/Members/test_user_1_/qux-baz-news-item-title'>
>>> browser.getLink('Next')
Traceback (most recent call last):
LinkNotFoundError
Changelog
0.2 - 2009-02-10
Fix a bug so that items contained in large folders will still have next/prev links if the cookie is set
Refactor the various views and adapters
0.1 - 2009-02-05
Initial release
Metadata
Release files for collective.nextprev 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| collective.nextprev-0.2.tar.gz | 7.1 kB | Without provenance | Details |
Release files / collective.nextprev-0.2.tar.gz
| Download URL | collective.nextprev-0.2.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80134ce2d4b88e2bb42975eece26b8c37b4c4989c8ceaeca7ced2c29d97d7147
|
|
BLAKE2b-256 checksum How to use checksums |
0ef0d3e1727679875bb4aa4e2e64574bcbc8194332aa3688ad7dd2adcb121d2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for collective.nextprev 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.