Integrating a JavaScript-based slider

Partly Outdated

This documentation is still correct, but we would write Fusion now differently and use AFX rendering. Please read our manual to understand how you would build modern NodeTypes. 

Especially instead of reusing the Neos.NodeTypes:Image NodeType, we would strongly recommend to create your own Vendor.Site:Content.Carousel.Item

If you want to integrate a Slider into your page as content element or as part of your template and want edit it in the backend you have do some simple steps.

First you have to use a slider javscript plugin which initializes itself when added to the page after page load. Or you write your own initialization code into a javascript function which you then add as callback for the neos backend events.

For this example the carousel plugin and styling from bootstrap 3.0 has been used:http://getbootstrap.com/javascript/#carousel

To create the basic content element you have to add it to your node types.

DistributionPackages/Vendor.Site/Configuration/NodeTypes.Content.Carousel.yaml
'Vendor.Site:Carousel':
  superTypes:
    'Neos.Neos:Content': true
  childNodes:
    carouselItems:
      type: 'Neos.Neos:ContentCollection'
  ui:
    label: 'Carousel'
    group: 'plugins'
    icon: 'icon-picture'
    inlineEditable: true

Next you need to define the prototype for the slider in Fusion.

Fluid rendering only

Below you can see how this would be rendered in Fluid. In AFX you would be able to use it as a prop, for more read the AFX documentation.

DistributionPackages/Vendor.Site/Resources/Private/Fusion/Content/Carousel/Carousel.fusion
prototype(Vendor.Site:Content.Carousel) {
   carouselItems = Neos.Neos:ContentCollection {
      nodePath = 'carouselItems'
      content.iterationName = 'carouselItemsIteration'
      attributes.class = 'carousel-inner'
   }

   // Collect the carousels children but only images
   carouselItemArray = ${q(node).children('carouselItems').children('[instanceof Neos.NodeTypes:Image]')}

   // Enhance image prototype when inside the carousel
   prototype(Neos.NodeTypes:Image) {
      // Render images in the carousel with a special template.
      templatePath = 'resource://Vendor.Site/Private/Templates/FusionObjects/CarouselItem.html'

      // The first item should later be marked as active
      attributes.class = ${'item' + (carouselItemsIteration.isFirst ? ' active' : '')}

      // We want to use the item iterator in fluid so we have to store it as variable.
      iteration = ${carouselItemsIteration}
   }
}

For rendering in the old Fluid template language, you need the fluid templates for the slider.

DistributionPackages/Vendor.Site/Resources/Private/Templates /FusionObjects/Carousel.html
{namespace neos=Neos\Neos\ViewHelpers}
{namespace fusion=Neos\Fusion\ViewHelpers}
 f:format.raw()}>
	

And now the fluid template for the slider items.

DistributionPackages/Vendor.Site/Resources/Private/Templates /FusionObjects/CarouselItem.html
{namespace neos=Neos\Neos\ViewHelpers}
{namespace media=Neos\Media\ViewHelpers}
 f:format.raw()}>
	
		
			
		
		
			Dummy image