// This template is for a topic that covers how to perform a task. // // To use this template: // - Copy it to your source directory with a new name, in noun-verbing.txt // format, such as "block-creating.txt". // - Follow the instructions that are contained in lines starting with // // throughout this file. // - Replace placeholder text with your content. You may need to remove // sections that do not apply. // - Before you submit your topic, remove all the lines in the file that // start with // -- these are comments that do not belong in the topic. Also // remove any blank lines that are before the ID line. // This next line is an ID, which should be left alone. [[block-create-custom.txt]] // The topic title goes on this line. Use "Title Case" for topic titles. === Creating a custom block // - Replace the text in (((Nouns,verbing))) with an appropriate index entry, // such as (((Blocks,creating))). You can add additional index entries if // appropriate. // - Also remove the // before the ((( so that this becomes an index entry // and not a comment. //(((Nouns,verbing))) ==== Goal // Describe the goal of this task here. Describes how to create a custom block to display custom widgets, HTML, or other snippets of content ==== Prerequisite knowledge // This section should mostly link to topic and concept tasks within // the guide that someone would need to understand before trying this task. // Some of the entries could be background knowledge that is needed that is // not covered in the guide. // // Some ideas (remove the // to make these not comments): //* <> //* <> //* How to upload files from your local server to your web server. <> ==== Site prerequisites // The items below are an example of what might go here for a task where // a "most recent image" view is created. They describe things that must be // present on the site (configuration, content, etc.) in order to perform // this task. // // Some ideas (remove the // to make these not comments): //* A content type is defined with an Image field. See <>. //* At least one published content item of this type exists. See // <>. The creation of a custom block is a core function of Drupal and only requires appropriate permissions. You will need either to be part of the Administrator Role or to be granted the "Administer Blocks" permission. ==== Steps // This is where you describe the actual steps needed to perform this task. For this tutorial we will create a simple "Hello World" block that can be displayed in any of the regions [start=1] . Navigate to the Block Layout Administration page to create a custom block Click Structure in the Administration menu then click Block Layout On the Block Layout page click the "+Add custom block" button located above the regions [start=2] . A custom block requires only the "Block description" field, but filling in both the description and a body is most common. Type in the following: Block Description: "Hello World Block" Body: "Hello World!" . Click Save [start=3] . Place your block on a page. A newly created block will not appear on your website until you place it within a region. Do this by following these steps On the block layout page located the filter text box on the right side of the page. Type "Hello World" in the Filter box. This will help you quickly find your block (Alternatively you can locate your block under the "Custom" category) Click the block's title to open the "Configure block" page Select the region of the page you would like the block to appear. For information on Regions please read Block Regions section <> Click Save to save the configuration (Tip: If the block doesn't immediately appear in the appropriate region it may be cached. You can either wait for the cache to be refreshed or manually refresh the cache in the Performance configuration located at Configuration -> Performance --> Clear all caches in the Administration section) ==== Follow-on tasks // In this section, you can make cross-references to other task topics in this // book that are related. You can also make suggestions for tasks that someone // who just learned this task might be able to do that are not in the book -- // try to think of tasks that would help someone solidify and broaden their // skills and knowledge. // // Some ideas (remove the // to make these not comments): //* <> //* Brief description of another task not in the book. Editing your custom block All custom blocks appears in the "Custom block library", which is accessible by navigating to the Block layout page and clicking on the "Custom block library" link at the top of the section. Once on the page find your custom block and click the edit link to the right of the Block description. Similar to editing content you may choose to save a revision of your block. ==== Additional resources // In this section, make a list of outside references: videos, Drupal.org // documentation, etc. https://www.drupal.org/documentation/modules/block