Controlling the Break with Drupal Teasers
One of the core features of Drupal is the teaser functionality. This allows you to show a teaser on the home page and category pages, rather the full article. The user has to click through to the full page to see the article in full. I really like this feature as it makes it a lot easier for user to scan through a range of stories on the home page before deciding which one they want to view in detail.
The only problem is, you may end up showing too much or not enough detail in the teaser. It is very annoying when a sub heading is visible in the teaser with the content below it cut off.
Thankfully there is a very easy solution! Simple enter the following code where you want the teaser to end:
This is a comment that will not appear on the website/blog, but will force a break in the right place. Only the content above the break will be included in the teaser.
If you liked this, you'll love my book, Master Drupal Module Development.
"..the must have drupal developers book"
Feeling stuck with Drupal 8 module dev?
Get the free 7 lesson course that will help you get started today without feeling overwhelmed.
- Create Drupal modules with just a few commands using the Drupal Console
- Create custom pages
- Create custom blocks
- Create admin forms
- Demystify routers and controllers
- Bonus material