Skip to content

Commit

Permalink
Hide similar courses when there are none
Browse files Browse the repository at this point in the history
  • Loading branch information
JortvD committed Oct 5, 2023
1 parent ac40bad commit 3621f6c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
7 changes: 3 additions & 4 deletions module/Education/src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ public function addCourseAction(): Response|ViewModel
$data = $form->getData(FormInterface::VALUES_AS_ARRAY);
$course = $this->courseService->saveCourse($data);

if ($this->courseService->saveCourse($course)) {
$this->flashMessenger()->addSuccessMessage(
$this->translator->translate('Successfully added course!'),
);
$this->flashMessenger()->addSuccessMessage(
$this->translator->translate('Successfully added course!'),
);

return $this->redirect()->toRoute('admin_education/course/edit', ['course' => $course->getCode()]);
}
Expand Down
34 changes: 18 additions & 16 deletions module/Education/view/education/education/course.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,24 @@ foreach ($documents as $document) {
<?php endif; ?>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-8">
<h2><?= $this->translate('Similar courses') ?></h2>
<ul>
<?php foreach ($course->getSimilarCoursesTo() as $similarCourse): ?>
<li>
<a href="<?= $this->url('education/course', [
'code' => $similarCourse->getCode(),
]) ?>">
<?= $this->escapeHtml($similarCourse->getCode()) ?> - <?= $this->escapeHtml($similarCourse->getName()) ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php if (count($course->getSimilarCoursesTo()) > 0): ?>
<hr>
<div class="row">
<div class="col-md-8">
<h2><?= $this->translate('Similar courses') ?></h2>
<ul>
<?php foreach ($course->getSimilarCoursesTo() as $similarCourse): ?>
<li>
<a href="<?= $this->url('education/course', [
'code' => $similarCourse->getCode(),
]) ?>">
<?= $this->escapeHtml($similarCourse->getCode()) ?> - <?= $this->escapeHtml($similarCourse->getName()) ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<?php endif; ?>
</div>
</section>

0 comments on commit 3621f6c

Please sign in to comment.