Hot answers tagged

3

UPDATE As discussed here, this issue was caused by some missconfiguration at view level and normally should not occur. Read the full post to get the full picture on how you can step on this error. ORIGINAL ANSWER I'm adding my findings as answer since comments have limitations both on styles and length, but by all means THIS IS NOT an actual answer to the ...


2

The plugin was missing the proper annotation (added now in the question). Views plugins use Annotation Discovery. Adding something like the following solved the problem: /** * My custom serializer * * @ViewsStyle( * id = "hindi_custom_serializer", * title = @Translation("Hindi Custom Serializer"), * help = @Translation("Serializes views row ...


2

Use a views_view_ hook, i.e. views_view_unformatted, views_view_list etc... I tried this with a PHP count for my views block and it worked great. My function is: function MYTHEME_preprocess_views_view_unformatted(&$vars) { $num_rows = $vars["rows"]; $count = count($num_rows); echo '<h2>This view has ' . $count . ' rows</h2><br&...


1

In my case, the '$result->_entity' was empty, so I had to get the value from the '$result->_object' : function YOUR_THEME_preprocess_views_view__YOUR_VIEW_ID(array &$variables): void { foreach ($variables['view']->result as $result) { $node = $result->_object->getEntity(); $title = $node->get('title')->getValue()[0]['value']; ...


1

Ok, I solved it like this: function THEMENAME_preprocess_views_view_field(&$variables) { $view = $variables['view']; $field = $variables['field']; $rows = $variables['rows']; if ($view->id() == 'VIEW_NAME' && $view->current_display == 'DISPLAY_NAME') { if ($field->field == 'FIELD_NAME') { foreach ($view->field as $fieldId => $field) ...


1

In replacement to your "Learn more" add "Custom text" field after "Field_program_id" in your views. In "Text" add "a" tag like <a href="/search?nodeid={{field_program_id}}" class="button">Learn more</a> Take a look in "Replacement patterns" for available fields. Read description there too for a guidance. (this is in Drupal 8) It is the almost ...


Only top voted, non community-wiki answers of a minimum length are eligible