You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Drupal 8:联系内容类型关联反馈表单及页面配置咨询

Hey there! Let's work through your two options for integrating the contact form with your custom contact content type in Drupal—both are totally doable, so let's break them down clearly:


Option 1: Embed the contact/feedback Form Directly Below Your contact Content Type's Body

If you want the form to show up automatically on every contact type node right below the main body content, here's how to do it with core tools (no extra modules needed):

  • First, make sure the core Contact module is enabled (head to Structure > Modules and check the box next to Contact if it's off).
  • Turn your feedback contact form into a block:
    • Go to Structure > Blocks > Place block, search for "Contact form" and find your feedback form's block entry. Click "Place block".
    • In the block settings, jump to the Visibility tab. Under "Content types", only check your custom contact content type—this ensures the block only loads on those nodes.
    • For the Region dropdown, pick the region that sits right below your content body (this depends on your theme, but common options are "Content bottom" or "Post content bottom"). Save the block configuration.
  • If you need more control over exactly where the form renders (like embedding it inside the content flow instead of a fixed region), you can use a custom template:
    • Create a template file named node--contact.html.twig in your theme's templates folder.
    • Add this Twig code wherever you want the form to appear (typically right after the body field):
      {{ drupal_form('Drupal\\contact\\Form\\ContactForm', 'feedback') }}
      
    • Clear your Drupal cache, and the form will render exactly where you placed it in the template.

Option 2: Add a Managed HTML Block Above the contact/feedback Form Page

If embedding the form directly on the contact node isn't feasible, you can easily add and manage custom HTML content above the standalone contact/feedback form page:

  • Create a custom HTML block:
    • Go to Structure > Blocks > Add block, select the "Custom HTML" block type.
    • Fill in a title (you can choose to hide it on the frontend if needed) and your desired HTML content using the rich text editor. Save the block.
  • Place the block on the contact/feedback page:
    • Go back to Structure > Blocks > Place block, find your new HTML block, and click "Place block".
    • In the Visibility tab, select "Pages" and enter contact/feedback in the text field—this restricts the block to only show on that exact form page.
    • Choose a region that appears above the form (like "Content top" or "Page header", depending on your theme) and save the settings.
  • To edit the HTML content later, just head back to Structure > Blocks, find your block, and click "Configure"—you can update the content anytime without touching code.

内容的提问来源于stack exchange,提问作者The Old County

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:39:17