Template Example for Content Managed Web Design
Example template topic for
CommentPluginExamples:templatetopic.
%TMPL:DEF{PROMPT:example}%%TMPL:P{promptbox}%%TMPL:END%
%TMPL:DEF{FORM:example}%
#TemplateTopicPrompt
<form method="post" action="%SCRIPTURL{save}%/%BASEWEB%/%BASETOPIC%" enctype="application/x-www-form-urlencoded" name="examplecomment" id="examplecomment">
<input type="hidden" name="redirectto" value="%BASEWEB%.%BASETOPIC%" />
%COMMENTPROMPT%
</form>
%TMPL:END%
%TMPL:DEF{OUTPUT:example}%%POS:BEFORE%%TMPL:P{OUTPUT:examplethreadmode}%%TMPL:END%
%TMPL:DEF{OUTPUT:examplethreadmode}%%POS:BEFORE%
%GMTIME{"#CommentDate$epoch"}%
%WIKIUSERNAME% - %DATE%:
%URLPARAM{"comment"}%
---
%TMPL:END%
Include generic comment templates:
%TMPL:INCLUDE{"%SYSTEMWEB%.CommentPlugin"}%
The code provided is an example of a templating mechanism used within a web-based content management system (CMS), such as TWiki or Foswiki. These systems use templates to manage the presentation and handling of user-generated content, such as comments or form submissions. Let's break down the provided template code in detail:
Template Definition Sections
The template is divided into several sections, each defined with
%TMPL:DEF%
and ended with
%TMPL:END%
. These sections define various parts of the template, which can be reused throughout the system.
1. PROMPT Section
%TMPL:DEF{PROMPT:example}%%TMPL:END%
- Explanation:
- This section defines a template named
PROMPT
for example
.
- Inside this definition, it includes another template part, ==.
-
promptbox
is likely a predefined part or another template that handles the visual representation or the input box for the comment prompt.
2. FORM Section
%TMPL:DEF{FORM:example}%
#TemplateTopicPrompt
<form method="post" action="%SCRIPTURL{save}%/%BASEWEB%/%BASETOPIC%" enctype="application/x-www-form-urlencoded" name="examplecomment" id="examplecomment">
<input type="hidden" name="redirectto" value="%BASEWEB%.%BASETOPIC%" />
%COMMENTPROMPT%
</form>
%TMPL:END%
- Explanation:
- This defines the
FORM
template for example
, which is typically used to handle form submissions in the web interface.
- The form submits data via POST method to a URL constructed using
https://pioneer.npl.washington.edu/do/save/Sandbox/CommentPluginTemplateExample
, which resolves to the script that processes the form data.
- The hidden input field
redirectto
ensures that after submission, the user is redirected back to the original page.
-
%COMMENTPROMPT%
is a placeholder that will be replaced with the actual prompt for user input, which might have been defined in the PROMPT
section or elsewhere.
3. OUTPUT Section
%TMPL:DEF{OUTPUT:example}%%POS:BEFORE%%TMPL:END%
- Explanation:
- This defines an
OUTPUT
template for example
.
-
%POS:BEFORE%
indicates that this content should be placed before certain content, likely a placeholder for dynamic insertion of the comments or other output.
- The template includes another part, ==, which refers to a threaded mode output template defined below.
4. OUTPUT Example Thread Mode Section
%TMPL:DEF{OUTPUT:examplethreadmode}%%POS:BEFORE%
#CommentDate1731606055
---
%TMPL:END%
- Explanation:
- This section is likely responsible for rendering each individual comment in a thread-like view.
-
#CommentDate1731606055
outputs the GMT time of the comment based on the epoch time.
-
Main.TWikiGuest
represents the username of the person who made the comment, and 2024-11-14
displays the current date.
- == pulls the comment text from a URL parameter, which is how the comment content is displayed.
- The
---
marks the end of a comment, separating it from others visually.
5. Including Generic Comment Templates
%TMPL:INCLUDE{"TWiki.CommentPlugin"}%
- Explanation:
- This line includes generic templates from the
CommentPlugin
, which resides in the SYSTEMWEB
directory.
- Including this ensures that the functionality provided by the CommentPlugin, such as additional formatting or handling, is available in the current template.
This template structure is designed to manage user comments within a CMS, facilitating the creation, display, and handling of user-submitted content on web pages. By breaking down the different parts of the template, the CMS can ensure consistency across different pages and user interactions. This also allows for modularity, making it easier to update or customize specific sections without affecting the entire system.
Include web design company:
https://www.portside.wales/services/website-design/