This forum is for assistance with theme development.

Changing the Homepage Page Title

Greetings,

  I have Drupal 9.45 installed and need to programmatically change the title tag.  I see in the twig template the field looks like this:

 <title>{{ head_title|safe_join(' | ') }}</title>

But when I try to set that variable in a preprocess function nothing is changing:

function MYTHEME_preprocess_page(&$variables){

      $variables['head_title']['#markup'] = [t('Welcome page')];

}

I've also tried:

$variables['head_title'] = 'Welcome Page';

How to Modify Placement of Elements in a view based of a field selected in the content

I have a content type with 4 fields namely title, body, image, and position, my goal is to set the placement of these fields based on the value selected in the position field e.g. if the value of position is set to 'left' the image is to be shown on the left and the title and body should be shown on the right and vice versa I created a view using all these fields now I want to use the HOOK__views_pre_render to get the value of the position field, and based on that set the position of the elements as given in the example

Add reference to a block/view through a hook

Hi, 

I'm fairly new to Drupal and I've got a question. Namely, is there any way of adding a reference to a view or block by a hook? I have an article content type and an courses content type. I need to implement a block with a list of courses in the middle of content. My form looks like this:

  • Lead - textfield
  • Image
  • Long html text
  • List of courses
  • Long html text
  • other fields...

I want to let my users choose to display the list of courses or not . 

[FIXED]: Using TWIG to display the rendered body content (no fields) without losing the contextual menu?

I'm trying to change some aspects of my page.html.twig file: I want to control how the body field is displayed in the theme and exclude the display of an image field but still use its URI for a theme DIV element. How can I do this via TWIG?

preload-fonts doesnt work in info.yml subtheme file

As indicated in this Drupal doc, I am trying to preload my local font to avoid flash of invisible text (FOIT), but it does not work.
It should be super easy since the fonts folder is in the 'subtheme-name/fonts' folder but any combination doesn't work.

I am using Adaptivetheme, but I think it applies to all themes.

What could I be doing wrong...is there eventually another method?

Pages

Subscribe with RSS Subscribe to RSS - Theme development