As an experienced website operations expert, who is deeply familiar with Anqi CMS, I often encounter users who are confused about the working principles of some auxiliary functions during template development. Today, let's delve into a seemingly simple yet easily misunderstood topic -loremHow is the content generated by the tag stored in the Anqi CMS database?
loremTag: The 'Extraordinary Actor' in the world of templates.
First, let us make it clearloremThe placement of tags in AnQi CMS templates. In the AnQi CMS template system,loremclassified as 'Other auxiliary tags', as described in the documentdesign-tag.mdandtag-tags.mdAs described. Its main responsibility is to generate random, meaningless placeholder text content.Whether it is to generate a standard Latin text, a specified number of words, or a paragraph of a fixed length,loremTags are the helpful assistants that template designers and developers use at the beginning of website construction, when the content is not ready, to quickly fill in page layouts, test styles, and layout effects.
For example, when you design a template for an article detail page, you may want to see the actual display effect of a long article on the page, but at this time, you do not have enough content for a long article. In this case, you can simply use in the template.{% lorem 3 p %}Quickly generate three placeholder paragraphs, simulating the length and paragraph structure of real content, so as to adjust CSS styles or JavaScript behavior, ensuring that the page remains beautiful and functional when real content is present.
The Anqi CMS template rendering mechanism withloremessence
To understandloremWhether the content generated by the label is stored in the database, we must first understand the template rendering mechanism of Anqi CMS.The AnQi CMS adopts a syntax style similar to the Django template engine and achieves fast template rendering with the high-performance features of the Go language.This means that when a user accesses a page through a browser, the AnQi CMS will perform the following series of operations:
- Receiving requests:The server receives a user's access request to a page.
- Data preparation:The AnQi CMS queries and prepares all the necessary real data from the database according to the type of requested page (such as article details, category list, single page, etc.)
- Template parsing and rendering:Loading the corresponding AnQi CMS:
.htmlTemplate file. At this stage, the template engine will parse the template code line by line. When encounteringarchiveList/categoryDetailWhen calling the tag with data, it will fill in the real data prepared in the second step; while encounteringloremthe tag, the template engine will be at this pointdynamically generateRandom text with specified length and format. - Content output:After all data is filled and dynamic content generation is completed, the template engine will send the final HTML content to the user's browser.
We can clearly see from this process,loremThe content generated by the tag is aInstant generation, instant consumptionThe process. These random texts are generated when the page is requested and rendered, and their lifecycle is limited to this page request and response.The server sends the generated HTML to the browser, after which these temporary texts are discarded, not retained, and certainly not written to the underlying database of the security CMS.It is like a temporary canvas that appears only when the designer needs it, and once the design is complete, it will be erased, and will not become a part of the final work.
How is the real content stored? WithloremThe fundamental difference
SinceloremHow is the real content of the website stored if the generated content is not stored in the database? This is the core function of AnQi CMS as a content management system.
AnQi CMS provides the "Flexible Content Model" feature, allowing users to customize article, product, and various other content structures according to business needs (refer toAnQiCMS 项目优势.mdandhelp-content-module.md)。When you go through the “Add Document”, “Page Management” and other functions (such ashelp-content-archive.md/help-source-page.mdWhen you post content, all the text, images, video links, and information such as titles, keywords, summaries, and custom fields you set in the rich text editor will be received by the backend program of the Anqin CMS.Persistent StorageTo its configured MySQL database.
These data stored in the database have independent IDs, associated category information, publishing time, and metadata, and can be edited, modified, and deleted through the backend management interface, as well as beingarchiveDetail/pageDetailTags are accurately read from the database and displayed on the front end page. This isloremin sharp contrast to the temporary and meaningless characteristics of tags.
Therefore, in summary,loremThe tag in AnQi CMS is just an auxiliary tool at the template rendering stage, and its content will not be stored in the database.The database is only responsible for storing all the real, valuable website content that you meticulously edit and publish through the backend.
Frequently Asked Questions (FAQ)
Q: How do I store some default text content in a database instead of generating random text each time?A: If you need to store fixed default text, such as product description templates, company profile templates, etc., you should create a new document, single page, or add a custom field in the content management module of Anqi CMS backend, and set a default value for the field. Then, use the corresponding tags in the template (such as
archiveDetailorpageDetailUse the field name) to call these predefined text content.Q: Use
loremWill the content generated by tags affect the website's SEO?A:loremThe content generated by the label itself has no SEO value. It is of course permissible to use it during website development and testing, butabsolutely cannot containloremThe content is launched on the production environmentThe search engine crawler will recognize these meaningless texts, which may result in the page being deemed low-quality content, thereby severely damaging the website's SEO ranking.Before going live, be sure to replace all with real, original, and valuable contentloremGenerated placeholder text.Q: Can I
loremShould the content generated by the tag be applied with other AnQiCMS template filters?A: Of course you can.loremThe output result of the tag in the template rendering process is essentially a plain string. Therefore, you can apply various template filters provided by Anqicms to it just like any other string variable, for exampletruncatechars(truncated character),wordwrap(Word wrapping) orupper(Uppercase) etc., to further test the display effect of the page under different text processing conditions. For example:{% lorem 100 w | truncatechars:50 %}A text of 100 words will be generated, then the first 50 characters will be truncated and an ellipsis will be added.