Problem/Motivation

Navigation block is auto-loaded meaning it is difficult to change or replace with another block.

Proposed resolution

Add hooks and options to swap out block or modify common bits of existing block.

Remaining tasks

Provide patch

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

Added more flexibility to customise the navigation block.

Credit

Initial code from `fathimaasmat`

Comments

scott_euser created an issue. See original summary.

scott_euser’s picture

Assigned: scott_euser » Unassigned
Status: Active » Needs review
StatusFileSize
new15.83 KB

Attached patch

fathima.asmat’s picture

The current "chapter_heading_label_alter" function does not take the chapter headings into account instead it alters the chapter SECTION headings, so it would be good to reword the function to "chapter_section_heading_label_alter".
Also adding a couple more hooks to alter the chapter headings in similar way and another hook to customise chapter menu item markup would be useful.
The patch and interdiff files are provided for these edits/additions.

Status: Needs review » Needs work

The last submitted patch, 4: epub_reader_framework-flexibility-for-navigation-block-3156378-3.patch.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

scott_euser’s picture

Status: Needs work » Needs review
StatusFileSize
new17.72 KB
new5.52 KB

Okay I think I've got what you are trying to achieve. I've refactored a bit to make the alter of the menu item broader to allow the full render array to be modified.

You should now be able to do this:

/**
 * Perform alterations on the chapter link item markup.
 *
 * @param array $chapter_menu_item
 *   The chapter menu item including link and icon.
 */
function MODULE_NAME_epub_reader_framework_navigation_chapter_menu_item_alter(&$chapter_menu_item) {
  $chapter_menu_item['#attributes'] = array_merge_recursive([
    'class' => ['u-container'],
  ]);
}

I've also added the `chapter_label` and `chapter_heading` alters to alter the two labels. I've kept `chapter_heading` as the headings within the chapter as that matches the object name and database storage for it.

  • scott_euser committed 680cf1f on 8.x-1.x
    Issue #3156378 by scott_euser, fathima.asmat: Provide more flexibility...
scott_euser’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.