Problem/Motivation

See #1880976: [meta] Port examples (including submodules) to D9.4+

Review views_examples (see #1883776: Port views examples to D8) and views_plugin_examples (see #1883780: Port views plugin examples to D8).

  1. Data integration: Exposing a table in your module to Views with a hook_views_data().
  2. Data handlers: Examples of field, filter, and argument handlers would go well with #1).
  3. Other plugin examples: E.g., a style plugin.

Please edit this summary to make this list more accurate

Proposed resolution

Remaining tasks

  1. Check the #2209627: [meta] Module Checklist for Examples for items missed below
  2. We need views_example.module file. This needs a @defgroup for the API site, and a bunch of text describing what the module does, what it demonstrates, and how to see it in action. #1883760-6: New examples for views on D8
  3. We also need a page which will show us the view in action, and enough textual information to let a newbie know if they're even looking at the right thing. #1883760-6: New examples for views on D8
  4. Examples of field, filter, and argument handlers would go well with #1) #1883760-12: New examples for views on D8
  5. Example Style plugin example #1883760-10: New examples for views on D8

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marvil07’s picture

Issue summary: View changes

Links to other full projects which exemplify views

marvil07’s picture

Issue summary: View changes

Link to issues on example modules for views.

xjm’s picture

Issue summary: View changes

Updated issue summary.

xjm’s picture

Issue summary: View changes

Updated issue summary.

blazey’s picture

Assigned: Unassigned » blazey
Issue summary: View changes
Status: Active » Needs review
FileSize
10.27 KB

Attaching patch for 1). It contains hook_schema and corresponding hook_views_data implementation. hook_views_data template was taken from views.api.php.

Status: Needs review » Needs work

The last submitted patch, 1: examples-hook_views_data-1883760-1.patch, failed testing.

blazey’s picture

Status: Needs work » Needs review
FileSize
23.02 KB
13.32 KB

Added default view using fields defined in hook_views_data.

Status: Needs review » Needs work

The last submitted patch, 3: interdiff-1883760-1-3.patch, failed testing.

The last submitted patch, 3: examples-views_examples_default_view-3.patch, failed testing.

Mile23’s picture

Thanks for moving forward on this, @blazey.

If you name the interdiff as 'interdiff.txt', the testbot won't try and test it.

  1. --- /dev/null
    +++ b/views_example/config/install/views.view.views_example.yml
    

    OK, this is a huge file of YML with no comments. We need a description of what this file is for, why given values were used, etc.

  2. +++ b/views_example/config/install/views.view.views_example.yml
    --- /dev/null
    +++ b/views_example/views_example.info.yml
    

    I know D8 doesn't necessarily need a .module file any more, but Examples does. We need a @defgroup for the API site, and a bunch of text describing what the module does, what it demonstrates, and how to see it in action.

    We also need a page which will show us the view in action, and enough textual information to let a newbie know if they're even looking at the right thing.

    See also the Examples module checklist: #2209627: [meta] Module Checklist for Examples

    Also tests. :-) The test run failed because of branch blockers.

TechNikh’s picture

If anyone landed on this issue like me looking for views integration with content_entity_example
https://www.drupal.org/node/2192175#comment-10758756

"list_builder" = "Drupal\content_entity_example\Entity\Controller\ContactListBuilder",
 *     "views_data" = "Drupal\views\EntityViewsData",
 *     "form" = {
lukas.fischer’s picture

Yes, please add "views_data" = "Drupal\views\EntityViewsData" to the examples code.

Mikael Berger’s picture

Hello,

Hopefully this is the right place to post a suggestion, it has not been easy to find active discussions on views plugin examples.

I have a sandbox project at Uikit Slideshow which I think might be suitable as a Views Style Plugin Example. Albeit developed for a particular use case, it also shows how to pick individual fields in the views row and then employ them in the plugin's Twig template.

If you find my suggestion to be appropriate, please bear in mind that I am a newbie module developer. Needless to say, this means that I maybe would need some help and advise for moving towards Drupal's full project standards.

Cheers
Mikael

Mile23’s picture

Assigned: blazey » Unassigned
bucefal91’s picture

Hello, guys!

Just recently I published a series of articles targeted to Drupal developers interested in advanced views integration for D8. https://medium.com/@oleksandr.trotsenko/drupal-8-views-tutorial-for-deve... It would cover points 1 and 2 from the main description of this issue. If you think any of those materials may serve for examples, feel free to grab it.

clemens.tolboom’s picture

Added to get listed on the Examples toolbar and menu links.

clemens.tolboom’s picture

Issue summary: View changes
clemens.tolboom’s picture

Issue summary: View changes
clemens.tolboom’s picture

The medium post by @bucefal91 in #12 looks great to reuse here. For relationship we need an extra table.

So maybe we could better change to the tables done by @bucefal91 and take over his code?

@bucefal91 I'm not sure I can take your code in here as there is no license. I guess you can but not sure.

Status: Needs review » Needs work

The last submitted patch, 13: examples-views-1883760-13.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

clemens.tolboom’s picture

Wow ... 8 days waiting ... weird.

@bucefal91 any thoughts?

bucefal91’s picture

@clemens.tolboom, hey!

Ufff :) I've been on a tight schedule since May finishing a project, so I didn't really follow activities on issue queues of d.org. Hence my belated response.

Definitely take my code samples! I wrote that series exactly for that purpose - for the purpose of education and helping others. If somebody considers it useful enough to base views examples on it, that'd be just awesome! :)

I cannot promise I will do adapting myself in the nearest month or so because I am still not through with that project on my work, but if time allows me and nobody else has done, I'll be happy to de it myself too.

rcodina’s picture

Patch on #13 just helped me a lot. Thank you all!

jungle’s picture

Version: 8.x-1.x-dev » 3.x-dev

3.x-dev is the default branch right now.

clemens.tolboom’s picture

@jungle can you please 'explain' why/how this version came into life. Preferably to a d.o CR link :)

jungle’s picture

@clemens.tolboom, thanks for asking. FYI:

Which branch?
Current development goes in 3.x branch, that is aimed to work with core version 9.1+

Other supported branches are 9.x-1.x (core 8.9 and 9.0) and 8.x-1.x (pre 8.9)

Copied and pasted from the project page, no CR.

clemens.tolboom’s picture

Thanks ... I checked with https://www.drupal.org/project/examples/releases

examples 3.x-dev
By valthebald on 26 May 2020

So more info is available @valthebald ;-)

I miss the link with #d9readiness effort as to move this issue forward we have to install 9.1.x first :-/

@jungle can you add 9.1-x testing? And publish this 3.x branch on the project page?

jungle’s picture

  1. Re @clemens.tolboom, it seems that branch testing against 9.1.x is not available for contributed modules yet. See https://drupal.slack.com/archives/C51GNJG91/p1590569035429500

    @Gábor Hojtsy: Should be possible in a week if not already :)

    @jungle can you add 9.1-x testing?

    So instead of adding testing against 9.1.x, I did add testing with 9.0.x

  2. And publish this 3.x branch on the project page?

    Sorry, I have minimal maintainer privileges ATM, so unable to do it myself. But I will pass this message to @valthebald.

Thanks!

valthebald’s picture

Moving to new examples meta