Parcourir la source

fix navbar merge, rm url key

master^2
Ernest Debruyne il y a 2 ans
Parent
révision
2d9d3ec398
3 fichiers modifiés avec 7 ajouts et 11 suppressions
  1. 2
    2
      public/index.php
  2. 3
    7
      src/View/Twig.php
  3. 2
    2
      templates/navbar.html.twig

+ 2
- 2
public/index.php Voir le fichier

@@ -51,7 +51,7 @@ function addNavbar($twig)
["link" => "https://www.facebook.com", "name" => "Facebook"],
["link" => "https://www.twiter.com", "name" => "Twitter"]
];
$twig->addBlockVariable('navbar', ['urls' => $urls]);
$twig->addBlockVariable('navbar', $urls);
}


@@ -62,7 +62,7 @@ function addNavbar2($twig)
["link" => "https://www.facebook.com", "name" => "Apple"],
["link" => "https://www.twiter.com", "name" => "TikTok"]
];
$twig->addBlockVariable('navbar', ['urls' => $urls]);
$twig->addBlockVariable('navbar', $urls);
}

function addFooter($response)

+ 3
- 7
src/View/Twig.php Voir le fichier

@@ -33,13 +33,9 @@ class Twig
// add block variables to the global variable bag
public function addBlockVariable($block, $data)
{
$current = $this->variables[$block]['urls'];
if ($current) {
$new = array_merge($current, $data['urls']);
} else {
$new = $data['urls'];
}
$this->variables[$block]['urls'] = $new;
$current = $this->variables[$block];
$new = array_merge($current, $data);
$this->variables[$block] = $new;
}

public function render($tmpl, $vars)

+ 2
- 2
templates/navbar.html.twig Voir le fichier

@@ -1,8 +1,8 @@
<div>
<ul>
{% for url in navbar.urls.getLinks %}
{% for url in navbar %}
<li>
<a href="{{ url.url }}">{{ url.name }} </a>
<a href="{{ url.link }}">{{ url.name }} </a>
</li>
{% endfor %}
</ul>

Chargement…
Annuler
Enregistrer