Current Location: Home> Latest Articles> EmpireCMS Fragment Types Explained: 5 Common Fragments and Their Usage

EmpireCMS Fragment Types Explained: 5 Common Fragments and Their Usage

M66 2025-07-15

EmpireCMS Fragment Types Explained: 5 Common Fragments

With the rapid growth of the internet, website development has become an essential need for both businesses and individuals. Among the various content management systems (CMS), EmpireCMS is favored by developers and webmasters due to its ease of use and powerful features. In EmpireCMS, the fragment functionality is a crucial module that helps users dynamically display and manage website content. In this article, we will explore five common fragment types in EmpireCMS and provide detailed code examples to help developers effectively utilize these fragment features.

Static Fragments

Static fragments are the most basic type of fragment in EmpireCMS. The content of static fragments remains fixed and does not change when the page is refreshed. Static fragments are typically used to display fixed content on the website, such as logos, footer information, and more. Below is an example of static fragment code:

{
if $fragment_static['logo']
    @@##@@
{/if}

Dynamic Fragments

Dynamic fragments, in contrast to static fragments, generate content dynamically based on the database. They are ideal for displaying dynamic website content, such as the latest articles or recommended products. Dynamic fragments help keep the website content up-to-date. Here’s an example of a dynamic fragment that displays the latest articles:

{loop type="article" typeid="1" return="data" limit="5"}
    <li><a href="{$data.url}">{$data.title}</a></li>
{/loop}

Fragment Files

Fragment files allow developers to save commonly used code snippets in separate files, making them easy to reference across multiple pages. This enhances the reusability of code and simplifies the website management process. Below is an example of a fragment file reference:

{#include file='common/header.html'}

External Fragments

External fragments refer to content that is pulled from other websites through a URL address. This type of fragment is useful when you need to share content across different websites. External fragments allow for content sharing between multiple sites. Below is an example of an external fragment:

{remote:http://www.example.com/fragment.html}

Custom Fragments

In addition to the four common fragment types mentioned above, EmpireCMS also supports custom fragments. This feature allows users to create specific fragment templates tailored to their website’s needs, providing more personalized content display. Below is an example of a custom fragment:

{include file="custom/fragment_custom.html"}

Conclusion

Through this detailed exploration of the five common fragment types in EmpireCMS, it is clear that fragments play an essential role in website content management. Whether it's for displaying static content or updating dynamic data, fragments provide flexible solutions for developers. We hope this article helps website builders better understand and leverage the fragment features of EmpireCMS to improve website management and user experience.