value=args.field# type: list # since model is 'strings' type
fortaginvalue:
yieldtag,{'tags_in_page':value}
yieldtag
```
This example is roughly equivalent to the config example above – the parameters of the `groupby.add_watcher` function correspond to the same config parameters.
@@ -183,9 +189,8 @@ field = args.record[k.fieldKey].blocks[k.flowIndex].get(k.flowKey)
```
The callback body **can** produce groupings but does not have to.
If you choose to produce an entry, you have to `yield`a string or tuple pair `(group, extra-info)`.
If you choose to produce an entry, you have to `yield`the group name (string).
`group` is slugified (see above) and then used to combine & cluster pages.
The `extra-info` (optional) is passed through to your template file.
You can yield more than one entry per source.
Or ignore pages if you don't yield anything.
@@ -194,9 +199,8 @@ The template file can access and display the `extra-info`:
```jinja2
<p>Custom field date: {{this.date}}</p>
<ul>
{%- for child, extras in this.children.items() -%}
{%- set etxra = (extras|first).tags_in_page %}
<li>{{etxra|length}} tags on page "{{child.path}}": {{etxra}}</li>
{%- for child in this.children%}
<li>page "{{child.path}}" with tags: {{child.tags}}</li>
{%- endfor %}
</ul>
```
@@ -279,7 +283,7 @@ This is useful if you do not want to create subpages but rather an index page co
This can be done in combination with the next use-case:
```jinja2
{%- for x in this|vgroups(keys=['TestA', 'TestB'], fields=[], flows=[], recursive=True)|unique|sort %}
{%- for x in this|vgroups(keys=['TestA', 'TestB'], fields=[], flows=[], recursive=True, order_by='group') %}
<a href="{{ x|url }}">({{ x.group }})</a>
{%- endfor %}
```
@@ -290,3 +294,7 @@ The keys (`'TestA', 'TestB'`) can be omitted which will return all groups of all
The `fields` and `flows` params are also optional.
With these you can match groups in `args.key.fieldKey` and `args.key.flowKey`.
For example, if you have a “tags” field and an “additional-tags” field and you only want to show one in a preview.
`order_by` can be either a comma-separated string or a list of keys.
Again, same [order-by](https://www.getlektor.com/docs/guides/page-order/) rules apply as for any other Lektor `Record`.
Only this time, the attributes of the `GroupBy` object are used for sorting (including those you defined in the `.fields` subsection).
{%- for k, v in [('testA','Config'),('testB','Simple'),('testC','Advanced')] %}
<div>{{v}} Tags:
{%- for x in this|vgroups(k, recursive=True)|unique|sort %}
{%- for x in this|vgroups(k, recursive=True, order_by='group') %}
<ahref="{{ x|url }}">({{x.key}})</a>
{%- endfor %}
</div>
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.