0

I have a drupal 7 site I inherited to manage. There is a view I can edit at /newsletters#overlay=admin/structure/views/view/newsletters/edit and it has a section titled "header" that I can't figure out how to enable for translations. The section below it,"content", is showing up properly translated on the front end. view editing example

The menu for Header looks like this:

enter image description here

Clicking Edit Global: Text area reveals this:

enter image description here

What do I have to do to translate this and display it properly?

1
  • A quick alternative would be create a simple custom block and display it above where you view is shown. Then its easily translated via a block
    – Leigh
    Commented Dec 15, 2017 at 17:01

1 Answer 1

0

The "global" header and "global" footer built in Drupal Views isn't treated as a separate translatable entity like a node is.

One recommended approach (that will also avoid giving content managers access to edit views) is to setup a single custom content type for view headers and footers and then with the Entity API module enabled, set/embed an entity reference to the specific node in the view header (and/or footer). A breakdown of steps for this approach is below:

  1. Make sure your site has the Entity API module installed and enabled.
  2. Create a custom content type (it can be just a body field and title. NOTE: the title will render in the embedded entity in the view, so you may want to utilize it for the view page title/H1 in lieu of the specific "title" field on the specific display of the view. Otherwise you can preprocess the node type to exclude the title or use css to hide it.
  3. Enable internationalization/translations for the new content type.
  4. Create a node for each specific view header or view footer where you need manageable/translatable content, noting the node ID upon save.
  5. Export a backup of the views impacted.
  6. Edit the desired views; be sure to be editing the specific "view display" that applies to your block or page. In the "Header" or "Footer" section of the view edit/config page (where you currently have a global textarea), click "ADD".
  7. In the modal, make sure the selector in the top left corner is set to apply changes to "This Page"/"This Block"/etc and not "All Displays". Select Entity: Rendered Entity and click Apply (this display). Embed Entity into View Header or Footer
  8. Input the node ID and choose the desired display mode (full node should suffice as outlined, unless you need a custom display mode setup on the node/content type).
  9. Remove the Global Text object in the View Header or View Footer. After applying this change (and assuming you have no other custom objects in the view header or footer), you should only see the referenced entity in the View Header or View Footer section. Embedded Entity
  10. Save and test the page where the view appears.
  11. If you decide to revert, import the backed up copy of the view as Admin1 to restore it.

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.