0

I need to know if there is a way to create a content type and within the content type to create a field which this field should be segment.

For Example :

at the beginning i will have an image, this will be the default image. and in case i will choose an option like to display only for authenticated user another image field will be opened , and in the display all unauthenticated users will see the default image and authenticated users will see the second image.

Is there something like this ?

Thanks

2
  • are you using 7 or 8?
    – Amy
    Commented Jun 27, 2016 at 16:41
  • I am using on 7 But i will be glad to hear also about 8 Commented Jun 27, 2016 at 17:40

1 Answer 1

0

You can create a template for that specific content type like

node--yourcontenttype.tpl.php

and inside you can check for the user roles like so

// Load the currently logged in user.
global $user;

// Check if the user has the 'editor' role.
if (in_array('editor', $user->roles)) {
  // print one image
} else {
  //print the other one
}
1
  • But in this situtation if i have multi segmentation the ui will be very long. Also in case i am pulling this data in a view i need to create a nother template for that view Commented Jun 28, 2016 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.