-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CIVIC-2089] Mobile search #1336
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richardgaunt - can you have a look at this and provide feedback on the best way to implement?
* @return array|null | ||
* The stored link array, or NULL if no link is stored. | ||
*/ | ||
function _civictheme_search_link(array $link = NULL): ?array { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about this approach. I'd leave it to @richardgaunt to provide feedback.
This seems like it could break if search block isn't rendered before the mobile navigation block, or if there are multiple search blocks.
I think we had discussed about multiple search blocks showing multiple links in mobile menu.
My assumption would have been something like:
use Drupal\block\Entity\Block;
// Load all blocks of type 'search'
$blocks = Block::loadMultiple(['type' => 'search']);
// Initialize an empty array to store the block data
$block_data = [];
// Iterate through the blocks and do something with them
foreach ($blocks as $block) {
// Get the block's configuration
$config = $block->getConfiguration();
// Check if the "field_c_b_link_in_mobile_menu" field checkbox is checked
$link_in_mobile_menu = $config['field_c_b_link_in_mobile_menu'] ?? false;
// Get the block's URL and title
$block_url = $config['url'];
$block_title = $config['title'];
if ($link_in_mobile_menu) {
// Add the block's URL and title to the $block_data array
$block_data[] = [
'url' => $block_url,
'title' => $block_title,
];
}
}
// Now you can use the $block_data array to do something with the block data
print_r($block_data);
in the mobile menu navigation, to identify any search blocks with that option checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this doesn't look right to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @alan-cole for the suggestion.
I tried with $blocks = Block::loadMultiple(['type' => 'search']);
but it didn't work for me so I use
// Load all blocks of type 'civictheme_search'
$block_storage = \Drupal::entityTypeManager()->getStorage('block_content');
$blocks = $block_storage->loadByProperties(['type' => 'civictheme_search']);
to get the block search content, it seems work well.
Please review my change.
Thank you!
Ticket:
Checklist before requesting a review
Issue #123456 by drupal_org_username: Issue title
Changed
section about WHY something was done if this was not a normal implementationChanged
Show link in mobile menu
field into search block typeScreenshots