By tomgf on
I am using CCK, Views and Views Attach to create a parent <-- children relation.
On the parent page I have a view with Title, Body of any child.
I am trying to add a ‘Edit’ link beside the Title of any given children (easily done adding a Edit link field which “Provides a simple link to edit the node.”).
My proble is that I want to have this link visible ONLY for certain roles (editors and so).
How could this be achieved? Adding an if… then… clause to the .tpl.php file is the best approach…?
Thanks for any advice!
Comments
I found an easy way to do
I found an easy way to do it.
In template.php:
The only problem is that this is working from the second value on… somehow the first value on the array is untouched!
did you solve this further ?
interested also in strategies for only showing field in view to selected roles.
> The only problem is that this is working from the second value on… somehow the first value on the array is untouched!
Did you figure out why and solve this ?
Webel IT Australia, "Elements of the Web", Scientific IT Consultancy,
For PHP-driven Drupal CMS web sites, Enterprise Java, graphical UML, UML Parsing Analysis, SysML, XML.
I tried
I tried unset($vars['fields']['field_id']); instead and it seemed to work for the first value too.
in drupal7 preprocess
in drupal7 preprocess function is called but it does not unset the fields
anyone knows why ?
and
$vars['fields']as mentioned above is not passed to the preprocessEDIT
creating a module and hooking into views_pre_render works nice though
------
GiorgosK
Web Development
Hmm - I'd edit the view and
Hmm - I'd edit the view and take the template suggestion for that field (under Theme:Information) and try adding the logic there. The tpl will end up being something like: views-view-field--edit_node.tpl.php. You can copy and paste the default code, then edit it with your if statement around it.
I'm not sure if that will solve the problem or not -- just a different way of doing the same thing, I think.
Amanda
per-role access Page "trick" in Views
Recommend read tip from merlinofchaos at: #755956: Is it possible to control display of specific fields by permissions or role within a view result ?
Webel IT Australia, "Elements of the Web", Scientific IT Consultancy,
For PHP-driven Drupal CMS web sites, Enterprise Java, graphical UML, UML Parsing Analysis, SysML, XML.
How do I show a specific field in Drupal 8 only for admins
I found the 'user role field' module. Unfortunately for 7 only.
How do I show a specific views field only for admins in Drupal 8?