In website operation, we often encounter such situations: an article is rich in content, but when it is displayed on the list page, the recommendation area, or some abstract module on the article detail page, we only want to display a part of the content and end with an ellipsis to maintain the cleanliness of the page and the fluency of reading.If the entire content is displayed directly, the page will appear long and affect user experience.幸运的是,AnQiCMS provides us with a very flexible and powerful template mechanism, which allows us to easily truncate long content and elegantly add ellipses, thereby enhancing the overall page effect.

In AnQiCMS, to implement the excerpt of article content, we need to use the powerful template inFilter (Filters)Function. Specifically for the content written for rich text editors, which often contains various HTML tags, such as paragraphs<p>, lists<ul>, image<img>If you simply cut characters, it may cause HTML tags to be cut off, resulting in chaotic page layout or abnormal display.AnQiCMS fully considered this point, providing an intelligent HTML-aware extraction filter, which ensures that while extracting content, the original HTML structure is not destroyed, making the output content still valid and beautiful.

How to truncate article content and add an ellipsis?

Generally, the detailed content of the article will be througharchive.ContentThis variable can be used. This variable contains the complete HTML content of the article. To extract it, we can add the symbol at the end of the variable.|Symbol