- Issue created by @giordy
- Assigned to manishvijay02
- 🇮🇳India manishvijay02
Hi @giordy,
Yes it is possible to do so. What you need to is :
1. Create a CSS file named homepage.css and add the necessary styles to it.
2. Link this file in libraries.yml with unique name
home-page:
css:
theme:
path-to-css-directory/homepage.css
3. Then use the following hook in your .theme file to attach the CSS to the homepage:
/**
* Implements hook_page_attachments_alter().
*/
function your_theme_page_attachments_alter(array &$attachments) {
// Check if the current path is the homepage.
if (\Drupal::service('path.matcher')->isFrontPage()) {
// Attach the 'home-page' library to the page.
$attachments['#attached']['library'][] = 'your_theme/home-page';
}
}Hope this helps.
- Issue was unassigned.
- 🇮🇹Italy giordy
Thanks but I don't have the technical skills to create the CSS.
If there is an easier solution or a model to copy, otherwise I leave it alone.thanks and best regards
- Assigned to flashwebcenter
- Status changed to Fixed
5 months ago 11:55am 27 June 2024 - 🇺🇸United States flashwebcenter Austin TX
Hello,
Changing the background color for your home page content in the Solo theme is a straightforward task. In Drupal, the home page is designated with the class "path-frontpage," allowing you to target the home page specifically. Follow this example to change the main content background color to red:
body.path-frontpage #page-wrapper #sidebar-box-main .region-inner { --r-bg: red; }
Best wishes,
Alaa - 🇮🇹Italy giordy
Alaa you're great!!
It's much easier that way.Thank you so much and best regards
- 🇺🇸United States flashwebcenter Austin TX
Thank you so much for your kind words! It's much appreciated.
Best regards,
Alaa Automatically closed - issue fixed for 2 weeks with no activity.