doublesecretagency / craft-siteswitcher

Site Switcher plugin for Craft CMS
MIT License
67 stars 7 forks source link

Question:: It is possible to get site attributes #22

Closed zzseba78 closed 2 years ago

zzseba78 commented 2 years ago

It is possible to get site attributes like title, id, slug, and so on with this plugin? thank you

lindseydiloreto commented 2 years ago

Unless I'm misunderstanding the question... you don't need this plugin to get the site attributes for you. In theory, you will already have access to the attributes you need.

From the docs...

{% set element = (category ?? entry ?? null) %}

<ul>
    {% for site in craft.app.sites.getAllSites() %}
        <li><a href="{{ siteSwitcher(site.handle, element) }}">{{ site.name }}</a></li>
    {% endfor %}
</ul>

Within the context of that loop, you could access site.id or any other attributes associated with each site.

Hope that helps!