Skip to content

Commit

Permalink
Merge pull request #104 from kpodemski/fix-non-existent-images
Browse files Browse the repository at this point in the history
Show all slides in back office
  • Loading branch information
kpodemski authored Jun 26, 2024
2 parents 9183d0c + c4d8a45 commit 8f62eda
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions ps_imageslider.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected function createTables()
*/
protected function deleteTables()
{
$slides = $this->getSlides();
$slides = $this->getSlides(null, true);
foreach ($slides as $slide) {
$to_del = new Ps_HomeSlide($slide['id_slide']);
$to_del->delete();
Expand Down Expand Up @@ -655,7 +655,15 @@ public function getNextPosition()
return ++$row['next_position'];
}

public function getSlides($active = null)
/**
* Get slides
*
* @param bool $active
* @param bool $forceShowAll Include all slides, even those without image for a given language
*
* @return array
*/
public function getSlides($active = null, $forceShowAll = false)
{
$this->context = Context::getContext();
$id_shop = $this->context->shop->id;
Expand All @@ -668,8 +676,8 @@ public function getSlides($active = null)
LEFT JOIN ' . _DB_PREFIX_ . 'homeslider_slides hss ON (hs.id_homeslider_slides = hss.id_homeslider_slides)
LEFT JOIN ' . _DB_PREFIX_ . 'homeslider_slides_lang hssl ON (hss.id_homeslider_slides = hssl.id_homeslider_slides)
WHERE id_shop = ' . (int) $id_shop . '
AND hssl.id_lang = ' . (int) $id_lang . '
AND hssl.`image` <> ""' .
AND hssl.id_lang = ' . (int) $id_lang .
($forceShowAll ? '' : ' AND hssl.`image` <> ""') .
($active ? ' AND hss.`active` = 1' : ' ') . '
ORDER BY hss.position'
);
Expand Down Expand Up @@ -732,7 +740,7 @@ public function slideExists($id_slide)

public function renderList()
{
$slides = $this->getSlides();
$slides = $this->getSlides(null, true);
foreach ($slides as $key => $slide) {
$slides[$key]['status'] = $this->displayStatus($slide['id_slide'], $slide['active']);
$associated_shop_ids = Ps_HomeSlide::getAssociatedIdsShop((int) $slide['id_slide']);
Expand Down

0 comments on commit 8f62eda

Please sign in to comment.