0

I have a view (block) created. When I modify the view block, I have only the field "block title" in the form. However they are 3 fields (block title, block description et block body) in a block of drupal (which I can create via /structure/block/add).

So my question is how can I add a custom field (like a textfield) to the form of views block? Is it possible to add it programmatically?

Thanks in advance.

  • why do you want to add the field? – 2pha Jan 28 '15 at 13:08
  • What's your purpose of doing it? – Ehsan Jan 28 '15 at 13:21
  • Views are only for viewing data (aka reporting data). So, if your aim is to make a view as an add/edit node form, it is not practically possible! – Ehsan Jan 28 '15 at 13:22
  • However it's possible to connect views to forms for showing some queried data. – Ehsan Jan 28 '15 at 13:23
  • @2pha @Ehsan because I want also a body field for my view block, without having to edit the view. If I have the body field for my view block, I just need to go to admin/structure/block/manage/views/[view_id]/configure, like the other blocks created by module block. – stevey Jan 28 '15 at 13:26
0

Views is used to pull in existing data/content from other nodes so that you can customise and display it either in new a page or block. There is no body field on the blocks page for a views block is because the contents of that block is controlled by the view and can change dynamically. So if you want to change the body text displayed in the view you can edit the body field of one of the content nodes your view is collecting from.

When I want to add extra custom text to a view I usually add a random field to the view and then inside that fields settings enable rewriting to allow rewrite the fields output with custom values, if you want to go a bit deeper you can use the module Views Custom Fields as another alternative: https://www.drupal.org/project/views_customfield, but as far as I know editing the body of a views block directly from the blocks admin page is not possible without writing some custom programming.

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.