I want to send url the website from Twig template to plugin (I create One plugin) in grav but when I get the value of url is "null". here is code twig
{% extends 'partials/base.html.twig' %}
{% block content %}
{% set fullUrl = page.url(true)|e %}
{% set parsedUrl = fullUrl|parse_url %}
{% set url = parsedUrl.host %}
{{ url }}
{% set data = getdata(url) %}
and for plugin
public function getFunctions(): array
{
return [
new \Twig_SimpleFunction('getdata', [$this, 'exampleFunction'])
];
}
public function exampleFunction($url)
{
// Extract host from URL
$host = parse_url($url, PHP_URL_HOST);
if ($host === null) {
echo 'Invalid URL';
}
dump($host);
I am try to get the url in my plugin but I get NULL of value the $url