Commit 64e6a5bf authored by bbaer's avatar bbaer
Browse files

initial commit

parents
/fluid_bs.zip
/.idea
# Created by .ignore support plugin (hsz.mobi)
<?php
/**
* @author Benjamin Baer <benjamin.baer@math.uzh.ch>
*/
namespace UNIVERSITY_OF_ZURICH\Fluid_bs\Controller;
class Fluid_bsController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
public function showAction() {
$this->view->assign('fluid_bsOutput', '<strong>' . uniqid() . '</strong>');
return $this->view->render();
}
}
\ No newline at end of file
mod.wizards.newContentElement {
wizardItems {
special.elements {
fluid_bs_element {
icon = icon goes here
title = fluid_bs Content Element
description = More info goes here
tt_content_defValues {
CType = fluid_bs_fluid_bs
}
}
}
special.show := addToList(fluid_bs_element)
}
}
\ No newline at end of file
all: archive
archive: clean fluid_bs.zip
fluid_bs.zip: Classes Configuration Resources ext_emconf.php ext_localconf.php ext_tables.php
zip -r $@ $^
clean:
rm -f fluid_bs.zip
Typo3 Extbase Extension Rundown
===============================
* This template is configured to be used as a template for frontend extensions, used to render tt-content records.
* To create a new extension based on this template:
Start:
git clone git@git.math.uzh.ch:typo3/typo3_sample_extension.git
cd typo3_sample_extension
# customize configure.sh by providing extension_key, plugin_name, author name, author email address.
# The following script will rename the current directory to the extension_key name.
./configure.sh
Go to the "Typo3 Backend > Extension manager", upload/install the extension zip file,
clear the Typo3 cache, create a new tt-content record of type 'extension key'.
In the frontend you should see a uniq id - a new one on every page load.
Change `/<extensionkey>/Classes/Controller/<Name>Controller.php` to your needs.
General
=======
For the simplest possible extbase extension, following directories and files are required:
/<extensionkey>/
/<extensionkey>/Classes/Controller/<Name>Controller.php
/<extensionkey>/Configuration/PageTSconfig/PageTSconfig.ts
/<extensionkey>/Resources/Private/Template/<Name>/<Action>.html
/<extensionkey>/ext_emconf.php
/<extensionkey>/ext_localconf.php
/<extensionkey>/ext_tables.php
* `<extensionkey>` is the extension key all lower-case.
* `<Name>` is the name of a controller, and is also used in `ext_localconf.php`.
* `<Action>` is the name of a controller action, e.g. `show` or `list`
ext_tables.php
--------------
In `ext_tables.php`, we make the plugin available to the backend by calling
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
/* The extension name in UpperCamelCase */
'Imath.' . $_EXTKEY,
/* Plugin name in UpperCamelCase. Must be unique */
'SamplePluginName',
/* Plugin title. Used in backend drop down menu */
'Sample Element',
'<Path to Icon>'
);
After calling this method, the plugin is made availabe in the backend. However, it has no functionality, yet.
The items shown in the backend, can are configured by using
$GLOBALS['TCA']['tt_content']['types']['sampleextension_samplepluginname'] = array(
'showitem' => 'CType, header, bodytext'
);
The last key is derived from the extension key and plugin name by lowercase concatenation. In the example above, the
extension key is `sampleextension` and the plugin name `SamplePluginName` (the same name used when calling
`registerPlugin()`).
ext_localconf.php
-----------------
In `ext_localconf.php`, we configure the plugin behavior by calling
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
/* The extension name in UpperCamelCase */
'Imath.' . $_EXTKEY,
/* Plugin name in UpperCamelCase. Must be unique */
'SamplePluginName',
/* Controller Actions */
array('Sample' => 'show'),
/* Non-Cacheable Controller Actions */
array('Sample' => 'show'),
/* Plugin Type */
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);
The first two arguments of `configurePlugin()` are identical to the call of `registerPlugin()` in `ext_tables.php`.
The Controller Actions are an assoc array, where the key refers to the name of the controller. When looking for the
controller class, extbase adds `Controller` to the key and looks for a class in `Classes/Controller/`. In the example
above, `Sample` becomes `SampleController`. Further, the class must be defined in a namespace
`Imath\$_EXTKEY\Controller` (the namespace is derived from the extension name).
The value of the key are the actions exposed by the controller. Typo3 finds the method to call on the controller
class by adding `Action` to the action, e.g., `show` becomes `showAction`.
If it is not desired to have the output of the controller cached, add the controller action in the same fashion to an
assoc array and pass that as third argument to `configurePlugin()`.
Templates & Controllers
-----------------------
Templates should be living under
`Resources/Private/Templates`. By convention, the template for a given controller action is located by looking at the
name of the controller class and stripping off `Controller`. For instance, if the controller is named
`SampleController`, Typo3 looks for a directory `Sample` beneath `Resources/Private/Templates`. It then looks at the
name of the controller action (method) and strips off `Action`, thus, in our example, `showAction()` becomes `show`
and Typo3 tries to locate the template file `Show.html` in the `Sample` directory.
The controller action can create variables, that are available in the corresponding template, by calling
`$this->view->assign('<variableName>', <value>)`.
All controllers should be put into `Classes/Controller`. The controller in the sample is defined as follows
namespace Imath\Sampleextension\Controller;
class SampleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
public function showAction() {
$this->view->assign('sampleOutput', '<strong>' . uniqid() . '</strong>');
return $this->view->render();
}
}
When we put the content element on a page, Typo3 knows because of the call to `configurePlugin()` in `ext_localconf
.php`, that the `SampleController` is in charge of the content element.
\ No newline at end of file
<p>
<f:format.raw value="{fluid_bsOutput}"/>
</p>
\ No newline at end of file
#!/bin/bash
EXTENSION_KEY=fluid_bs
PLUGIN_NAME=fluid_bs
AUTHOR_NAME="Benjamin Baer"
AUTHOR_EMAIL="benjamin.baer@math.uzh.ch"
ORGANIZATION="University of Zurich"
#-------------------------------------------------------
# all configuration done - do not change something below
#-------------------------------------------------------
# Make all lowercase and remove unwanted chars
EXTENSION_KEY="${EXTENSION_KEY,,}"
EXTENSION_KEY=`echo "${EXTENSION_KEY}" | tr -c '[a-zA-Z0-9\n]' '_'`
# Make leading camelhook
EXTENSION_KEY_CAMEL="${EXTENSION_KEY^}"
# Make all lowercase and remove unwanted chars
PLUGIN_NAME="${PLUGIN_NAME,,}"
PLUGIN_NAME=`echo "${PLUGIN_NAME}" | tr -c '[a-zA-Z0-9\n]' '_'`
# Make leading camelhook
PLUGIN_NAME_CAMEL="${PLUGIN_NAME^}"
# Sanatize Author
AUTHOR_NAME=`echo "${AUTHOR_NAME}" | tr -c '[a-zA-Z0-9\.\-\n ]' '_'`
AUTHOR_EMAIL=`echo "${AUTHOR_EMAIL}" | tr -c '[a-zA-Z0-9@\.\-_\n]' '_'`
AUTHOR_FULL="${AUTHOR_NAME} <${AUTHOR_EMAIL}>"
# Sanatize Organization
ORGANIZATION=`echo "${ORGANIZATION}" | tr -c '[a-zA-Z0-9\n]' '_'`
ORGANIZATION="${ORGANIZATION^^}"
#--------------------------------------------------
function doResources() {
mv Resources/Private/Templates/Sample Resources/Private/Templates/${EXTENSION_KEY_CAMEL}
}
#--------------------------------------------------
function doController() {
mv Classes/Controller/SampleController.php Classes/Controller/${EXTENSION_KEY_CAMEL}Controller.php
}
function replaceAll() {
ALL=`find . -name "*.php" -type f ; find . -name "*.ts" -type f; find . -name "*.html" -type f; find . -name "Makefile" -type f; find . -name ".gitignore" -type f`
for FILE in $ALL ; do
sed -i "s/AUTHOR_FULL/${AUTHOR_FULL}/g" $FILE
sed -i "s/AUTHOR_NAME/${AUTHOR_NAME}/g" $FILE
sed -i "s/ORGANIZATION/${ORGANIZATION}/g" $FILE
sed -i "s/EXTENSION_KEY_CAMEL/${EXTENSION_KEY_CAMEL}/g" $FILE
sed -i "s/EXTENSION_KEY/${EXTENSION_KEY}/g" $FILE
sed -i "s/PLUGIN_NAME_CAMEL/${PLUGIN_NAME_CAMEL}/g" $FILE
sed -i "s/PLUGIN_NAME/${PLUGIN_NAME}/g" $FILE
done
}
function renameCwd() {
if [ -e ../$EXTENSION_KEY ] ; then
echo "Directory not renamed: another file already exist"
exit -1
fi
OLD_DIR=`pwd`
cd ..
mv $OLD_DIR $EXTENSION_KEY
cd $EXTENSION_KEY
}
function removeGit() {
chmod -R u+rwx .git
rm -R .git
}
#============
#--- Main ---
replaceAll
doController
doResources
# Remove old 'git' config
removeGit
# At the end: rename own directory
renameCwd
make archive
cat <<EOF
GIT: The .git directory has been removed. Start from scratch.
Typo3: Import this extension now by uploading and installing ${EXTENSION_KEY}.zip
CWD: `pwd`
EOF
<?php
/**
* @author Benjamin Baer <benjamin.baer@math.uzh.ch>
*/
$EM_CONF[$_EXTKEY] = array(
'title' => 'fluid_bs Extension',
'description' => 'fluid_bs Extension',
'category' => 'Frontend',
'author' => 'Benjamin Baer',
'dependencies' => 'fluid,extbase',
'clearcacheonload' => true,
'state' => 'alpha',
'version' => '0.1.0'
);
\ No newline at end of file
<?php
/**
* @author Benjamin Baer <benjamin.baer@math.uzh.ch>
*/
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'UNIVERSITY_OF_ZURICH.' . $_EXTKEY,
'Fluid_bs',
array('Fluid_bs' => 'show'),
array('Fluid_bs' => 'show'), // put here as well, if controller output must not be cached
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:fluid_bs/Configuration/PageTSconfig/PageTSconfig.ts">');
// By default, the 'tt_content' Header will be rendered: Avoid this,cause it's much nicer to use the header in the backend as a description title of what the record does.
$addLine = '
tt_content.fluid_bs_fluid_bs = COA
tt_content.fluid_bs_fluid_bs {
10 >
}
';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($_EXTKEY, 'setup', '# Setting ' . $_EXTKEY . $addLine . '', 'defaultContentRendering');
<?php
/**
* @author Benjamin Baer <benjamin.baer@math.uzh.ch>
*/
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'UNIVERSITY_OF_ZURICH.' . $_EXTKEY,
'Fluid_bs',
'Fluid_bs Element',
'[none]'
);
/*
* The type name is generated by combining the extension key and plugin name, all lowercase and concatenated with `_'
*/
$GLOBALS['TCA']['tt_content']['types']['fluid_bs_fluid_bs'] = array(
'showitem' => 'CType, header, bodytext'
);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment