Skip to content

Instantly share code, notes, and snippets.

@skurfuerst
Created July 19, 2015 08:06
Show Gist options
  • Save skurfuerst/67cd39915b7b33b6ec88 to your computer and use it in GitHub Desktop.
Save skurfuerst/67cd39915b7b33b6ec88 to your computer and use it in GitHub Desktop.
T3DD15 Neos Workshop Examples
<?php
/**
* Created by IntelliJ IDEA.
* User: sebastian
* Date: 18.07.15
* Time: 11:19
*/
namespace TYPO3\NeosDemoTypo3Org;
use TYPO3\Eel\FlowQuery\Operations\AbstractOperation;
class MySiblingsOperation extends AbstractOperation {
static protected $shortName = 'mySiblings';
//static protected $final = TRUE;
/**
* Evaluate the operation on the objects inside $flowQuery->getContext(),
* taking the $arguments into account.
*
* The resulting operation results should be stored using $flowQuery->setContext().
*
* If the operation is final, evaluate should directly return the operation result.
*
* @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
* @param array $arguments the arguments for this operation
* @return mixed|null if the operation is final, the return value
*/
public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments) {
$nodes = $flowQuery->getContext();
$results = array();
foreach ($nodes as $node) {
// start implementing the actual code:
/* @var \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node */
foreach ($node->getParent()->getChildNodes() as $potentialSiblingNode) {
if ($potentialSiblingNode !== $node) {
$results[] = $potentialSiblingNode;
}
}
}
$flowQuery->setContext($results);
//return 'Venue 1, Venue 2';
}
}
'TYPO3.NeosDemoTypo3Org:Session':
superTypes:
'TYPO3.Neos:Content': TRUE
ui:
label: Session
icon: 'icon-youtube'
inspector:
groups:
'session':
label: Session Options
position: 50
properties:
'name':
type: string
defaultValue: ''
ui:
label: 'Session Name'
reloadIfChanged: TRUE
inspector:
group: 'session'
'abstract':
type: string
defaultValue: 'Enter abstract here'
ui:
inlineEditable: true
'TYPO3.NeosDemoTypo3Org:Venue':
superTypes:
'TYPO3.Neos:Document': TRUE
ui:
label: Venue
inspector:
groups:
'venue':
label: Venue Options
position: 50
properties:
'name':
type: string
defaultValue: ''
ui:
label: 'Venue Name'
reloadIfChanged: TRUE
inspector:
group: 'venue'
'image':
type: 'TYPO3\Media\Domain\Model\ImageInterface'
ui:
label: 'Venue Image'
reloadIfChanged: TRUE
inspector:
group: 'venue'
{namespace neos=TYPO3\Neos\ViewHelpers}
{namespace ts=TYPO3\TypoScript\ViewHelpers}
<div>
<h2>Session: {name}</h2>
Menu Depth: {depth}
<neos:contentElement.editable property="abstract" />
</div>
<?php
/**
* Created by IntelliJ IDEA.
* User: sebastian
* Date: 18.07.15
* Time: 11:19
*/
namespace TYPO3\NeosDemoTypo3Org;
use TYPO3\Eel\FlowQuery\Operations\AbstractOperation;
use TYPO3\TypoScript\TypoScriptObjects\AbstractTypoScriptObject;
class SiblingValueGeneratorImplementation extends AbstractTypoScriptObject {
/**
* Evaluate this TypoScript object and return the result
*
* @return mixed
*/
public function evaluate() {
$numberOfSiblingsToShow = $this->tsValue('numberOfSiblingsToShow');
return "asdasfg: " . $numberOfSiblingsToShow;
}
}
{namespace neos=TYPO3\Neos\ViewHelpers}
{namespace ts=TYPO3\TypoScript\ViewHelpers}
{namespace media=TYPO3\Media\ViewHelpers}
<div>
<h2>VENUE {name}</h2>
<media:image image="{image}" alt="Haha" />
<p>Sibling Venues:
{siblingVenues -> f:debug()}
</p>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment