AnQiCMSpageDetailTagsidParameter: flexible and optional art
As an experienced website operations expert, I am well aware of the importance of the flexibility of the content management system template in enhancing operational efficiency and website performance.AnQiCMS (AnQi CMS) boasts its simple and efficient architecture, which is also reflected in the design of its template tags.pageDetailthe tag inidAre the parameters mandatory? The answer is:It is not always mandatory, it demonstrates the intelligence and flexibility of AnQiCMS in content calls.
In the template design of AnQi CMS,pageDetailThe label is specifically used to display the detailed content of a single page (such as "About UsThe core value of this tag lies in its ability to accurately capture and present rich information such as the title, description, content, images, etc. of a specific single page according to your needs.
Smart Default: When you do not need to specify an ID
AnQiCMS in DesignpageDetailTags are considered with the most common usage scenarios in mind. When you are already on a single page detail page (for example, you are editing or previewing the 'About Us' page created in the background, whose URL might be/page/about-us.html)Directly callpageDetailWhen using tags to obtain information about the current page, the system will default to recognizing the ID of the current page. This means that you can completely omitidParameters, AnQiCMS will automatically extract the data of the current single page being browsed.
For example, in your "About Us" single page templatepage/detail.html(or customized)page/about.htmlIn the brackets, if you want to display the title and content of this page, you can simply write it like this:
<h1>{% pageDetail with name="Title" %}</h1>
<div class="page-content">{% pageDetail with name="Content" %}</div>
Here, you do not need to explicitly statepageDetailLabel “Please give me the single page with ID X” as it already knows that you are referring to the current page.This design greatly simplifies the template code, improves development efficiency, and reduces the likelihood of errors.
Accurate positioning: when it is necessary to provide explicitlyidortoken
However, this default behavior of intelligence is not applicable to all scenarios. If you want tonon-single-page, or on some single pagerefer to the content of other single pagesWhen, you need to explicitly tellpageDetailthe tag of the single page data you want to retrieve. At this time,idortokenthe parameter comes into play.
Use
idParameters:idThe parameter is used to specify the digital ID of a single page.When you clearly know the unique numeric identifier of the target single page, you can use it directly.<a href="{% pageDetail with name='Link' id='5' %}"> <h2>{% pageDetail with name="Title" id="5" %}</h2> </a> <p>{% pageDetail with name="Description" id="5" %}</p>Use
tokenParameters:tokenThe parameter is used to specify the URL alias for a single page.Compared to numeric ID, URL alias is usually more readable and memorable, and also conforms to SEO-friendly principles.about-usThen you can call it like this:<section id="contact-info"> <h3>联系我们</h3> <div>地址:{% pageDetail with name="Content" token="contact-us" %}</div> </section>This method is especially convenient when the URL alias in the background page remains stable and you hope to refer to the page in a more intuitive way.
Cross-site considerations:siteIdAdvanced applications
ExceptidandtokenYou may also notice,pageDetailthe tag also hassiteIdParameter.This is usually used for the multi-site management scenario of AnQiCMS.siteIdParameters become indispensable.It allows you to cross the boundaries of the site, realizing flexible sharing and calling of content.Of course, for most single-site operators, this parameter can be ignored.
**Practice and Flexible Application
In summary,pageDetailthe tag inidwhether the parameters must be provided depends entirely on your usage scenario and goals.
- In the target single-page detail page, obtaining its own content when,
idThe parameter is not required.You can rely on the intelligent default behavior of AnQiCMS. - When referencing specific single-page content on other pages,
idortokenthe parameters are your precise positioning tool.Prioritize usingtoken, as it is easier to understand and maintain, and is more friendly to SEO.
The design philosophy of the template tag in AnQi CMS is to provide the greatest flexibility, allowing you to write concise, efficient, or precise template code according to your actual needs.Understanding the semantics and usage scenarios of these parameters will help you better handle AnQiCMS and create a powerful, user-friendly website.
Common Questions (FAQ)
Q1:pageDetailthe tag inidandtokenWhat are the differences? Which one should I use first?
A1:idThe parameter is a unique identifier for a single page, usually automatically assigned by the system.tokenThe parameter is the URL alias of a single page, usually set by the user in the background, and it is more semantic and readable.When referencing a non-current single page in the template, you can choose either one.token[en]Because it is more intuitive and easy to understand in the template, when the page ID changes in the database (although it is not common),tokenit is also not necessary to modify the template code, and it is more friendly to SEO.
Q2: If I use the tag in a non-single-page template, butpageDetaildo not provideidortokenWhat will happen?
A2: If you are not on a single-page detail page (i.e., the route of the current page does not point to a specific single-page), but you have calledpageDetailand did not provideidortokenparameters,pageDetailTags will not recognize the single-page ID in the context.This usually results in the tag returning an empty value, or may cause template rendering errors under some strict template configurations.pageDetailWhen, be sure to clearly provideidortoken.
Q3:pageDetailandpageListWhat are the uses of tags, and how should I choose?
A3:pageDetailTags are used to obtain and displayA single specificDetailed information on a single page, emphasizing is the "detail".pageListTags are used to retrievemultiple single-pagelists, usually combined with loop tags (such asforTo display all or part of a single page (for example, listing all about us subpages at the bottom of a website). If you need to display the full content of the 'About Us' page,pageDetailIf you want to list all the single-page titles and links of the "help document" category in the navigation or sidebar, you should usepageList.