Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show all slides in back office #104

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading