Giter Club home page Giter Club logo

taxonomylist's Introduction

TaxonomyList

This extension adds a twig tag for Taxonomy Listings.

You can use this extension to create category listings and tagclouds.

Simple lookup

The quick lookup only reads the taxonomy config and does not count items in the database. Usage with quick lookup:

    {% set list = taxonomylist('categories') %}
    <ul>
    {% for item in list %}
        <li>
            <a class="taxonomy-{{ item.slug }}" href="{{ item.link }}" title="{{ item.name }}">
                {{ item.name }}
            </a>
        </li>
    {% endfor %}
    </ul>

Tags lookup or full lookup

The full lookup counts all items in the database for each category and returns this in {{ item.count }}.

If your taxonomy behaves like a tags category, there will automatically be a full lookup - because the individual tags are not visible in the config file.

Usage with full lookup:

    {% set list = taxonomylist('categories', true) %}
    <ul>
    {% for item in list %}
        <li>
            <a class="taxonomy-{{ item.slug }}" href="{{ item.link }}" title="{{ item.name }}">
                {{ item.name }}
                <small>{{ item.count }}</small>
            </a>
        </li>
    {% endfor %}
    </ul>

Use as a Tagcloud

A tagcloud, usage with limit and weight in a full lookup (it does not make sense to do a quick lookup with weighted tags, or limits):

    {% set list = taxonomylist('categories', { 'limit': 10, 'weighted': true } ) %}
    <nav class="tags">
    {% for item in list %}
            <a class="taxonomy-{{ item.slug }} weight-{{ item.weightclass }}" href="{{ item.link }}" title="{{ item.name }}">
                {{ item.name }}
                <small>{{ item.count }} items</small>
            </a>
    {% endfor %}
    </nav>

Weighted will return the tags with the most matches first, unweighted will return the tags in the original sortorder. Taxonomy terms without any records in the database will not be returned.

The weighted query also returns {{ item.weight }} and {{ item.weightclass }}. The {{ item.weight }} is a percentage. The {{ item.weightclass }} is one of xl, x, m, s, xs.

Only published items

If you only want to count the published items you will need to know the content type as well as the taxonomy. The rest of the behaviour is the same as the other options.

    {% set list = taxonomylist('categories', { 'limit': 10, 'weighted': true, 'contenttype': 'pages' } ) %}

This might be a problem if you share taxonomies with more contentypes.

Override order

If you prefer to specify the order of the tags. This option will be ignored if weighted is set to true.

    {% set list = taxonomylist('categories', { 'orderby': 'name' } ) %}

or descending order

    {% set list = taxonomylist('categories', { 'orderby': '-name' } ) %}

taxonomylist's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

taxonomylist's Issues

AJAX: The function "taxonomylist" does not exist in "listing.twig" at line 11

Hi,

Bit of a strange issue, calling a page via ajax for instance /categories/news?page_category_news=2 results in a 500 error and the following error message in the Bolt system log

Type: Critical
Context: exception
Route: taxonomylink
URI: /categories/news?page_category_news=2
Details: The function "taxonomylist" does not exist in "listing.twig" at line 11

A standard request to the URI works fine :-/

Feature request: add template option

Very often you assign different listing templates to different contenttypes.
It would be nice if the extension lets you assign a custom listing template.
If no template is assigned > get the listing template form contenttypes.yml > else use the listing template used in config.yml

This way you can create some sort of frontpage for your contenttype and when using the pager, the following pages can use it's own listing template.

If you know what I mean.

Feature request: order by name

Currently, if weighted option is not set/false, the sortorder defaults to sortorder ASC. That my apply to some taxonomies, but for tags, the most likely default sort order is alphabetical, ie by name ASC. It would be nice to be able to specify this in the twig function.

Exception thrown when taxonomy is empty

When I have a contenttype item with a taxonomy, it will crash the page when I pass parameters to the twig taxonomylist function.

I'm getting the following fatal error:

An exception has been thrown during the rendering of a template ("Parameter "slug" for route "taxonomylink" must match "[^/]++" ("" given) to generate a corresponding URL.") in "partials/_bar-articles.twig" at line 2.

It seems the function doesn't understand content items not having an assigned taxonomy, and I can't find a way to make taxonomy a required field or give it a default value.

Release Tag

Could you maybe release a tag including the latest bugfixes?

tags limit

make it possible to limit the number of results retuned

maybe by

{% set list = taxonomylist('tags', { 'limit':10}) %}

Taxonomylist jadwigo insert images

Hi there!!
I´m using taxonomylist by jadwigo.
I wish to insert images for each category.
i have a folder with specific .jpgs in public/theme/mytheme/images/category.jpg
how can i insert in your code these images with that path?

    <nav class="taggy flex margin center tags icons p-margin">
    {% for item in list %}
<a class="icon fa-tags taxonomy-{{ item.tag }} 
weight-{{ item.weightclass }}" 
href="{{ item.link }}" 
title="{{ item.name }}">
{{ item.name }}
               
        </a>   
    {% endfor %}
    </nav>

Thank you!!
Roland

Unable to create tag cloud with taxonomy "Tags"

Hi,

I'm trying to create a weighted tagcloud with the following code:

{% set list = taxonomylist('tags', { 'limit': 10, 'weighted': true }) %}

But this doesn't work for tags. If I use categories it works like a charm.

The error I'm getting is the classic
Bolt ClassNotFoundException in Local.php line 311: Attempted to load class "finfo" from the global namespace.Did you forget a "use" statement?

I'm using Bolt 3.3.0,

weighted tags

Return weighted results for tagcloud lists

{% set list = taxonomylist('tags', { 'weighted':true}) %}

Passing any options to taxonomylist showing error

both on bolt 3.2.1 and 3.2.3 this extension throwing exception when I am passing any options such as {'limit': 10, 'weighted': true} but working when only passed true

An exception has been thrown during the rendering of a template ("Notice: Undefined index: options") in "taxonomylist.twig" at line 13.```

Sort items by their count

Hi,

I made a little modification on my copy of TaxonomyList, because I wanted more used tags listed first, maybe it can be useful for main version:

On //default parameters at getFullTaxonomy function:

        if(isset($params['sortcounted']) && $params['sortcounted']==true) {
                $sortcounted = true;
            }

And then, on sort order if:

           // type of sort depending on params
            if($weighted || $sortcounted) {
                $sortorder = 'count DESC';
            } else {
                $sortorder = 'sortorder ASC';
            }

On method of use, it looks like:

{% set list = taxonomylist('tags', { 'limit': 20, 'sortcounted': true}) %}

Best regards,

Ricardo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.