diff --git a/src/Model/PointOfInterestModel.php b/src/Model/PointOfInterestModel.php index 7ea2118..5ead213 100644 --- a/src/Model/PointOfInterestModel.php +++ b/src/Model/PointOfInterestModel.php @@ -4,9 +4,23 @@ namespace Oneup\Contao\ContaoPointsOfInterestBundle\Model; +use Contao\Date; use Contao\Model; class PointOfInterestModel extends Model { protected static $strTable = 'tl_point_of_interest'; + + public static function findPublishedByPid($intPid, array $arrOptions = []) + { + $t = static::$strTable; + $arrColumns = ["$t.pid=?"]; + + if (!static::isPreviewMode($arrOptions)) { + $time = Date::floorToMinute(); + $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; + } + + return static::findBy($arrColumns, $intPid, $arrOptions); + } } diff --git a/src/PointsOfInterest/ResponseRenderer.php b/src/PointsOfInterest/ResponseRenderer.php index 1ff54e8..fffb027 100644 --- a/src/PointsOfInterest/ResponseRenderer.php +++ b/src/PointsOfInterest/ResponseRenderer.php @@ -26,7 +26,7 @@ public function getResponse(Template $template, Model $model, Request $request): return $template->getResponse(); } - $pois = PointOfInterestModel::findBy('pid', $poi->id); + $pois = PointOfInterestModel::findPublishedByPid($poi->id); $fileModel = FilesModel::findByUuid($poi->singleSRC); diff --git a/src/Resources/contao/dca/tl_point_of_interest.php b/src/Resources/contao/dca/tl_point_of_interest.php index 1550b8c..4760539 100644 --- a/src/Resources/contao/dca/tl_point_of_interest.php +++ b/src/Resources/contao/dca/tl_point_of_interest.php @@ -120,7 +120,7 @@ 'wizard' => [ ['oneup_contao_points_of_interest.dca_helper', 'showPositionPicker'], ], - 'sql' => "mediumtext NULL", + 'sql' => 'mediumtext NULL', ], 'cssID' => [ 'exclude' => true,