Login / Status
developer.Resource
Home . Documentation . Document Library . Extension Manuals
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

5.3. Adding a Custom Resource Type

One of the highly flexible portions of the SMS extension is the ability to create custom resources, select properties for the resources, and define how the resources will be shown in the Frontend. This is accomplished by defining a new Resource Type.

Caution: The rest of this section assumes the reader has an understanding of template records, TypoScript, cObjects, and how to use these in conjunction to provide Frontend output. For assistance with this, see the Support section of www.webempoweredchurch.com. WEC provides a self-help Community forum, and a list of third party providers who may assist you in your needs.

There area two steps to create and use a custom resource type for the SMS extension. Those steps are as follows:

  1. Create a new SMS Resource Type record and TypoScript Object

  2. Modify the SMS template file, inserting new markers as needed

Example Addition of a New Resource Type

Let's suppose your organization stores the Study Guides of each sermon in Adobe PDF files. You would like to make the file available for download, but would also like a preview of the document next to the document link. You would prefer the preview be generated from the first document page, rather than uploading a separate thumbnail image for every file. SMS Resource template markers alone will not accomplish this, but you can use the output from the TypoScript Object along with the ###RESOURCE_CONTENT### template marker to display this output.

Begin by logging into the TYPO3 Backend with an administration login. You must have administration privileges in order to modify template records.

Step 1: Creating a New Resource Type

Illustration 47: Adding a New Plugin Resource Type 1

  1. Refer to Illustration 47. Click on the List Module in the Backend (1).

  2. Click on the SMS Storage Folder (2).

  3. Click on the Create New Record icon in the upper right corner of the screen (3).

Illustration 48: New Plugin Resource Type 2

  1. Refer to Illustration 48. Scroll down and click on SMS Resource Types (4) to create a new resource type record.

  1. Illustration 49: New Plugin Resource Type

    Refer to Illustration 49. In the new SMS Resource Type record, fill in the Title, Marker Name, and TypoScript Object Fields, along with any other fields you require (5).

    Note: The Template Name field, if left empty, will be assumed as TEMPLATE_{marker name} at run-time. In this example, the template name would be assumed as TEMPLATE_SERMON_GUIDE

  1. Refer to Illustration 50. Scroll down the page to t

    Illustration 50: Add File Field to Resource Type

    he Visible Resource Fields. Click the File item to add the file field to this resource type (6). This allows you to upload a file directly into this Sermon Guide resource type.

  2. Click the Save & Close button (7).

Step 2: Modify the Template File

After creating the SMS Resource Type records, you need to modify the existing template file and add markers for the new SMS Resource Type.

Tip: See the Modifying the Layout Template portion of this document, under the Advanced Options section, for details on making a copy of the existing template file for modification.

  1. Illustration 51: Edit the Template Resource

    Refer to Illustration 51. Click on the Template module. (1)

  2. Click the page name Sermon, (or other location where the template record for SMS is stored.) (2)

  3. Choose Info/Modify from the drop down menu in the upper right of the screen. (3)

  4. Click the Edit pencil image, to the left of Resources: which opens another edit page. (4)

  1. Illustration 52: Edit the SMS Template Resource

    Refer to Illustration 52. Click on the Edit pencil image on the wecsermons.tmpl record of the UPDATE RESOURCE LIST (5).

  2. Illustration 53: Edit the Template, Insert the Sermon Guide Marker

    Refer to Illustration 53. Find the template you wish to modify and insert the Sermon Guide marker: <!--###SERMON_GUIDE###--> ###RESOURCE_CONTENT###<!--###SERMON_GUIDE###--> (6)The template marker, ###SERMON_GUIDE### sets the start and end point where the output for a sermon guide will be placed in the template. The marker ###RESOURCE_CONTENT### tells the SMS to show the Sermon Guide using the TypoScript object.

  1. Illustration 54: Insert the Sermon Subpart Marker

    Refer to Illustration 54. Insert a subpart marker for the Sermon Guide template (7). The Sermon Guide template is used to display the single view of a Sermon Guide Resource.

  2. Refer to Illustration 53 again. Click the Update button to save your changes to the template file.

Step 3: Create a New TypoScript Object

In some circumstances you may not get all that you need out of a new resource type, using template markers alone. This is the point that TypoScript takes over, giving you advanced control of how your custom resource type is shown.

Illustration 55: TypoScript Object Name Field in an SMS Resource Type Record

Technical Stuff: For every resource type, there is a ###RESOURCE_CONTENT### marker that renders TypoScript content objects (cObjects). Within the setup field of a template record, you can use TypoScript to configure this advanced output of your custom resources. This is accomplished by adding new properties to the resource_type cObject array.

The resource_type cOjbect:

plugin.tx_wecsermons_pi1.resource_types = CASE

The resource_types object is a CASE content object (cOjbect). This object contains an array that defines how to display each resource type on the Frontend. Each array property name is defined by the TypoScript Object Name field of the SMS Resource Type record (see Illustration 55).

Example TypoScript Code

plugin.tx_wecsermons_pi1.resource_types {

       

        # PDF (Portable Document)

        pdf = COA

        pdf {

        ...

        }

       

        # Flash video

        flv = COA

        flv {

...

        }

       

        # MP3 Audio

        mp3 = COA

        mp3 {

...

        }

       

 # Sermon Guide

        sermonguide = COA

        sermonguide {

...

        }

 # Other custom resources

 ...

       

}

Text 1: TypoScript Example for Custom Resources

To create a new TypoScript Object, begin by logging into the TYPO3 Backend with an administration login.

  1. Refer to Illustration 56

    Illustration 56: Adding TypoScript for a New Resource 1

    . Click on the Template Module (1).

  2. Click on the page where the SMS Static Template is installed on your site—typically either the Root Page (Home) or the Sermons page (2).

  3. Click the upper right dropdown, and select Info/Modify (3).

  4. Click the Edit icon (pencil) to the right of Setup (4).

  1. Refer to Illustration 57

    Illustration 57: Adding TypoScript for a New Resource

    . Insert your new TypoScript code (5) to update the resource_types object array, creating a new definition for SermonGuide. (See Text 1 below for example code.)

  2. Click the Update button to save your changes (6).

Example TypoScript Code

plugin.tx_wecsermons_pi1.resource_types {

        # Sermon Guide (PDF format)

        # Use COA, content object array, to output multiple types of content at once

        SermonGuide = COA
        SermonGuide {

         # Use the image cObject to output a preview of the PDF file

          10 = IMAGE
          10 {
           prefixComment = 2 | Sermon Guide Preview:

           altText.field = title

           file.import = uploads/tx_wecsermons/

           file.import.field = file

           file.width = 150m

           file.height = 150m

           wrap = <div class="tx-wecsermons-pi1-sermonguide-preview" style="float: left;">|</div>

             stdWrap.typolink {

             parameter = uploads/tx_wecsermons/{field:file}
               parameter {
                 setCurrent.field = file
                 setCurrent.listNum = 0
                 insertData = 1  
                         }
                        }
                }
        

         # Use the text cObject to output the title of this resource, wrapping the title

         # in a link to the file attachment

          20 = TEXT
          20.prefixComment = 2 | Sermon Guide File Link:
          20.field = title
          20.typolink {
                       parameter = uploads/tx_wecsermons/{field:file}
                       parameter.insertData = 1
                      }
          20.wrap = <p class="bodytext">|</p>
        
          30 = TEXT
          30.field = description
          30.parseFunc < plugin.tx_wecsermons_pi1.general_stdWrap.parseFunc
       
     wrap = <div class="tx-wecsermons-pi1-sermonguide">|</div>
        }

}

Text 1: Example TypoScript Code for Illustration 49

Above is the example code needed for Illustration 55. This is obviously a complicated example, so take a look at the Simplified TypoScript Example section below for more detail.