2

In my node I have embeded a view using php snippet in body field. When regular user edits it I don't want him to accidently delete the snippet, is there a way to hide or lock that part of the text from that user so no matter what he does the snippet will remain there? Should I add a custom field just for it or are there a better options? Also note, that the snipped could be placed in the middle of the body field content.

Thanks!

  • in your body field right? – Bala Dec 15 '14 at 8:17
  • yes, in the body field – Reinis Dec 15 '14 at 8:18
  • check this out drupal.org/project/defaulttextfornode but it don't have privileges – Bala Dec 15 '14 at 8:25
  • 1
    seems good, but the problem is I want to be able to to choose the placement of that snippet(above or below the body field) – Reinis Dec 15 '14 at 8:31
3

No, there are no ways to do this. And there shouldn't be. First of all, read PHP in database: bad practice but - this addresses exactly the situation you have here. Long story short: don't do it. Turn off PHP module if you don't need it.

And why you don't need it? Because there is Viewfield module.

Viewfield provides a field that holds a reference to a View and renders it whenever the entity containing the field is displayed.

Exactly what you want to do, but without any snippets in user editable texts.

  • @EverWondeR It might be a bit hard to set up, I admit, but it's worth it. Ping me in chat if you need additional help with it. Or ask a question, if it's something big enough to be worth it. – Mołot Dec 15 '14 at 8:38
  • @EverWondeR Glad it was easy for you. For me - I always need a manual and half an hour to get it straight ;) – Mołot Dec 15 '14 at 8:56
  • I know the feels, that was the same for me when I was dealing with taxonomy views firsthand. – Reinis Dec 15 '14 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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