How to generate random text in AnQiCMS template as placeholder content for development testing display?

Calendar 👁️ 72

During the development of AnQiCMS templates, we often need to fill in placeholder text on the page before the real content is in place, so that we can better observe the layout, test the styles and functions.Manually entering "test content" or "placeholder text" is time-consuming and lacks authenticity.Fortunately, AnQiCMS provides a very convenient built-in tag that can elegantly solve this problem--that islorem.

A random text generator in AnQiCMS:loremTag

loremThe label is inspired by the commonly used "Lorem ipsum" text in printing layout, which can generate pseudo-Latin text according to your needs, perfectly solving the problem of layout preview when content is missing. Whether you need a short sentence with a few words or a long text with several paragraphs, loremTags can easily handle it.

loremBasic usage of tags

The simplest usage is to directly write in any position of the AnQiCMS template{% lorem %}. When the page is rendered, it will generate a default-length pseudo-Latin text at this position.This text is of moderate length, enough to fill most common text areas, giving you an initial perception of the overall visual effect of the content.

Control the number and type of text

To control the length and structure of the generated content more accurately,loremThe label provides two key parameters:QuantityandMethod.

  1. Number parameter: Used to specify how many words, paragraphs, or bytes you want to generate.
  2. Method parameterIt determines the interpretation of 'quantity', which has three optional values:
    • w(words): It indicates generating by word count.
    • p(paragraphs): Indicate the generation by the number of paragraphs.
    • b(bytes): Indicate the generation by the number of bytes.

By combining these parameters, you can flexibly generate various forms of placeholder content. For example:

  • Generate a short sentence of 10 words:{% lorem 10 w %}
  • Generate 3 paragraphs of text:{% lorem 3 p %}
  • Generate 50-byte text:{% lorem 50 b %}

This precise control capability enablesloremTags are particularly efficient in tests of text regions with different lengths.

Add randomness

By default,loremThe text generated by the label is fixed, and the text generated each time the page is refreshed is the same.But in some test scenarios, you may want to see different placeholder content each time you refresh, to simulate the randomness of real website content, or to check the stability of the layout under different text lengths.

At this point, it is possible to introducerandomparameters. Simply inloremAdd at the end of the labelrandomThat's it, for example:

  • Generate 15 random words:{% lorem 15 w random %}
  • Generate 2 random paragraphs:{% lorem 2 p random %}

addrandomAfter the parameter, every time the page loads,loremLabels are randomly selected from the built-in pseudo-Latin text library, ensuring that each time you see it, it is a unique placeholder text.

Actual application scenarios: convenience in development and testing

loremLabels play an important role in the multiple stages of development and testing of the AnQiCMS website:

  1. Template layout design: When you are designing the template of AnQiCMS website, you often encounter the situation where the real content is not in place. UseloremLabel, you can quickly fill in the text area and intuitively see the actual effect of text in different layouts and font sizes, ensuring that the design can be perfectly converted to the actual page.
  2. Content Filling Effect PreviewFor example, a list page of articles may need to display article titles and summaries. Use{% lorem 8 w %}as the title,{% lorem 60 w %}As an introduction, it can effectively preview the visual balance of list items, avoiding layout disorder due to uneven text length after the real content goes online.
  3. Responsive layout test:When testing responsive layouts for different screen sizes, irregularly long real content can cause layout jumps.loremLabels can generate text of different lengths to help you check the robustness and adaptability of the layout with various amounts of text.
  4. Performance testing and layout proofreadingFor pages that need to load a large amount of text content, you can generate hundreds of words or multiple paragraphs to simulate real load, and evaluate the page loading speed and rendering performance.At the same time, it also allows designers and editors to better proofread the text flow and reading experience during the layout stage.

Usage examples and tips

Let's look at some specific examples and experienceloremFlexible use of tags:

Fill content in the ordinary page block:

<div class="hero-section">
    <h1>{% lorem 6 w %}</h1>
    <p>{% lorem 30 w %}</p>
    <a href="#" class="button">{% lorem 2 w %}</a>
</div>

<div class="about-us">
    <h2>{% lorem 4 w random %}</h2>
    <p>{% lorem 2 p random %}</p>
</div>

Display as default content in the article list loopIn AnQiCMS, when you retrieve data from the database and display it in a loop, if a field (such as the article title or summary) may be empty, you can combinedefaultFilters andloremLabel, provide elegant placeholder content for these empty fields.

{% archiveList archives with type="list" limit="5" %}
    {% for item in archives %}
    <div class="article-preview">
        <h3><a href="{{ item.Link }}">{{ item.Title|default:{% lorem 8 w random %} }}</a></h3>
        <p>{{ item.Description|default:{% lorem 50 w random %} }}</p>
        <small>发布日期: {{ stampToDate(item.CreatedTime, "2006-01-02")|default:{% lorem 3 w %} }}</small>
        {% if not item.Thumb %}
            <img src="https://via.placeholder.com/150/EEEEEE/999999?text={% lorem 2 w %}" alt="{% lorem 3 w %}">
        {% endif %}
    </div>
    {% else %}
    <p>暂时没有文章内容可供显示。</p>
    {% endfor %}
{% endarchiveList %}

This example shows how toarchiveListusedefaultFilter, when the realitem.Titleoritem.Descriptiondoes not exist, automatically fill in randomly generated ones.loremText. We used an external placeholder image service for thumbnails and dynamically generated the images on top of them.loremText to simulate more diverse placeholder content.

By flexible applicationloremLabel, AnQiCMS users can greatly improve the efficiency and comprehensiveness of template development and testing. Whether it is simple text filling or complex content structure simulation,loremCan provide powerful

Related articles

How to automatically parse URL strings in HTML code to display clickable links in AnQiCMS?

In the daily operation of websites, we often need to insert various URLs in the article content, whether it is to refer to external resources or to guide users to visit other pages within the site.If adding the `<a>` tag manually to these URLs each time is time-consuming and prone to errors.It is fortunate that AnQiCMS provides users with a very intelligent and convenient solution in this regard, which can automatically identify and parse URL strings in HTML code and convert them into clickable links.### Core Mechanism: Make the URLs in the content "alive" When you edit articles in the AnQiCMS backend

2025-11-08

How to use AnQiCMS filter to perform string truncation, case conversion, and other processing on displayed content?

When using AnQiCMS for website content management, we often encounter situations where we need to make some fine adjustments to the displayed content, such as when a title of an article is too long and we want it to be displayed partially with an ellipsis at the end;Or some text should be displayed in uppercase or lowercase. The powerful template filter function of AnQiCMS can easily help us meet these needs without modifying any backend code, and it can be completed directly at the template level.The template filter is a practical tool in AnQiCMS template language, which allows us to transform the values of template variables

2025-11-08

How does AnQiCMS ensure that mathematical formulas and flowcharts inserted in the Markdown editor are displayed normally on the front end?

In modern website content creation, Markdown is favored by a large number of content creators for its concise and efficient features.However, for websites that need to present complex information, such as mathematical formulas and flowcharts, how to seamlessly insert them into Markdown editors and ensure they are displayed normally on the front end is often a challenge for content operators.AnQiCMS (AnQiCMS) fully understands this need, through flexible configuration and standardized introduction methods, allowing these complex elements to be elegantly presented on your website

2025-11-08

How to display custom Banner image and content in AnQiCMS single page?

In website operation, a well-designed single page often plays an important role in brand display, product introduction, or specific event promotion.A striking Banner area that can quickly capture the visitor's attention and convey core information.AnQiCMS as a flexible content management system, provides a very convenient way, allowing you to easily set and display custom Banner images and content on a single page.Next, we will explore how to implement this feature in AnQiCMS.## Step 1

2025-11-08

How does AnQiCMS display the table of contents or outline of the article content on the article detail page?

For articles that are rich in content and long in length, a clear table of contents or outline is like a navigation map, which can greatly enhance the reading experience of the reader.It not only helps readers quickly grasp the main points of the article, but also allows them to accurately jump to the parts of interest, thereby improving the readability and practicality of the content.In AnQiCMS, implementing the content directory display on the article detail page is not a difficult task, the built-in functions of the system provide us with a simple and efficient solution.### AnQiCMS How to understand the article structure? AnQiCMS

2025-11-08

How to dynamically retrieve and display the contact information of a website, such as phone number, email, and social media links?

The contact information of the website, such as phone number, email, and social media links, is an important bridge for users to connect with us.It is crucial that the accuracy and accessibility of this information is maintained in the operation of the website.AnQiCMS as an efficient content management system provides a very convenient way to manage and dynamically display this contact information, allowing us to easily maintain the consistency of website content and quickly update it when needed.This article will delve into how to set contact information in AnQiCMS, as well as how to dynamically retrieve it in templates and display it in a user-friendly manner.### One

2025-11-08

How does AnQiCMS set the 'default thumbnail' to unify the display effect when images are missing?

In website content operation, images play a vital role. They can attract users' attention, enhance the visual appeal of the content, and help users quickly understand the theme of the content.However, in the process of daily content publishing, we sometimes encounter situations where some articles fail to upload exclusive thumbnails for various reasons, or the content itself does not have suitable images to extract.If the front-end page directly displays blank, broken image icons, or disordered layout, it will undoubtedly severely affect user experience and the professionalism of the website.To solve this problem, AnQiCMS

2025-11-08

How AnQiCMS affects the display effect of the website under different template modes (adaptive, code adaptation, PC + mobile)?

When building and operating a website, we often consider how to make the website display beautifully on different devices.AnQiCMS (AnQiCMS) fully understands this point and therefore provides three flexible template modes to meet different needs: adaptive, code adaptation, and PC + mobile independent site mode.Each pattern has its unique implementation method and impact on the display effect of the website, understanding them can help us better choose the solution suitable for our project.### One, Adaptive Mode: One template, multiple screens Adaptive mode, as the name suggests

2025-11-08