基础篇21. 模板中的变量,devel kint,html模板

龺龶龵龴龲龱龰龭龬龨龦龣龠龟龛龨Drupal龊龆龅龄龃齿齾齼齸龰齶齲齯齮齫齩齦龛齤齢齞齝齙齕龰齔齓齑齎龛齊齆齄齂龰龬鼾鼻鼺龛鼷鼶齕齿鼴鼲齢鼮鼬鼫齄齂鼩龛鼧鼤龛鼢鼡齕鼞鼚齔齓龠龟龛鼗鼗鼔鼑鼎鼊鼇鼫鼅鼂鼁鼗黾黽鼎 龵黼

鼫齩黻龰黷齿鼩龛黳黯黫黧黽黦黤黡黠黟黛黙黖龛黳黯黔黾黦黤龰黑黐龱黍黌html麿麽龛黔黾黖龱麼龅CSS黟JS鼎麶麴麰龨齊HTML龱黛黙麡麝龛CSS黛黙麙黐龛JS黛黙麖麔麑麐麍齑麌麋黼龛麊麔黻麇麄麂麀龛黳黯鹾鹺鹷鼅鹳鹲鹱鹮鹫鹨鹤黽龛鹢鼅鹳鹲鹱鹞鹚鹖鼫鹒龰鹎龛鹌麴麰鹉鹇鹅鹂龲龠龟黽鼎鹀龨龠龟龨鸿鸽龱龰鸹鸷鼅齦齿龛黳黯鸴鸰鸭鼅齲鸩龆鼎

黡黠鼩龰黌鸥

鼫鹉齦齿鼩黳黯黦黤黽page黡黠龛鼴鼫鸞鼩鸜鸚黽齦麖鸗鸔龛鸑鹇龨齦鹷h1麿麽鼎鼫鼅鹷h1麿麽鼩龨黳黯鸍鸉鸆龅龰齔鸃龠龟鷿hello drupal鷵鼎鼅齲齔鸃鹇龨黳黯鸜鸚鷴麴麰鹉龰龠龟鼎

黳黯鼫黦黤黡黠龰鷱鷭龛鼴鷪鷩鹫鼅鸽鷨龛鼧麔鼅鷦鷿黤鷤鷵鼫黡黠鼩龰龠龟龛龨鷡鷝鷛鷚drupal鷗鷔龱鷒鷑黟鷎黍龰龛鷊鷆齸鷎黍龛鷅鷃鷀鶿鶼鼅齲黡黠齔鶹鼎麶drupal麊麔齦齲CMS麑content management system黼鸑鹇龨龠龟鷒鷑鷗鷔龛鶱龰麊鷚鹇鼫齆鸴鶮鷦龠龟鶫鶧鼫鶣鶠黖鼩龛鶝鶛鸴鶗黯鶕黌鸥龰鶑黐鸆鼮鷴麴麰鹉鼎

鶍鶕龛鶉黳黯鹢鼅齲鷿hello drupal鷵龰齔鸃黍麔齦齲黌鸥龛鼫黡黠齔鶹龰鶈鶄鼩龛黳黯鶂鶕鵾鷴齶齲鼫page黡黠鼩鹫鷚龰黌鸥龛拷鵺鸞鼩齦齲龛齞鷊 logged in 鵸鵶鷿hello drupal鷵 鼎 龭鹷鵳鵲鵮龨twig鷚龱鸆鼮鵩鵨黐麡鷆龰龛鵧齆twig龛黳黯鶕鶛鵤鵡鵞龄黫鼎

鼅龨齦齲鵝鵛鵗鵖龰黌鸥龛鷚齆鵓鵏鷚鵌龨鵋鶈鵇鼴鵃鵂鼎黳黯鼬鼫龨鵃鵂鴾鴽龛鼧鼤龛鼫麴麰鴼鴺鸆鼮龰龨1鼎

鶈鶄鼩鴶鼮龰鴳鴳龨page黡黠鼩齾鹫鷚龰黌鸥龛鹖鼤齩鹒龛鵤齢齦鹳鸞鶗龰黌鸥鶂鶕鷛鷚鼎鼅鹳黌鸥齢龰龨齊Drupal鴯鴫鴧鴣龰龛齢龰龨鼧麔鴠鴟鴞黽鸞鶱黡鴜龛齊鼅鹳黡鴜鴧鴣龰鼎

devel kint

鶝鶛龛黳黯鼫黡黠齔鶹龰鶈鶄龲黑龛鸗鸔龰鴼鴺龛鸜鸚齦齲鴕鴔龛鴠鶂鶕鼫齔齓鼩鴑鷴鼅麖鴐鴌鼎

{{ kint() }}

鼅齲鴕鴔龨齊黳黯鼫鴂14齿鶍鴟鴞龰devel kint黡鴜鴧鴣龰鼎鶱鶂鶕麔黳黯鼫麴麰鹉鳻鳸黡黠鼩鶍齢龰黌鸥鼎鼫鷛鷚鶱齩黻龛鴠鵤鳴齸鳱鳮twig debug鳪鳨鼎鵧齆鼅齲龛黳黯鼫鴂11齿鼩鳤鳡黾鼎

kint鼫麴麰鹉鳞鳚黽齦齲鳙鳗龛齫鳖鳕鳱鶕鶛龛鴠鶂鶕鵾鷴鶍齢龰黌鸥鶕鳑鶱黯龰鳐鵧鳏鳌鼎

鼅鼂龰page龨齦齲鶣鳉龛鳕鳱齩鶛鴠鶂鶕鵾鷴鼅齲鶣鳉鼩龰鳈鳇龛鸞鼩齢齦齲title鼎

鼫鼅鼂龛黳黯鹢齩黻龰logged in 鵸鵶麔 page title 龛鶱龰黤鷝鳃php鼩鶣鳉龰黤鷝龨齦鲿龰龛鴠鶂鶕鲼鵾齔齓鼩龰鸗鸔鼎

<h1 class=“v1”> {{ page['#title'] }} </h1>

鶫鶧鶛鲡鲝鲜鲛麴麰龛鶂鶕鵾鷴龛鲚麴鼧麔鼲齢麿龆龛鼧鼤龛麴麰鴼鴺鼴鼲齢鸆鼮鼅齲黌鸥鼎鳕鳱kint鳞鳚龰鳙鳗龛鴑鷴page鼩龰title龛黳黯鶂鶕鵾鷴鼅鼂龨齦齲鼇鸃鲗鲓鼎

黳黯鲑鵶鷴齔黷麴麰龛麴麰鴼鴺齼鲎鳻鳸黽龭鲝麴麰麿龆龛鸞鼩龰鴂齦齲龛鲋龨黳黯鸜鸚龰鼅麖鸗鸔龰麡鷆鼎鳕鳱kint鳞鳚龰鳙鳗龛鴑鷴page鼩龰title龛黳黯鶂鶕鵾鷴鼅鼂鲈鳡黽鳐鹾龰鳏鳌鼎

鼧鼤龛鲆鲂twig debug黡黐黟devel kint龛黳黯鶂鶕鷛鷚kint鴐鴌龱鳻鳸黡黠鼩鶍齢龰鶂鷚黌鸥龛鶕鼤龱鴑鷴黳黯鶍鳴齸龰黌鸥龛鼴鸴鶱黯鼫黡黠鼩鳻鳸鼮龱鼎

鼫鱾齿齄齂鼩龛黳黯鴳鴳鳕鳡黽鼫page黡黠鼩鷛鷚kint龱鳻鳸黌鸥龛鴠鵤鶂鶕鼫鸞鶗龰黡黠鼩龛鷛鷚鵗鱼龰黑鷝龱鲼鵾鶗黯鶮鸍鶂鷚龰黌鸥鼎

齾鶛龛鴠齸鶈鱺龰龨龛鼅齲kint鳞鳚龰鳙鳗鱷鱴龰鸚鵮龛齦鱱鱭鱫龲龛鷪齸齫鳖鼎鼧麔龛鼅齲鱩鱨鵡鳕鳱鼅齲鳙鳗龰鱦齦鱥鼎鼅麙龛鱣鱣鵡鱟鲿麴麰鱛鷤鼎

html.html.twig黡黠

齩黻黳黯鳻鳱黽page黡黠龛鼴鹷鶗鷨黽鷎黍鼎

鼅鼂黳黯鲡龱鵾齦龲html黡黠鼎鼅齲黡黠龰鸗鸔鼷鱗龵

{#
/**
 * @file
 * Theme override for the basic structure of a single Drupal page.
 *
 * Variables:
 * - logged_in: A flag indicating if user is logged in.
 * - root_path: The root path of the current page (e.g., node, admin, user).
 * - node_type: The content type for the current node, if the page is a node.
 * - head_title: List of text elements that make up the head_title variable.
 *   May contain one or more of the following:
 *   - title: The title of the page.
 *   - name: The name of the site.
 *   - slogan: The slogan of the site.
 * - page_top: Initial rendered markup. This should be printed before 'page'.
 * - page: The rendered page markup.
 * - page_bottom: Closing rendered markup. This variable should be printed after
 *   'page'.
 * - db_offline: A flag indicating if the database is offline.
 * - placeholder_token: The token for generating head, css, js and js-bottom
 *   placeholders.
 *
 * @see template_preprocess_html()
 */
#}
<!DOCTYPE html>
<html{{ html_attributes }}>
  <head>
    <head-placeholder token="{{ placeholder_token|raw }}">
    <title>{{ head_title|safe_join(' | ') }}</title>
    <css-placeholder token="{{ placeholder_token|raw }}">
    <js-placeholder token="{{ placeholder_token|raw }}">
  </head>
  <body{{ attributes }}>
    {#
      Keyboard navigation/accessibility link to main content section in
      page.html.twig.
    #}
    <a href="#main-content" class="visually-hidden focusable">
      {{ 'Skip to main content'|t }}
    </a>
    {{ page_top }}
    {{ page }}
    {{ page_bottom }}
    <js-bottom-placeholder token="{{ placeholder_token|raw }}">
  </body>
</html>

鼫鼅齲黡黠鼩鸆鼮黽DOCTYPE鰠html鰠head鰠body麿麽龛鼅鹳龨html麴麰鶍鷪鶂鰜鰚龰鹲鹱鼎鶝鶛鵤齢齦鹳黌鸥龛齞鷊鷚齆鸆鼮麿龆鰠css黟js龰黌鸥龛鷚齆鸆鼮麴麰黡黠龰黌鸥page鼎鼅鼂龰js龛鵡鰙鶠黖鼩龰鰘齎龱鵓鵏鹾鹺鸴齔鶹鰔鼫麴麰龰鴼鴺head麿麽鼩龛鵤龨鰔鼫麴麰龰鰓鴺鼎

{{ page }}

鼅鰑鴕鴔鷚齆鸆鼮鰐鰍鼫html黡黠鼩龰page黡黠鼎

{{ page_top }}
{{ page_bottom }}

鷚齆鸆鼮麴麰鹉黑黟龲黑鰉鸚龰鳙鳗龛齞鷊黳黯齩黻鴧鷴黾龰鷒鷑鰅鵃鰄齩鶛龛鼫麴麰鴼鴺鲈鳡龰鷒鷑鰀鯾鹇龨鯻鼅鼂龰page top鸆鼮龰鼎

麶page黡黠麑page.html.twig黼龛鷅鷚龱鸆鼮body麿麽鼩龰鯺鴺龠龟鼎

本书共66小节:

评论 (写第一个评论)