Closed (fixed)
Project:
Recently Read
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 Apr 2018 at 14:42 UTC
Updated:
15 Mar 2022 at 04:58 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
nkoporecCreated a patch which adds plugins support.Created basic plugins (node,user,taxonomy_terms).Under configuration, you can select to enable certain plugins.Also changed some functionality so that the module can track any enabled plugin.To add support for new entity just create a new plugin with plugin id(tracked entity id) and label then enabled it the configuration.
Comment #3
useernamee commentedHey,
I have tested your patch. It applies and works. However it adds another step at enabling entity type for recently read (first you have to enable plugin then you have to enable it in list '/admin/config/system/recently-read'). This might be a bit counterintuitive. I've also tried to add poll as plugin. I have created new custom module with Poll class in 'my-new-module/src/Plugin/RecentlyReadType' and it was show in configuration afterwards.
However I did not menage to show recently viewed polls in views block. This might however be separate issue since I didn't find a way to show neither users nor taxonomy_terms which are already recognised via recently read type manager.
Comment #4
a.sinitsa commentedTest patch with commerce 2 products. Works as expected.
Comment #5
a.sinitsa commentedTested on three different projects
Comment #6
mbatterton commentedThanks for the patch @nkoporec this is just what I am looking for but I can't get it working. I have used composer to install the dev version and added the patch which has gone smoothly, but I don't see how @a.sinitsa has been able to get this working with commerce 2. I don't see "Products" listed in the list of Plugins. Please, can you advise what I am missing?
Comment #7
nkoporec@mbatterton after applying the patch, you must create a plugin for commerce(for example you can see how taxonomy, node or user plugins are made). The patch doesn't contains the commerce plugin by default you must create it yourself.
Comment #8
a.sinitsa commentedHi @mbatterton!
You should create new module Ex. recently_read_products with Commerce_product.php inside recently_read_products/src/Plugin/RecentlyReadType/
with this code:
Comment #9
mbatterton commented@nkoporec and @a.sinitsa thank you, guys. This is exactly what I need thank you for getting back to quickly.
Comment #10
kmajzlik commentedi am unable to apply against 8.x-1.0 :-(
Comment #11
bgronek commentedLikewise. Unable to apply this patch.
Comment #12
bgronek commentedIt looks like this patch needs to be re-rolled against the current 8.x-1.0 version of this module. Changing status to "Needs Work".
Comment #13
nkoporecThis patch still applies to the 8.x-1.x-dev.Patches should apply to dev(8.x-1.x-dev) branch and not to the release branch(8.x-1.0).
If you want to use this patch, clone the dev(8.x-1.x-dev) branch of the module and apply it.
Comment #14
bgronek commented@nkoporec My bad. Thank you!
Comment #15
introfini commentedThe patch seems to be working, but I can't seem to add the relationship to the views block when the base table is Products.
Am I missing something obvious or the patch doesn't have it yet?
Thanks!
Comment #16
nkoporec@introfini this patch does not create a relationship. It provides a plugin system so you can create your own plugin for a custom entity. In order to track products, you need to create a new plugin (via a custom module), see #7 and #8 comments.
The patch only contains plugins for node, taxonomy and user entities, but can be extended to any kind of entity you want.
Comment #17
introfini commented@nkoporec I understood that. I've the module with your patch and created a new plugin module as instructed in #8. This is what I have:
But from what I understood of the module in D8 it's needed to add a relationship "Recently read" like in the default /admin/structure/views/view/recently_read_content: When I try to that with a base table of Products (because my plugin is for Drupal Commerce products) no relationship of that type appears.
Do I need something more in my plugin?
Comment #18
bzoks commentedWhile testing patch #2 and trying to explain it's usage for @introfini, I realized that it does work with some adjustments and quirks, but it is only useful with further development (of plugins), just to fulfill a simple requirement of being able to track ANY Entity Type.
That's why I refactored it in such a way that Administrator can just tick checkboxes in a list of all (content) Entity Types and that's it... no need for custom plugin development. I tested it with core Entity Types (nodes, taxonomies), and also with module-provided Entity Types, for example, Product from commerce module.
I also developed an upgrade path from the 8.x-1.0 version and from the patch #2 version.
Comment #19
strozx commentedI have tested this and looked at the code and everything appears to be in order and working. Thanks, bzoks.
Comment #20
dunot commented> it's needed to add a relationship "Recently read"
> like in the default /admin/structure/views/view/recently_read_content
After #18 and run /update.php in module` recently_read_content view relationship will be "Broken/missing handler".
But you can add the relationship in any other views.
Comment #21
zterry95 commented@nkoporec
Thanks for your great works on this module. I have add you as module maintainer.
You can commit it to the latest code and make new release.
Cheers!
Comment #22
nkoporec@zterry95 Thank you!
Comment #23
nkoporecI have reviewed the patch from #18, the code needed some cleanup and certain bug fixes (as per comment #20), also the tracking was not working with media entity due to not using type in the views query, so I have converted the query to use bundle field instead.
Comment #25
nkoporecComitted to dev, please test it out and open a new issue if any errors appears.
Comment #27
tm01xx commentedI installed latest dev 8.x-1.1+7-dev. After installing I went to admin/config/system/recently-read/config to uncheck the default Content (node) then checked for Commerce product. I then went to here admin/structure/views/view/recently_read_content/edit/block_1 -> The views relationship is broken.
Comment #28
nkoporec@tm01xx The Recently Read Content view is meant to be used to render recently read content but since you disabled the Content in the recently read settings the view relationship will not be created. If you want to have a recently read commerce product then you will need to create a new view of Commerce products and add the relationship there.
Comment #29
sahilgidwani commentedThis patch is not working in Drupal 9.1.0 because in the RecentlyReadRelationship.php the following line of code is using the bundle column but the table actually has the type column. So I request to open the issue again so that the patch can updated and tested.
Code in the patch
$this->query->addWhere('recently_read', "$basetable.bundle", array_filter(array_values($this->options['bundles'])), "IN");Actual code should be
$this->query->addWhere('recently_read', "$basetable.type", array_filter(array_values($this->options['bundles'])), "IN");Comment #30
sahilgidwani commented