Twig filter to extract the domain name from a string.
This plugin requires Craft CMS 3.x
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require akagibi/getdomain
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Getdomain.
Getdomain filter can be used with 4 different parameters.
- full
- long
- normal
- short default
Input:
{% set url = "https://www.domain.com:1234/index.html?param" %}
{{ url | getdomain(full) }}
{{ url | getdomain(long) }}
{{ url | getdomain(normal) }}
{{ url | getdomain }}
Output:
https://www.domain.com:1234
https://www.domain.com
www.domain.com
domain.com
Brought to you by Akagibi