Creating you own content types (Part 2)
Response Example
Here as an example the content type for bugtracker (r0010_bugtracker_xml):<?xml version="1.0" encoding="utf-8"?> <contenttype> <info> <name>Bugtracker</name> <about>Choose this option if you want to submit a bug report</about> </info> <fields> <field> <name>title</name> <text>Title</text> <description>Enter here a title for your bug report</description> <type>text</type> <required>1</required> <error>The topic title is empty. Please provide a title that describes what this topic is about.</error> </field> <field> <name>text</name> <text>Summary of the problem</text> <description></description> <type>message_textarea</type> <required>2</required> <error>Sorry, you forgot to enter a message.,Sorry, your message need to be at least 6 characters long.</error> </field> <field> <name>version</name> <text>Affected Version</text> <description></description> <type>text</type> <required>1</required> <error>Please enter a version number in the affected version field.</error> </field> <field> <name>priority</name> <text>Priority</text> <description></description> <type>dropdown,normal,low,high</type> <required>1</required> <error></error> </field> </fields> <links> <main>bugtracker</main> </links> </contenttype>
The content type XML file started with:
<?xml version="1.0" encoding="utf-8"?> <contenttype>
The info fields are the content type name and description, in this case Pages and A content type to handle pages as description:
<info> <name>Bugtracker</name> <about>Choose this option if you want to submit a bug report</about> </info>
Next we need to specify the used fields:
<fields>
Our first field is the Title:
<field> <name>title</name> <text>Title</text> <description>Enter here a title for your bug report</description> <type>text</type> <required>1</required> <error>The topic title is empty. Please provide a title that describes what this topic is about.</error> </field>
Name is the fields name used in the database. Text is the text that is show up in the content editor while Description is an optional description. With the Type option you can set the field type, in this case text for a text field. The Required option turns this field into a required field. If this field is empty, the user will get the error message specified in the Error field. Next field is for summary:
<field> <name>text</name> <text>Summary of the problem</text> <description></description> <type>message_textarea</type> <required>2</required> <error>Sorry, you forgot to enter a message.,Sorry, your message need to be at least 6 characters long.</error> </field>
The next field is version:
<field> <name>version</name> <text>Affected Version</text> <description></description> <type>text</type> <required>1</required> <error>Please enter a version number in the affected version field.</error> </field>
and then a dropdown menu field for priority:
<field> <name>priority</name> <text>Priority</text> <description></description> <type>dropdown,normal,low,high</type> <required>1</required> <error></error> </field>
</fields>
Now we need to set the links:
<links> <main>bugtracker</main> </links>In this case, we use bugtracker as main link. This means content with this content type are accessible over www.example.com/bugtracker/some_example_page/. Finally, we close the content type with:
</contenttype>
Next are the templates. Response content types are using 4 templates. This first template in this example is bugtracker. The template name of the first template is always the name you set under links/main. All other templates are using the links/main name as well with the affixes: _post, _responses, and _print.
<!-- Template: bugtracker --> <link rel="stylesheet" href="{%website_url%}/assets/css/colorbox.min.css?ver={%css_version%}" integrity="{%checksum_colorbox-min-css%}" crossorigin="anonymous" /> <script async src="{%website_url%}/assets/js/jquery.colorbox.min.js?ver={%css_version%}" integrity="{%checksum_jquery-colorbox-min-js%}" crossorigin="anonymous"></script> <script async src="{%website_url%}/assets/js/contentteller.images.min.js?ver={%css_version%}" integrity="{%checksum_contentteller-images-min-js%}" crossorigin="anonymous"></script> <script src="{%website_url%}/assets/js/jquery.jscroll.min.js?ver={%css_version%}" integrity="{%checksum_jquery-jscroll-min-js%}" crossorigin="anonymous"></script> {%pagination_scroll_posts%} {%pagination_scroll_ratings%} {%subscription%} {%topic_moderation%} <article itemid="{%website_url%}/bugtracker/{%community_seo%}/" itemscope itemtype="https://schema.org/Report"> <header> <h2 class="site-post-title"><a href="{%website_url%}/bugtracker/{%community_seo%}/"><span itemprop="headline">{%community_title%}</span></a></h2> <p class="site-post-meta"><span class="btn btn-xs btn-category ct-category-{%category_id%}"><a href="{%website_url%}/community/category/{%category_seo%}"><i class="{%category_icon%}"></i> {%category_name%} <span class="badge">{%category_count%}</span></a></span> This bug report was posted by <span itemprop="author" itemscope itemtype=" https://schema.org/Person"><span itemprop="name">{%community_username%}</span></span>, <time itemprop="datePublished" datetime="{%community_date_utc%}" prettydate>{%community_date%}</time></p> </header> {%posts_notice%} <div class="postsarea"> {%posts%} {%pagination_posts%} </div> </article>Next is the bugtracker_post template:
<!-- Template: bugtracker_post --> <article class="row response-comments"> <div class="{%level%}"> <div class="panel panel-response"> <div class="{%panel%}"> <table class="table table-hover"> <thead> <tr> <th>Bug Report</th> <th>{%response_title%}</th> </tr> </thead> <tbody> <tr> <th>Reported By</th> <td><img class="img-circle smallavatar" src="https://www.contentteller.com/{%user_avatar%}" alt="avatar" />{%user_username%} {%statusbadge%} <span class="badge"><i class="far fa-comment"></i> {%user_responses%}</span></td> </tr> <tr> <th>Opened</th> <td><time datetime="{%response_date_utc%}" itemprop="datePublished" prettydate>{%response_date%}</time></td> </tr> <tr> <th>Priority</th> <td>{%response_priority%}</td> </tr> <tr> <th>Affected Version</th> <td>{%response_version%}</td> </tr> </tbody> </table> <br /> <h4>Description</h4><hr /> <div class="comment-post"> {%response_text%} </div> {%reply_edit%} {%moderator%} {%share_buttons%} </div> </div> </div> </article>
Next we have the template to separate the bugtracker post from the responses bugtracker_responses:
<!-- Template: bugtracker_responses --> <hr /> <div class="setcenter"><h4><i class="fas fa-angle-double-down"></i> Latest responses to this bug report <i class="fas fa-angle-double-down"></i></h4></div> <hr />
and finally the printer friendly version template bugtracker_print:
<!-- Template: bugtracker_print --> <h2>{%title%}</h2> <strong>Bug Report</strong>: {%response_title%}<br /> <strong>Reported By</strong>: {%user_username%}<br /> <strong>Opened</strong>: {%response_date%}<br /> <strong>Priority</strong>: {%response_priority%}<br /> <strong>Affected Version</strong>: {%response_version%}<br /><br /> <strong>Description</strong>:<br /> {%response_text%} <hr /> Printed from: <a href="{%website_url%}/bugtracker/{%community_seo%}/">{%website_url%}/bugtracker/{%community_seo%}/</a>
Response Fields
The following fields are supported by the Contentteller response module:
text - for text fields
<field> <name>textfield</name> <text>Example Text Field</text> <description>This is an example text field</description> <type>text</type> <required>1</required> <error>The example text field is blank.</error> </field>
message_textarea - for the main message text area field
<field> <name>message</name> <text>Message</text> <description>This is the main message field</description> <type>message_text</type> <required>2</required> <error>The message field is blank.,You message need at least 6 characters.</error> </field>
textarea_mini - for a text area with 5 rows
<field> <name>textareamini</name> <text>Text Area Mini</text> <description>This is an example ext area mini field</description> <type>textarea_mini</type> <required>1</required> <error>The example text area mini field is blank.</error> </field>
textarea_small - for a text area with 10 rows
<field> <name>textareasmall</name> <text>Text Area Small</text> <description>This is an example text area small field</description> <type>textarea_small</type> <required>1</required> <error>The example text area small field is blank.</error> </field>
textarea - for a regular description text area with 20 rows
<field> <name>textarea</name> <text>Text Area</text> <description>This is an example text area field</description> <type>textarea</type> <required>1</required> <error>The example text area field is blank.</error> </field>
textarea_large - for a text area with 30 rows
<field> <name>textarealarge</name> <text>Text Area Large</text> <description>This is an example text area large field</description> <type>textarea_large</type> <required>1</required> <error>The example text area large field is blank.</error> </field>
link - for web links
<field> <name>weblink</name> <text>Example Weblink</text> <description>This is an example weblink field</description> <type>link</type> <required>1</required> <error>The example weblink field is blank.</error> </field>
dropdown - for dropdown menus
<field> <name>dropdown,Option 1,Option 2,Option 3,Option 4</name> <text>Example Dropdown Menu</text> <description>This is an example dropdown menu</description> <type>dropdown</type> <required>0</required> <error></error> </field>
checkbox - for checkboxes
<field> <name>checkbox,Option 1,Option 2,Option 3,Option 4</name> <text>Example Checkbox Options</text> <description>This are example checkbox options</description> <type>checkbox</type> <required>0</required> <error></error> </field>