1

In views (D7) i made a list of nodetitles that link to content. Some nodes are not accessible for anonymous users, others are. I want the view to list accessible nodetitles with a link but non-accessible titles without a link. How can i do that? I use content access for setting permissions on individual nodes.

What if i add two fields for Title, one with a link to content and one without. Both fields excluded from display. I can add a binary (or whatever works) field in my content type telling views if visitors should have access to an individual node. Nodes that allow access should (manually) be set open with content-access. That isn't the best way because it requires two edits for every node that should be accessible, but i don't mind.

Than i can make a Views-PHP field that tests on the binary field and either displays the first title-field or the second.

Anyone can help me with some rough coding example for this?

3
  • did you check if this is not handled by default.
    – arpitr
    Oct 16 '13 at 15:06
  • I did. By default, views only displays nodetitles of nodes you have access to. I want to show ALL titles, but only have links fot nodes an anonymous user has access to. When i disable SQL-rewriting i get the full list, with all links. Clicking a link i have no access to gives the errorpage.
    – caskraker
    Oct 16 '13 at 15:21
  • This is either going to be really difficult or probably not possible.
    – Beebee
    Oct 16 '13 at 16:03
1

I found it. I added a boolean field with Yes as the value for access, No for no access. This requires some careful management, as the value of this field has to equal the given access control. But in Views everything is very easy, using the extra boolean field. I added both Titles (Title1 being the one without a link, Title2 with link) and the boolean field. Both titles excluded from display, the boolean included. In its settings rewrite i input [Title2], and in the empty behaviour [Title1]. That's all.

0

You could use Views PHP module

First you would add the title field and additionally a path to the current node as well.

Then you can add a views php field and with in this field you can check the permissions for the current user or the role of the current user or any other logic you want to put. Then depending on the role either you can simply print the title or title with the link.

Another option would be to override the field template and do the same logic there. that is check the current role and if the role is not allowed to see the link then only print the title id they have the permission then print with the link.

You might want to set access restriction to none. (Should be careful with this one as all the permissions with in the view would be disabled. So all the quries would be run without checking the permissions.)

There are some gotchas. The module is in dev stage so should use the module with care. and using php should be done carefully. Unsecured code can damage the site's security.

1
  • I'm afraid this won't help me. I uase Views PHP for some other tweaks but have hardly any knowledge of PHP coding. Is there nothing else i can try? In the online courses business you see these kind of listings all the time.
    – caskraker
    Oct 17 '13 at 8:22

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .