Themeless

Component ID

2912160

Component name

Themeless

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

62

Component created

Component changed

Component body

Themeless entity output (only nodes for now) in JSON, XML or HTML format on the path 'node/%/themeless' and 'some/alias/themeless'.

Only a stripped down node template is used by a distinct display mode 'Themeless' to be rendered, effectively only showing the fields without the page template. Therefore no headers, footers or sidebars or menus are shown but only the node content. No theme at all.

JSON and XML can be consumed by other applications for example a mobile app.

Use the HTML output to embed Drupal content for example within an iFrame. In that case only the field templates are used.

Other advantages

  • Designed to be used in tandem with the TableField module but not necessarily.
  • Possibly a basic DoItYourself API builder for webmasters.
  • No risk of formatting errors by editors as opposed to if they would create JSON or XML in a text field.
  • Quick creation of mock data as a service to test an application with.
  • Being a distinct display mode you can enable and configure themeless rendering per content type without any impact on for example the 'Default', 'Full' or 'Teaser' view modes. It can include other fields and in a different order.
  • If a visitor can't access the node, it can't access the themeless version either. You can extend that refusing anonymous access in addition to the regular node access check. One can see the regular node but not the themeless version.

Get started

  • Enable the Themeless display mode per content type under the Default view mode in the section CUSTOM DISPLAY SETTINGS at admin/structure/types/manage/[your-content-type]/display.
  • Select the format at the bottom of admin/structure/types/manage/[your-content-type]/display/themeless.
  • Choose the desired fields and field settings moving them from Hidden.
  • Save.
  • Visit a content page at ../node/%nid/themeless or ../some/alias/themeless.
  • Set which roles have the permission 'View Themeless tab'.

Extend

  • To have more nested levels in JSON/XML use the TableField module.
  • Refuse anonymous access in addition to the regular node access check. In that case a consuming application should make an HTTP request as an authenticated user. To allow for basic authentication enabled HTTP requests you would need a module like Basic HTTP Authentication.

To keep in mind

  • Works currently only for nodes (for now).
  • For the HTML output any type of field is rendered. For JSON/XML output it works with fields that output as text (for example also select) and a TableField.
  • A TableField needs to be configured with a corresponding JSON, XML or HTML format at /admin/structure/types/manage/[your-content-type]/display/themeless.
  • URLs with aliases are accessible for the themeless output, e.g. ../my/custom/alias/themeless.
  • It is unlikely you publish links to a themeless version of a page (based on permission users don't see a Themeless tab). They are therefore not found by a web crawler. Add Disallow: */themeless in the robots.txt file found in the root of the Drupal install just to make sure themeless pages are not indexed by Search Engines.