Feature #22388

Add simple API for creating new content elements

Added by Jeff Segars about 11 years ago. Updated almost 6 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Sprint Focus:


The basic idea is to add some very simple way to create new content elements that can be shared among TYPO3 installations as extensions. The scope is very similar to FCEs with the difference being that they do not require TemplaVoila, are quicker to create (no mapping) and are much more easily shared and updated (extensions instead of T3Ds).

For PHP developers, this offers a more rapid way to add custom contenet when a full extension would be overkill. This also opens up some doors for site builders who are not PHP developers. If they know Typoscript and FlexForm XML, they can add new content elements.

As far as technical details go, this ends up being a pairing of Flexforms for backend data entry and nothing but TypoScript for frontend output.

We've already made an initial attempt at doing this sort of thing in the WEC Content Elements extension [1] so I'll attempt to describe what we did there. It's nothing earth shattering at all, but the non-developers who have see it really like it.

1. Add a simple PHP API for telling TYPO3 about the new content element (Something like this could easily live in t3lib_extMgm) =======================================================================
tx_weccontentelements_lib::addContentElement($_EXTKEY, 'youtube') adds the necessary entries to the TCA and New Content Element Wizard. Locallang paths, icons, and flexform paths can all be defined but there's a simple convention that should work 95% of the time.

tx_weccontentelements_lib::addTyposcript($_EXTKEY, 'youtube') adds the TypoScript needed for frontend output. This TS is very similar to what the built in content elements use. As a quick example, see [2] which embeds YouTube on a page.

2. Add ability to read FlexForm data from TypoScript via getData (This could be an enhancement to tslib_cObj) =======================================================================
If we're writing extensions that are simply FlexForm XML and TypoScript, then we need a bridge between the two. Many people have done this before and its really pretty simple with the hooks for getData already. Perhaps its time to bring this into the core.

The syntax for our implementation looks something like this:
t3datastructure : pi_flexform->width

You can see more details at [2]

3. Add ability to loop over FlexForm sections (This could be an enhancement to tslib_cObj) =======================================================================
Once we can read simple values from FlexForms, the next obvious step is to operate on sections. This is useful for something like a slideshow content element that contains multiple images.

An example of our implementation is in line 139 and following at [3]. We have new FFSECTION cObject that is responsible for iterating over sections and it requires a rootPath to iterate over. Within that, getData is extended with a new flexformSection keyword that reads FlexForm values relative to the root path.

4. Add ability to insert header data from a content element (This could be a pageRenderer enhancement) =======================================================================
Since many of these content elements will be widgets implementing Javascript functionality, it only makes sense to have some way that they can add header data to the page but only when the content element is actually in use.

In wec_contentelements we've added a HEADERDATA cObject that is an idea Olly had prior to the pageRenderer. A better solution would enhancing the pageRenderer somehow.

[1] http://typo3.org/extensions/repository/view/wec_contentelements/current/
[2] http://svn.webempoweredchurch.org/projects/contentelements/repository/entry/trunk/wec_contentelements/youtube/content.ts
[3] http://svn.webempoweredchurch.org/projects/contentelements/repository/entry/trunk/wec_contentelements/slideshow/content.ts#L139

(issue imported from #M14015)


T3X_ce_test-1_0_0-z-201004061820.t3x (5.2 KB) T3X_ce_test-1_0_0-z-201004061820.t3x Administrator Admin, 2010-04-07 01:25
14015.diff (9.15 KB) 14015.diff Administrator Admin, 2010-04-07 01:26

Updated by Jeff Segars about 11 years ago

Added patch file for trunk along with a simple demo extension.

Before submitting to the core list, the patch should be split into several parts...
1) Content element helper functions in t3lib_extMgm
2) Flexform-related enhancements to tslib_content
3) Ability to add headerData from within content element (still needs more work, only a primitive solution for now).


Updated by Benni Mack about 11 years ago

The approach sounds right. I'd split up the patch in three RFCs as well.

1) t3lib_extMgm seems to be the right spot, "addContentElement" is not correct for the naming, "addContentType" or "addPlugin"

2) Just make sure that it's possible to fetch from any generic XML field from getData
stdWrap.data = field:pi_flexform:ROOT->sheet1->field_myfield

3) Maybe we should also call this XMLSECTION?



Updated by Jeff Segars about 11 years ago

Thanks for the feedback Benni!

For #1, the goal is to add a standard content element just like text, text w/ image, etc so I think addContentElement fits more closely than anything plugin related.

#2 - Sounds good.

#3 - My only thinking here is that the idea of sections is closely related to t3datastructure and FlexForms so there might be some value in including that in the cObject name.

Since the feature freeze for 4.4 is here and I hate to rush this through and be stuck with some bad decisions later on, I'll hold off until 4.5 and put my efforts today into reviewing other patches. This will still be available as an extension using various hooks in the core and we can revisit again later.


Updated by Alexander Opitz about 7 years ago

  • Target version deleted (0)

Hi Jeff,

the issue is rather old, some things changed and maybe some not. Can you please write what thinks from your ideas are not done yet?


Updated by Susanne Moog almost 6 years ago

  • Status changed from Accepted to Closed
  • Assignee deleted (Jeff Segars)

I'm closing this ticket as there has been no feedback for quite some time and with fluid and fluid based content elements in version 7 I guess this ticket is solved.

Also available in: Atom PDF