Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'development' of https://github.com/Dolphiq/craft3-plugi…
Browse files Browse the repository at this point in the history
…n-sitemap into development

* 'development' of https://github.com/Dolphiq/craft3-plugin-sitemap:
  Added a fix for deleted sites
  Fix and/or operation order
  Filter out deleted sections and draft elements
  • Loading branch information
johanzandstra committed Aug 3, 2020
2 parents cae27b0 + 51e6e62 commit d588335
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private function _createEntrySectionQuery(): Query
->leftJoin('{{%dolphiq_sitemap_entries}} sitemap_entries', '[[sections.id]] = [[sitemap_entries.linkId]] AND [[sitemap_entries.type]] = "section"')

->groupBy(['sections.id'])
->where(['sections.dateDeleted' => null])
->orderBy(['type' => SORT_ASC],['name' => SORT_ASC]);
}

Expand Down
9 changes: 5 additions & 4 deletions src/controllers/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,16 @@ private function _createEntrySectionQuery(): Query
'[[sections_sites.sectionId]] = [[sections.id]] AND [[sections_sites.hasUrls]] = 1')
->innerJoin('{{%entries}} entries', '[[sections.id]] = [[entries.sectionId]]')
->andWhere(['<=', 'entries.postDate', $currentDate])
->andWhere(['>', 'entries.expiryDate', $currentDate])
->orWhere(['entries.expiryDate'=> null])
->andWhere(['or', 'entries.expiryDate > :currentDate', 'entries.expiryDate is null'], [':currentDate' => $currentDate])
->innerJoin('{{%elements}} elements', '[[entries.id]] = [[elements.id]] AND [[elements.enabled]] = 1')
->innerJoin('{{%elements_sites}} elements_sites',
'[[elements_sites.elementId]] = [[elements.id]] AND [[elements_sites.enabled]] = 1')
->innerJoin('{{%sites}} sites', '[[elements_sites.siteId]] = [[sites.id]]')
->andWhere(['elements.dateDeleted' => null])
->andWhere(['sites.dateDeleted' => null])
->andWhere(['elements.archived' => false])
->andWhere(['elements.draftId' => null])
->andWhere(['elements.revisionId' => null])


->groupBy(['elements_sites.id']);
}

Expand Down Expand Up @@ -206,6 +205,7 @@ private function _createAlternateSectionQuery($elementId): Query
'[[elements_sites.elementId]] = [[elements.id]] AND [[elements_sites.enabled]] = 1')
->innerJoin('{{%sites}} sites', '[[elements_sites.siteId]] = [[sites.id]]')
->where(['=', '[[elements_sites.elementId]]', $elementId])
->andWhere(['sites.dateDeleted' => null])
->groupBy(['elements_sites.id']);
}

Expand All @@ -230,6 +230,7 @@ private function _createEntryCategoryQuery(): Query
'[[elements_sites.elementId]] = [[elements.id]] AND [[elements_sites.enabled]] = 1')
->innerJoin('{{%sites}} sites', '[[elements_sites.siteId]] = [[sites.id]]')
->andWhere(['elements.dateDeleted' => null])
->andWhere(['sites.dateDeleted' => null])
->groupBy(['elements_sites.id']);
}

Expand Down

0 comments on commit d588335

Please sign in to comment.