Skip to main content

Snippets Reusable HTML Blocks

modular, reusable chunks of HTML (and optionally PHP) content that you can insert into layouts, templates, and viewsโ€”dramatically speeding up development and ensuring consistency across your UI

๐Ÿ” What Are Snippets?

Snippets are short reusable pieces of frontend or backend markup that:

  • Contain HTML and optional PHP logic
  • Can include dynamic placeholders (e.g., {field_value}, {item->title})
  • Are editable from the GUI
  • Are version-controlled and package-aware
  • Can be injected into Templates, Layouts, and Custom Admin Views

Snippets are useful for any repeated HTML patternโ€”such as:

  • Field display blocks
  • Info cards
  • Alerts/notifications
  • Button groups
  • Reusable form sections

๐Ÿงฐ Where Are They Used?

  • Layouts: You can inject one or more Snippets into layout blocks
  • Templates: Templates can load Snippets dynamically
  • Views: Both Admin and Site Views can render Snippets conditionally
  • Libraries: JS/CSS assets can be linked to Snippets if needed

๐Ÿ“‹ Features

  • โœ… GUI Editor with HTML/PHP support
  • โœ… Named and keyed for reuse
  • โœ… Linked to Layouts, Templates, Views
  • โœ… Can contain nested placeholders
  • โœ… Support for round-trip code integration
  • โœ… Easily shareable and resettable across projects

๐Ÿ“ฆ Snippets vs Layouts vs Templates

Type Purpose Use Case
Snippets Reusable markup chunks Field groups, cards, quick HTML
Layouts PHP render logic for sections Repeating rows, list views
Templates Page-level view structure Full output of a Site/Admin View

๐Ÿ’ก Example Use Cases

  • A consistent user profile card: + avatar + action button
  • A notice section used in both Admin and Site interfaces
  • A form block reused across multiple layouts (e.g. billing form)

๐Ÿ” Maintenance & Version Control

Like other JCB entities, Snippets are:

  • Resettable to shared blueprints
  • Forkable for long-term customization
  • Pushable to external repositories

๐Ÿ“Ž Related Features

  • Layouts
  • Templates
  • Libraries
  • Field Injection Points
  • Round-Trip Code Tags

๐Ÿงฉ Conclusion

Snippets reduce repetition and bring smart modularity to your Joomla component views. With GUI-driven editing, version-aware linking, and dynamic placeholder supportโ€”theyโ€™re your go-to tool for clean, maintainable interface design. Use them once, reuse them everywhere.