/
[cms] Page search by content [5.2.2-B1]
[cms] Page search by content [5.2.2-B1]
For large CMS websites it's crucial for users to be able to find relevant content using Search page. Unfortunately in current implementation the actual page text (what's inside content blocks) isn't used during search which might result from page relevance indicator drop (in search results) to not even showing needed page.
Solution
- create "PageHelper::getRevisionContent($page_revision_id)" method, that will: - 0.5h
- get contents of all content blocks (they belong to single page) in a given revision
- process content from each language separately
- combine content block content using space and ignoring empty values
- call the "html_entity_decode" function with same arguments as "htmlspecialchars_decode" in "kUtil::unescape" (replaces " " and similar things with searchable equivalents)
- call the "strip_tags" (removed HTML tags)
- return associative array, where each key would be in "lX_PageContent" format (X is language ID) and value would be searchable revision content on that language
- add "lX_PageContent" column (X is language id) to the "PageRevisions" table: - 0.5h
- add multi-lingual field declaration in the unit config
- create "CoreUpgrades::Upgrade_5_2_2_B3" method (see similar methods in that class), that will only when "$mode == 'after'":
- call "\kMultiLanguageHelper::createFields" method to create new multilingual fields in "PageRevisions" table
- populate created fields using "PageHelper::getRevisionContent" method for each of existing page revisions
- create "page-revision:OnAfterPageContentChangedHook" event, that will: - 0.5h
- be a hook to "content:OnAfterItemCreate", "content:OnAfterItemUpdate" and "content:OnAfterItemDelete" events
- load page revision object associated with affected content block
- call "PageHelper::getRevisionContent" method to rebuild content
- store above retrieved content to loaded page revision in database
- add record to "SearchConfig" table to: - 0.5h
- appear in "Configuration > Website > Search" section
- make "PageRevisions.lX_PageContent" (X is language ID) of currently approved page revision (the Revision number (NOT ID) is stored in "Categories.LiveRevisionNumber" column)
Quote: 2h*1.4 = 3h