Problem/Motivation
Block plugin with cores or specific fields should be more configurable. Based on selection result will be shown in blocks.

Proposed resolution
In block plugin create radio button to select the core or specific field and show the result based on selection.

Comments

dishabhadra created an issue. See original summary.

dishabhadra’s picture

StatusFileSize
new2.51 KB

Added the Radio button to select the core and type for block to get the results.

dishabhadra’s picture

StatusFileSize
new9.45 KB

Added the Solarium Filter Query based on Identifier types.

dishabhadra’s picture

Assigned: dishabhadra » Unassigned
Status: Active » Needs review
piyuesh23’s picture

Status: Needs review » Needs work

@Disha,

The patch looks good. However, i think a little more effort would make the plugin more generic. Additional comments below:

  1. +++ b/src/Plugin/Block/CustomSolrSearchResultBlock.php
    @@ -64,16 +76,39 @@ class CustomSolrSearchResultBlock extends BlockBase implements ContainerFactoryP
    +      '#options' => array( 'core' => $this->t('Core'), 'type' => $this->t('Type')),
    
    @@ -94,33 +132,43 @@ class CustomSolrSearchResultBlock extends BlockBase implements ContainerFactoryP
    +    // Selecte the type.
    

    Typo here.

  2. +++ b/src/Search.php
    @@ -29,11 +30,13 @@ class Search {
    +  public function basicSearch($keyword, $offset, $limit, $solr_core, $type = NULL) {
    

    I would suggest replacing $type with $options. This would make the function more extendable. e.g.,

    i can later pass $options = array('sort' => 'date', 'filter' => array('format' => 'type'));

    Also, don't think its a good idea to hardcode the query parameter to 'format' in this function.

  3. +++ b/src/SearchSolrAll.php
    @@ -26,14 +26,16 @@ class SearchSolrAll {
    +  public function seachAll($keyword, $type = NULL){
    

    Same as basicSearch()

dishabhadra’s picture

StatusFileSize
new9.73 KB

All the review changes are done.
Remove the hardcoded format type and make it configurable.

harivenuv’s picture

hi dishabhadra,

Can you please double check the patch (https://www.drupal.org/files/issues/block_plugin-2756975-1.patch), there is number of white spaces occurred..

swarad07’s picture

Apart from whitespaces, I think the patch is also missing the Plugin directory. It is not present in 8.x-1.x, so should be part of this patch, no?

Checking patch src/Plugin/Block/CustomSolrSearchResultBlock.php...
error: src/Plugin/Block/CustomSolrSearchResultBlock.php: No such file or directory
piyuesh23’s picture

@swarad, This patch is intended for 8.x-1.x-dev. Plugin directory was pushed in to dev as a part of the last patch.

  1. +++ b/src/Plugin/Block/CustomSolrSearchResultBlock.php
    @@ -84,6 +119,9 @@ class CustomSolrSearchResultBlock extends BlockBase implements ContainerFactoryP
    +    ¶
    

    Whitespace here.

  2. +++ b/src/Plugin/Block/CustomSolrSearchResultBlock.php
    @@ -94,33 +132,45 @@ class CustomSolrSearchResultBlock extends BlockBase implements ContainerFactoryP
    +    ¶
    

    Whitespace here.

dishabhadra’s picture

StatusFileSize
new9.67 KB

Hi Piyuesh,

Whitespace is removed.

piyuesh23’s picture

Status: Needs work » Closed (fixed)
swarad07’s picture

Got it, did not realise there was a separate dev branch.