<emit source="category-document"></emit>
Provided by module: CMS: Category
This emit plugin
returns paths to files in SiteBuilder with one or more categories.
The resulting list of paths can be sorted using the standard emit sort
attribute, on any of the entities publish, title, path or combinations of
these.
Be aware that there may be performance issues using the
AND operator together with 1) a big category database table, and 2) multiple
node id:s in the nodes="" attribute. In those cases it is recommended that
some form of caching is used. The typical example would be when the tag is
used to display the latest pages in the news category on a site start page. In
this case it is a very good idea to use a cache with a time out.
Sorting on publish and path will be done in SQL and should therefore
give good performance. Sorting on title will be done in Pike and
all rows must be returned from the database regardless of maxrows/skiprows.
The sorting performance will therefore be based on the total number of rows
mathing the search criterias. Note that the maxrows/skiprows attributes will
still function as expected, only that technically they are used in Pike instead
of in the SQL query.
Ex. 1:
List a maximum of 10 paths categorized as
'News' and 'Important' (node id '1205396296-0' and '1205396296-1' respectively)
, allow only paths in '/news/' and '/misc/' and cache the result in 5 minutes:
<cache minutes='5'>
<emit source='category-document'
nodes='categories.xml!1205396296-0,categories.xml!1205396296-1'
operator='and'
path='/news/*,/misc/*'
maxrows='10'
sort='-publish'>
<div>&_.path; <i>(&_.publish;)</i></div>
</emit>
</cache> |
Ex. 2:
List paths 101 - 120 categorized as 'Car' or
'Boat' (node id '1205396296-2' in /categories1.xml or '1205304615-0' in
/categories2.xml respectively), but exclude all paths in '/new/' and
'/newest/', sort on title ascending and publish descending:
<nocache>
<emit source='category-document'
nodes='categories1.xml!1205396296-2,categories2.xml!1205304615-0'
operator='or'
not-path='/new/*,/newest/*'
skiprows='100'
maxrows='20'
sort='title,-publish'>
<div>&_.path; <i>(&_.publish;)</i></div>
</emit>
</nocache> |
Attributes
- operator="{and, or}" (and)
-
and: list files
categorized with all node id:s.
or: list files categorized with at
least one of the node id:s.
- nodes="string"
-
Comma-separated list of
category node id:s to list paths for.
- path="string"
-
Comma-separated list of path globs to
include in the list of paths.
- not-path="string"
-
Comma-separated list of
path globs to exclude from the list of paths.
- invisible
-
Include invisible files in the list of paths.
-
&_.path; (provided by CMS: Category)
File path.
-
&_.publish; (provided by CMS: Category)
Publish date. The date the file was first committed or the external visibility start date if set. Note that this entity may give incorrect results on frontend servers unless the Site News module is active.
-
&_.title; (provided by CMS: Category)
The title of the file. Note that this attribute is fetched dynamically and not stored in the database.