Commit 0c4d8ab4 authored by Administrator's avatar Administrator 💬

feat: review the lessons order

parent 9ff0cdbc
...@@ -10,8 +10,12 @@ use Symfony\Component\EventDispatcher\Event; ...@@ -10,8 +10,12 @@ use Symfony\Component\EventDispatcher\Event;
/** /**
* Features: * Features:
* - /sync Cheap git-sync (did not knew about it at the time) * - /sync Cheap git-sync (did not knew about it at the time)
* - /polyglot/<page-path>
* - /lessons/<lesson-slug> * - /lessons/<lesson-slug>
* *
* The way GRAV works to define new routes is to listen to the onPageNotFound event.
* This is expected to evolve as GRAV integrates more and more with Symfony components.
*
* Class M3P2Plugin * Class M3P2Plugin
* @package Grav\Plugin * @package Grav\Plugin
*/ */
...@@ -218,7 +222,7 @@ class M3P2Plugin extends Plugin ...@@ -218,7 +222,7 @@ class M3P2Plugin extends Plugin
$uri = $this->grav['uri']; $uri = $this->grav['uri'];
// var_dump($uri); // best doc ftw // var_dump($uri); // best doc ftw
if ("lesson" != $uri->paths(0)) { if ("lessons" != $uri->paths(0)) {
return; // perhaps not return; // perhaps not
} }
...@@ -260,19 +264,19 @@ class M3P2Plugin extends Plugin ...@@ -260,19 +264,19 @@ class M3P2Plugin extends Plugin
$ha = $a->header(); $ha = $a->header();
$hb = $b->header(); $hb = $b->header();
$fdp = function ($pp) use ($lesson_slug) { $fdp = function ($lesson) use ($lesson_slug) {
return $pp["slug"] == $lesson_slug; return $lesson["slug"] == $lesson_slug;
}; };
// We're assuming the config exists (it should) // We're assuming the config exists (it should)
$ma = array_filter($ha->lessons, $fdp)[0]; $ma = array_filter($ha->lessons, $fdp)[0];
$mb = array_filter($hb->lessons, $fdp)[0]; $mb = array_filter($hb->lessons, $fdp)[0];
if (isset($ma['level'])) { if (isset($ma['order'])) {
$la = floor($ma['level']); $la = floor($ma['order']);
} }
if (isset($mb['level'])) { if (isset($mb['order'])) {
$lb = floor($mb['level']); $lb = floor($mb['order']);
} }
return $la - $lb; return $la - $lb;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment