on this page
https://www.drupal.org/docs/7/api/theme-api/overview

the 2 code samples at the top show 2 different ways to use theme api

in the second one the name of the theme being use (form, pager ect) appears twice
both as the name of the array ( $build['table'] ) and as one of the key value pairs stored by this array (array(
'#theme' => 'table', ..... );)

why is it necessary to mention the fact that it is a table twice?

also, does the theme API work the same in D8

Comments

sprite’s picture

D8 theming is completely different from D7 theming.

D8 theming uses the twig framework:

(twig framework information)
https://twig.sensiolabs.org/

(D8 theming documentation)
https://www.drupal.org/docs/8/theming

spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...

sprite’s picture

Learn by reading the documentation and by studying existing code from a good D8 theme, like the following:

(download the D8 theme for study)
https://www.drupal.org/project/showcase_lite

(get full theme site distribution from github for study)
https://github.com/morethanthemes/showcase-lite

spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...

megaman7’s picture

I was not talking about themes

I was talking about the theme API
I believed these to be different things.

Themes are like templates with a combination of static html, regions (or twig tags in D8) and various variables drupal provides.
theme API can be used to make a range of front end objects such as forms. these would be inserted into a region.

my question only concerned theme API

sprite’s picture

The answer to your question involves interconnected concepts, how the D8 theme APIs interact with a theme and/or forms.

The link below is to the theme API section of the Drupal 8 APIs documentation, which you could easily have located yourself.

Drupal 8 theme APIs api.drupal.org

As noted in my prior responses, you also need to learn the twig framework, which involves another API and language.

To understand the above, as I suggested, you should study the excellent example Drupal 8 theme I linked to, to see how all the foregoing works within a theme implementation, and how various forms would interact with a theme using the them APIs and other interfaces. There are many components to a Drupal 8 theme, all of which require understanding multiple APIs and languages including but not limited to:

php
twig
css
html
yaml

about which a thorough knowledge is needed to properly utilize the Theme APIs to interact with the architecture.

https://api.drupal.org/api/drupal/8.3.x

spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...