Plugin screenshot thumbnail 1/1

Sites Field

This plugin provides a field type for choosing sites. Entries using this field can then access the site ID in their templates.


Requirements

  • Craft CMS 3.0.0-RC1 or above

Example Usage

To display only events related to the current site you could use the following logic:

{% set events = craft.entries.site('main').section('blog').type('event').orderBy('date asc').all() %}
{% for event in events %}
  {% if craft.app.sites.currentSite.id in event.siteIds %}
    {# show this event... #}
  {% endif %}
{% endfor %}

Note: siteIds returns an array of site ID's which you can use the twig in operator.

Installation Instructions

To install this plugin, copy the command above to your terminal.

Reviews

This plugin doesn't have any reviews.

Active Installs
99
Version
1.0.6
License
MIT
Compatibility
Craft 3, Craft 4, Craft 5
Last release
July 9, 2024
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
0
Open PRs