Skip to content

Commit

Permalink
Fehler behoben
Browse files Browse the repository at this point in the history
Fehler behoben -> "count(): Argument #1 ($value) must be of type Countable|array, null given"
Gruppen wurden nicht richtig dargestellt
  • Loading branch information
hhunderter committed Dec 17, 2023
1 parent 89d2729 commit 01c56b3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
11 changes: 8 additions & 3 deletions application/modules/faq/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ public function getUpdate(string $installedVersion): string
// Convert tables to new character set and collate
$this->db()->query('ALTER TABLE `[prefix]_faqs` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
$this->db()->query('ALTER TABLE `[prefix]_faqs_cats` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
// no break
// no break
case "1.3.0":
case "1.4.0":
case "1.5.0":
// Add read_access column
$this->db()->query('ALTER TABLE `[prefix]_faqs_cats` ADD COLUMN `read_access` VARCHAR(255) NOT NULL DEFAULT \'1,2,3\';');
// no break
// no break
case "1.6.0":
case "1.7.0":
// Update description
foreach ($this->config['languages'] as $key => $value) {
$this->db()->query(sprintf("UPDATE `[prefix]_modules_content` SET `description` = '%s' WHERE `key` = 'faq' AND `locale` = '%s';", $value['description'], $key));
}
// no break
// no break
case "1.8.0":
$this->db()->update('modules')->values(['icon_small' => $this->config['icon_small']])->where(['key' => $this->config['key']])->execute();

Expand Down Expand Up @@ -185,6 +185,11 @@ public function getUpdate(string $installedVersion): string

$this->db()->query('ALTER TABLE `[prefix]_faqs` ADD INDEX `FK_[prefix]_faqs_[prefix]_faqs_cats` (`cat_id`) USING BTREE;');
$this->db()->query('ALTER TABLE `[prefix]_faqs` ADD CONSTRAINT `FK_[prefix]_faqs_[prefix]_faqs_cats` FOREIGN KEY (`cat_id`) REFERENCES `[prefix]_faqs_cats` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE;');
// no break
case "1.9.0":
// no break
case "1.9.1":
// no break
}

return 'Update function executed.';
Expand Down
2 changes: 1 addition & 1 deletion application/modules/faq/controllers/admin/Cats.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function treatAction()
->add($this->getTranslator()->trans('menuCats'), ['action' => 'index'])
->add($this->getTranslator()->trans('edit'), ['action' => 'treat']);

$model = $categoryMapper->getCategoryById($this->getRequest()->getParam('id'));
$model = $categoryMapper->getCategoryById($this->getRequest()->getParam('id'), null);
} else {
$this->getLayout()->getAdminHmenu()
->add($this->getTranslator()->trans('menuFaqs'), ['action' => 'index'])
Expand Down
7 changes: 5 additions & 2 deletions application/modules/faq/views/admin/index/treat.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<?php if ($cats) : ?>
<form class="form-horizontal" method="POST" action="">
<?=$this->getTokenField() ?>
<div class="form-group <?=$this->validation()->hasError('catId') ? 'has-error' : '' ?>">
<div class="chosen-select form-group <?=$this->validation()->hasError('catId') ? 'has-error' : '' ?>">
<label for="catId" class="col-lg-2 control-label">
<?=$this->getTrans('cat') ?>:
</label>
Expand Down Expand Up @@ -54,7 +54,10 @@ class="form-control"
</div>
<?=($faq->getId()) ? $this->getSaveBar('updateButton') : $this->getSaveBar('addButton') ?>
</form>
<?=$this->getDialog('mediaModal', $this->getTrans('media'), '<iframe frameborder="0"></iframe>') ?>
<?php else : ?>
<?=$this->getTrans('noCategory') ?>
<?php endif; ?>

<script>
$('#catId').chosen();
</script>
2 changes: 1 addition & 1 deletion application/modules/faq/views/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<?php foreach ($categories as $category) :
$countFaqs = count($faqMapper->getFaqs(['f.cat_id' => $category->getId()], ['f.id' => 'ASC'], $readAccess));
$countFaqs = count($faqMapper->getFaqs(['f.cat_id' => $category->getId()], ['f.id' => 'ASC'], $readAccess) ?? []);
if ($category->getId() == $this->getRequest()->getParam('catId')) {
$active = 'class="active"';
} else {
Expand Down

0 comments on commit 01c56b3

Please sign in to comment.