Page 1 of 1

How can I create a new static content type?

Posted: Tue May 08, 2012 5:14 am
by davidW
I'm trying to create a new static content type. By default, we have 3 types: "Homepage Banner Ad", "Homepage Small Ad" and "Message". The new type that I'm trying to create is a "Text block".
When I make my changes, all the site pages that load static content crash. For example:

Code: Select all

<cms:content contentType="Homepage Banner Ad" contentItemVar="item">
    <a href="${item.targetUrl}"><img src="${item.imageUrl}" /></a>
</cms:content>


This code from a jsp works before my changes. Then I create the new type of static content:

Code: Select all

-- Create template
INSERT INTO BLC_SC_FLD_TMPLT(SC_FLD_TMPLT_ID, NAME) VALUES(3, 'Textblock Template');

-- Add HTML field to the template
INSERT INTO BLC_SC_FLDGRP_XREF(SC_FLD_TMPLT_ID, FLD_GROUP_ID, GROUP_ORDER) VALUES (3,1,0);

-- Create type
INSERT INTO BLC_SC_TYPE (SC_TYPE_ID, NAME, DESCRIPTION, SC_FLD_TMPLT_ID) VALUES (4, 'Textblock', NULL, 3);


And the code in jsp doesn't work anymore. The error message says that there isn't a "targetUrl" property. I don't understand why if I create a new static content type (not modifying an existing type but creating it), other types lose their properties.
Now, in the admin page, I can create static content using the new type "Textblock", and I can edit the HTML text in its "body" field. But I can't see the results in the site because it crashes when it tries to get any property like here:

Code: Select all

<cms:content contentType="Textblock" contentItemVar="item">
    ${item.body}
</cms:content>


Does anyone know how to fix this? How can I create a new type of static content without affecting other types?

Thanks.

Re: How can I create a new static content type?

Posted: Sat May 26, 2012 6:41 pm
by jefffischer
I added your exact SQL changes and put your example content tag in a local instance of the demo that I set up. Everything seemed to work OK. The only thing I had to add was the following to bl-override-ehcache.xml so that the CMS cache would timeout quickly so I could test the changes:

Code: Select all

<defaultCache
        maxElementsInMemory="100000"
        eternal="false"
        overflowToDisk="true"
        timeToLiveSeconds="1"/>

    <!-- 1 hour cache -->
    <cache
        name="blCMSElements"
        maxElementsInMemory="10000"
        eternal="false"
        overflowToDisk="true"
        timeToLiveSeconds="1"/>

    <!-- Page Cache - 1 hour cache -->
    <cache name="cmsPageCache"
        maxElementsInMemory="1000"
        eternal="false"
        overflowToDisk="true"
        timeToLiveSeconds="1"/>

    <!-- Structured Content Cache - 1 hour cache -->
    <cache name="cmsStructuredContentCache"
        maxElementsInMemory="5000"
        eternal="false"
        overflowToDisk="true"
        timeToLiveSeconds="1"/>


I tested this using the latest version of the demo from the master branch in the GIT repository and used the 1.6.0-GA version of Broadleaf. I'll try it with the 1.5.5 version and post back, but I imagine the results will be the same.

Re: How can I create a new static content type?

Posted: Mon Jun 04, 2012 5:42 am
by davidW
Thank you jeff it is working with your change!!!