Honor the mapped page template when creating pages - #79
Open
hissy wants to merge 1 commit into
Open
Conversation
CreatePageStructureCommandHandler::createRegularPage() resolved the mapped page template into $pageTemplate, but only passed its ID inside the $data array. Page::add() never reads $data['pTemplateID']; it takes the template from its third argument, and when that is falsy it substitutes the page type's default template instead. As a result every newly published page received its page type's default template, and the template mapping configured for the batch had no effect. Batches published a second time looked correct, because updateExistingPage() goes through Page::update(), which does honor pTemplateID. Passing the template to Page::add() also lets it copy the page type defaults belonging to that template, via getPageTypePageTemplateDefaultPageObject($template), so pages no longer inherit the default template's blocks. Aliases and external links are unaffected: they have no page template. The multilingual home page branch below already passed $pageTemplate to addHomePage(). Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #44.
Problem
CreatePageStructureCommandHandler::createRegularPage()resolves the mapped page template into$pageTemplate, but only passes its ID inside the$dataarray:Page::add()never reads$data['pTemplateID']. It takes the template from its third argument, and when that argument is falsy it substitutes the page type's default template instead:So every newly published page receives its page type's default template, and the template mapping configured for the batch has no effect — exactly what #44 describes. The mapping itself is fine; the resolved template just never reaches
Page::add().This is easy to miss because publishing the same batch a second time looks correct: the pages then exist, so
updateExistingPage()runs instead, and that goes throughPage::update(), which does honorpTemplateID.Fix
Pass the resolved template to
Page::add()as the third argument.This also lets
Page::add()copy the page type defaults belonging to that template, viagetPageTypePageTemplateDefaultPageObject($template). Previously pages were given the default template's blocks in addition to its template, so this corrects the default blocks too.Scope
$pageTemplatetoaddHomePage().$pageTemplateisnullwhen the template is unmapped or ignored, and?: falsepreserves the existing "no template" behaviour, so the page type default still applies in that case.Verification
Against a Concrete 9 site with a
seminar_entrypage type whose default template isseminar_entry, publishing a CIF page carryingtemplate="seminar_entry_sidebar"(mapped in the batch). CallingPage::add()both ways with identical$data:In a real batch of 52 pages, 11 of which specified the non-default template, all 52 previously came through as
seminar_entry; the areas belonging to the sidebar template imported their blocks but never rendered.Made with Cursor