I have created a block in custom block library, i need to render the block on all pages except home page.  Unfortunately I need to do it in twig file only because of ui issues if I enabled in the block layout UI  In twig file how can I render the block in drupal 8.  Thanks
122161
I try to embed a view in a specific node. I found tutorials for doing this with Drupal 7 and PHP-Templates:  &lt;?php print views_embed_view('view_name'); ?&gt;   But I look for a way in Drupal 8 with twig-Templates. I tried to call the views_embed_view() function in the hook_node_view() and assign it to the node so that I can print it out in the twig-Template. But it seems that this hook never gets called.  Any hints/solutions how to do this in the Drupal 8 way?
38380
I have an overwritten edit page for my custom object, which have different record types with different fields.  The simplified desktop version of this VF page looks like this:  &lt;apex:page standardController="CustomObject__c" extensions="CustomObjectCtrlExt" &gt;      &lt;apex:form&gt;          &lt;apex:pageBlock&gt;                       &lt;apex:pageBlockButtons &gt;                 &lt;apex:commandButton value="Save" action="{!save}"/&gt;                 &lt;apex:commandButton value="Cancel" action="{!cancel}"/&gt;                             &lt;/apex:pageBlockButtons&gt;              &lt;!-- Record Type 1 --&gt;             &lt;apex:pageBlockSection rendered="{!recordtypename == 'RecordTypeName1'}" &gt;                 ...             &lt;/apex:pageBlockSection&gt;               &lt;!-- Record Type 2 --&gt;             &lt;apex:pageBlockSection rendered="{!recordtypename == 'RecordTypeName2'}" &gt;                 ...             &lt;/apex:pageBlockSection&gt;               &lt;!-- Record Type 3 --&gt;             &lt;apex:pageBlockSection rendered="{!recordtypename == 'RecordTypeName3}" &gt;                 ...             &lt;/apex:pageBlockSection&gt;                ...        &lt;/apex:form&gt;  &lt;/apex:page&gt;   Now I want to create a second VF page for my mobile users with HTML 5.  How do I implement the conditional rendering with HTML 5 ?  Of course, something like &lt;div rendered="{!recordtypename == Name1}"&gt; doesn't work.
61833
I'm trying to add a class to list blocks (core/list) in Gutenberg. Unfortunately, it looks like because some blocks like lists and paragraphs don't have the standard default class name of wp-block-{name} they can't be renamed using the  filter.  To get around that, I've used the blocks.getSaveContent.extraProps filter, which seems to enable me to add a class to ALL the blocks that don't already have classes. Code below is how I got that working. It's adding added-class-name to blocks likes lists and paragraphs and so on.   function addBlockClassName( className ) {   return Object.assign( className, { class: 'added-class-name' } ); }  wp.hooks.addFilter(   'blocks.getSaveContent.extraProps',   'gdt-guten-plugin/add-block-class-name',   addBlockClassName );   And I'm enqueuing it like so:  function gdt_blocks_class_rename() {   wp_enqueue_script(       'gdt-plugin-blacklist-blocks',       get_stylesheet_directory_uri() . '/dist/guten-addons.js',       array( 'wp-blocks' )   ); } add_action( 'enqueue_block_editor_assets', 'gdt_blocks_class_rename' );   However, what I want to be able to do is add a class to ONLY list blocks? Can that be done at all?
89533
I need Drupal to use a custom page template if the URL contains a particular _GET parameter.  In D7 I would do something like this in the theme's template.php:  function mytheme_preprocess_page(&amp;$variables) {       if($_GET['isCustomTpl'] == true)         $variables['theme_hook_suggestions'][] =  'page__myCustomTpl'; }   It doesn't work in D8 though (I would have been surprised by the opposite, considering all the architectural changes in the theme layer).  Any ideas?  Bonus question: is it possible to define such a function in a module, so that i can release it publicly without having the users to edit their themes?
105914
I have a couple of blocks that have been created using the ... extends BlockBase syntax in my module. They work perfectly fine, and I can add them on the blocks layout page, can add them into DS as a field, etc. They definitely exist fine.  However, when I try and render them using Block::load(), they won't show up, unlike other blocks that work fine.  For example, if I have the following docblock:  /**  * Provides a 'Cute Cats' Block.  *  * @Block(  *   id = "cute_cats",  *   admin_label = @Translation("Cute cats yo"),  * )  */  class CuteCats extends BlockBase { ... }   ... and then try and call it like this:  $block = \Drupal\block\Entity\Block::load('cute_cats'); return render(\Drupal::entityTypeManager()   -&gt;getViewBuilder('block')   -&gt;view($block));   Any idea why? Thanks in advance.
123057
I am using hook_theme_suggestions_HOOK() to implement a custom template file in my drupal 8 website like below.   /**  * Implements hook_theme_suggestions_HOOK().  */ function mymodule_theme_suggestions_page(array $variables) {   $template_suggestions = array();   // This is used to display only $content.   if (isset($_GET['ajax']) &amp;&amp; $_GET['ajax'] == 1) {     $template_suggestions[] = 'page__ajax';   }   return $template_suggestions; }   Above code is working fine and I can add template page--ajax.html.twig inside my current active theme and changes in template is reflecting in page.  But when I put that file inside my module itself file is not detecting and changes not reflecting in page and taking default page.html.twg template file.  How can I provide default template file within my module itself?
12258
I do a lot of  development and I like their templating language. , the , looks very much like it.  How can I use Twig in Drupal 7 or even Drupal 6?
84651
I have a table inside of a pageblocksection and then inside of that I have an  that I am trying to utilize the default help text for but it's not showing up.  &lt;apex:pageBlockSection columns="1"&gt;   &lt;apex:outputPanel&gt;     &lt;table&gt; width="100%"&gt;       &lt;tr&gt;         &lt;td&gt;           &lt;apex:pageBlockSectionItem helpText="test text"&gt;             &lt;apex:inputCheckbox value="{!searchBySKU}" /&gt;             &lt;apex:outputLabel value="Search for this SKU or text in the SKU name" /&gt;           &lt;/apex:pageBlockSectionItem&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/table&gt;   &lt;/apex:outputPanel&gt; &lt;/apex:pageBlockSection&gt;   Any ideas why this doesn't work as I expect?  EDIT:  So, I just did some more testing and it creates the text if it's a direct child of the pageBlockSection. Is there any way to get around this restriction without going the fully custom route to do so?
56661
There is a lot about theming custom blocks, but what about blocks created by views?  My views block has id: block-views-posts-listing-block,  I try many ways for naming template file, ex: block--block--views-posts-listing-block.tpl.php, but I can't find correct file name.
35792
In Drupal 6, I could control block visibility using PHP code in the block UI configuration like:  &lt;?php return MYMODULE_abc() || MYMODULE_def() ; ?&gt;   These functions looked up the current node, taxonomy, etc. to decide on whether to display the block. This PHP option is gone in Drupal 8, but there is a $visibility field in BlockBase. Can I use this to programmatically set the visibility at runtime?
87458
I have a VF page to make a record for a custom object. It has 2 &lt;pageBlockSection&gt;. The first should always be rendered, and it contains a picklist. Depending on the value of the picklist, the second might be rendered.  What is the best way to go about this? Can the standard controller handle this, or does it need a custom controller? Why isn't my second section rendering correctly?  The picklist:  &lt;apex:inputField value="{!CustomObject__c.Type__c}"&gt;       &lt;apex:actionSupport event="onchange" reRender="section2"/&gt; &lt;/apex:inputField&gt;   And the second section:  &lt;apex:pageBlockSection id="section2" columns="1" rendered="{!IF(CustomObject__c.Type__c == 'Functionality Request',true,false)}"&gt;       &lt;apex:inputField value="{!CustomObject__c.Priority__c }"/&gt;  &lt;/apex:pageBlockSection&gt;
54857
I want to generate the html elements and their classes to fit my styling of the main menu.    I'm confused by all the near-possibilities offered in the api documentation and by looking at core themes etc. and still can't quite see what I have to do, or where I have to do it. I would be very grateful for clear pointers to:     which php functions I have to write;  which variables I need to add / update;  in which files the functions will go.   Presumably, in MYTHEME.theme I will need a preprocess function of some sort to add to the attributes and item.attributes variables that links.html.twig uses to print the menu ul and the menu item li's.   [Update] So far I have discovered one way to place classes on the Main Menu's ul but ideally I would like to add a class to each submenu's ul indicating the depth of the sub-menu. And I cannot locate any documentation or examples from which I can understand the generation / modifying of the main menu's individual link items.    This function goes into the file  MYTHEME.theme.  function MYTHEME_preprocess_page(&amp;$variables) {    // Pass the main menu and secondary menu to the template as render arrays.   if (!empty($variables['main_menu'])) {     $variables['main_menu']['#attributes']['id'] = 'main-menu-links';     $variables['main_menu']['#attributes']['class'] = array('links', 'clearfix', 'MYNEW_class');   }  }
107826
I have a custom block containing a text field and an image field. I would like to render the block so that the image's URL can be defined as a data attribute of the block's wrapper div so that it can be used by a javascript function to create a parallax background effect behind the text field.  If I make a template file block.parallax.html.twig, I am able to render the image HTML.  {{ content.field_parallax_image.0 }}   However If I try to get the actual image URL, nothing is returned  {{ content.field_parallax_image.0['#url'] }}   If I dump the #item keys  {{ dump(content.field_parallax_image.0['#item']|keys) }}   I am able to get target_id, alt, title, width and height values, but I can't find the URL defined anywhere.  I have also tried to see if I could find anything useful in the block preprocess function but the field_parallax_image #url field in the variables is also empty  function mytheme_preprocess_block(&amp;$variables) {     if( isset($variables['content']['body']['#bundle']) &amp;&amp; $variables['content']['body']['#bundle'] == 'parallax'){         $variables['img_url'] = $variables['elements']['content']['field_parallax_image'][0]['#url'];     } }   Is there a way I can get this URL?
77578
Drupal 7 you can style down to the fields on the page will we have this type of control with twig? I have reviewed a lot of documents about twig and didn't see anything that lets you have that same inheritance as the Drupal 7 template engine. If this is not built in to twig, is Drupal 8 going to be building it in?
120015
I want to create my custom block with custom content in Drupal 8,in start I create  Block with just simple text on it, and work correctly, my Problem is how can I pass my custom variable to it? I saw some tutorial about it , my Module name is tcdev and this is content of .module file.  function tcdev_theme($existing, $type, $theme, $path) {     return array('tcdev' =&gt;         array(             'variables' =&gt; array(                 'title' =&gt; 'Default title',                 'description' =&gt; null             ),             'template' =&gt; 'block--sliderblock'         )     ); }   and my SliderBlock.php       namespace  Drupal\tcdev\Plugin\Block; use Drupal\Core\block\BlockBase;   /**  * Provides a 'SliderBlock' block.  *  * @Block(  * id = "slider_block",  * admin_label = @Translation("Slider Block"),  * )  */  class SliderBlock extends BlockBase{     /**      * {@inheritdoc}      */     public function build(){         return array(             '#title' =&gt; 'my title ',             '#description' =&gt; 'my custom desc'         ); } }   and finally my template file block--sliderblock.html.twig    &lt;h2&gt;My Custom Block{{ title }}-{{ description }}&lt;/h2&gt;   But Result is only "My Custom Block-" . The problem is variables not getting passed to template file,where is my fault?  appreciate any help
85601
In Drupal 8, is there a way to figure out what current block or view machine name you should use?  For example, with the following code, I noticed that 'machine_name_to_determine' could change depending on how many times you have used your block.  $block_id = 'machine_name_to_determine'; $block_config = \Drupal\block\Entity\Block::load($block_id);   I need a way to retrieve this at run-time. How can I retrieve it?
64667
I have a block that I want to show on pages matching news and news?page=1. In the 'only show on these pages' section I have news and news/* but it doesn't match the second url. Is there a way to do this?   Update 1: I have also tried this:  &lt;?php     $url = request_uri();     if (strpos($url, "news")) {     return TRUE;         }     ?&gt;   But even after clearing all the caches it doesn't seem to have worked either.  I also tried the pattern news?page=* but that doesn't work either! Surely somebody considered being able to show blocks on paginated pages?  Update 2: Found the answer   Turns out the block I was trying to display was a View which was also set to display a pager (even though one doesn't appear). Turning the pager off resolved the issue.