Skip to content

Commit

Permalink
Fix bug in dynamic channel/structure entries tag
Browse files Browse the repository at this point in the history
  • Loading branch information
bryannielsen committed Dec 18, 2023
1 parent c715030 commit 97bc733
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- Bug retrieving dynamic Structure entry from Structure Entries tag

## [1.2.2] - 2023-12-05

### Fixed
Expand Down
13 changes: 7 additions & 6 deletions src/View/Tags/Channel/Entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,15 @@ public function run()
]);
}

$lastSegment = last(ee()->uri->segment_array() ?: request()->segments());

// EE sets the page_query_string to an entry_id if the segment is found
// in the config site_pages array during Core::generate_page()
$queryString = (ee()->uri->page_query_string != '') ? ee()->uri->page_query_string : ee()->uri->query_string;
$this->setArgument('limit', 1);

$this->query->when(is_numeric($lastSegment), function ($query) use ($lastSegment) {
$query->where('entry_id', (int) $lastSegment);
}, function ($query) use ($lastSegment) {
$query->where('url_title', $lastSegment);
$this->query->when(is_numeric($queryString), function ($query) use ($queryString) {
$query->where('entry_id', (int) $queryString);
}, function ($query) use ($queryString) {
$query->where('url_title', $queryString);
});
}

Expand Down

0 comments on commit 97bc733

Please sign in to comment.