Closed (fixed)
Project:
Entity Pager
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
18 Apr 2017 at 17:12 UTC
Updated:
18 Nov 2017 at 01:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
rv0 commentedCoincidently, I wrote something for this yesterday:
Comment #3
replicaobscuraNice! I like it, going to get this tested and committed ASAP. Thanks!
Comment #4
chriswingerThe patch works, mostly, but on the first and last articles in the pager I get:
Comment #5
rv0 commentedI'll have a look at it later today
Comment #6
rv0 commentedThat should do it. Rerolled against latest dev
Comment #7
chriswingerPatch in #6 worked for me. Thanks!
Comment #8
chriswingerComment #9
chriswingerActually, I noticed a problem with the patch (both of them actually). If you have the 'Display Count' option checked you will get the error:
Fatal error: Call to undefined method Drupal\entity_pager\EntityPager::t() in /modules/contrib/entity_pager/src/EntityPager.php on line 203Comment #10
chriswingerComment #11
chriswingerThis should fix the translation error.
I also also changed this so that it will always attempt to detokenize the link. If we don't do this, links on first and last pages would show the token markup.
Comment #12
chriswingerComment #13
Station.ch commentedChanging to my user.
Comment #14
s_leu commentedNot sure about changing this
Not sure about this change. Actually it's a good idea to use an injected string translation service for this. But this would require to convert the class into a service first, which would make sense in order to allow re-using the code with dependency injection I suppose.
Besides there's some other things missing/wrong in the code of the module. For example, there's a template but no corresponding implementation of
hook_theme().The last patch fixes the fatal error but is not a clean solution IMO. Some test coverage for the token resolving and the general working of the module would be great too.
Comment #15
s_leu commentedAdding a new patch that keeps using $this->t() instead of t.
Looking at the class, probably also the token service should not be used by calling \Drupal::token() but use an injected service instead, which would require to create a factory for the EntityPager objects. It's out of scope here a followup for this would sure make sense, along with the other issues i mentioned in the last post.
Besides this, there's quite some coding style issues that should be fixed as well.
Comment #16
s_leu commentedComment #17
replicaobscuraThanks for the effort, and the patch!
I will give the latest patch a test and get it committed ASAP if it looks good. Also, I noted your other comments about the other mentioned issues, as well as code style issues, and will handle those separately (unless there are already issues for them).
Thanks again!
Comment #19
replicaobscuraThanks everyone! I committed a change similar to s_leu's last patch, credit given to s_leu along with mentions of everyone else that's contributed to this issue.
Comment #21
ericshell commentedCurrently having trouble with this feature:
1) With just the alpha 2 release I get this error on initial config of a view:
Notice: Undefined index: next_prev in template_preprocess_entity_pager() (line 34 of .../contrib/entity_pager/entity_pager.module)
2) With the alpha 2 release and patch from #15 I get this error:
Notice: Trying to get property of non-object in Drupal\entity_pager\EntityPager->getLink() (line 182 of .../entity_pager/src/EntityPager.php)
3) With the latest dev release (+5) that appears to have a similar addition for the use of tokens I get this error:
Notice: Undefined index: next_prev in template_preprocess_entity_pager() (line 34 of .../contrib/entity_pager/entity_pager.module)
Currently on 8.3.5. It looks like I get the errors 1 and 3 until I turn off the All Link, remove the link and title from textfield, and turn off the Count settings. Turning them back on seems to work fine afterwards (at least for the preview). Will continue to look into this and post any additional info I can find.
Comment #22
Mytko Enko commentedAfter enabling dev-mode module (with patches included?) seems to work fine on node page, but completely crashes home page:
Fatal error: Call to a member function getEntityTypeId() on a non-object in /home/r2jmq/www/modules/entity_pager/src/EntityPager.php on line 238Comment #23
replicaobscuraericshell and Mytko Enko, are both of these issues only related to using tokens in the link titles, or are these general issues you're running into regardless whether you use tokens? Trying to determine if this issue needs to be re-opened, or if a separate one should be used.
Comment #24
firfin commentedI think ericshell's issue is probably related to this issue, as he is having difficulties with alpha2 version also? Also my problem is not directly related maybe, but I am not getting the desired result using tokens with entity_pager (dev-1.x a73eadd)
No errors but tokens don't seem to get replaced? I am trying {{title}} and [title]. Neither work, what are tokens that can be used?
Also still having this problem when trying a non-token string. As in #2920753: Changing labels has no effect
Comment #25
plusproduit commentedHi,
I just updated to latest dev because of https://www.drupal.org/project/entity_pager/issues/2900996
Now the tokens don't work in next/prev links.
The patches in this issue don't seem to apply to latest dev (dec 8 2017). Any help would be appreciated!
EDIT:
Sorry I just realized that the tokens are not views replacement tokens, so now I use [node:title] instead of {{ node:title }} and it works like a charm