To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Ticket #433 (closed enhancement: fixed)

Opened 20 months ago

Last modified 13 months ago

Variants for Slots - Default value for allowed_variants should bean empty array

Reported by: johnnyoffline Owned by: tboutell
Priority: major Milestone: 1.4.2
Component: apostrophePlugin Version: 1.4
Keywords: slots, variants, syntax Cc: agilbert, rickybanister, jake, dordille, geoffd, boutell, johnnyoffline
Symfony version: 1.4

Description

First, I have to say Variants are awesome. They offer a level of flexibility with such minimal overhead for implementation, it's awesome. love it love it.

BUT, All this awesomeness has to come with some kind of catch right?,

In practice, if you have one or two variants for a single slot and it's OK if that custom functionality ripples throughout every template throughout an entire site, the we're OK.

BUT, as soon as you have variants for 4 slots and 6 templates, and you want to allow or more importantly DISALLOW certain variants in some templates vs. another, you find yourself pasting this, ALOT:

'allowed_variants'=> array()

Example Slideshow Slot with Variants:

    slot_variants:
      aSlideshow:
        normal:
          label: Normal
          options:
            interval: 0
            title: false
            description: false            
            arrows: true
        autoplay:
          label: Auto Play
          options:
            interval: 6
            title: true
            description: false
            arrows: true
        full:
          label: Full Info
          options:
            title: true
            description: true
            arrows: true
        inset_left:
          label: Inset Left
          options:
            width: 200
            height: 130
            resizeType: c
            flexHeight: false
            interval: 6            
            arrows: false
            title: false
            description: false
        inset_right:
          label: Inset Right
          options:
            width: 200
            height: 130
            resizeType: c
            flexHeight: false            
            interval: 6            
            arrows: false
            title: false
            description: false
        callout:
          label: Call Out
          options: 
            width: 345
            height: 260
            resizeType: c
            flexHeight: false
            arrows: true
            title: true
            description: true

Across six templates, I have to disallow all of these variants first, then selectively turn on which variants I want to allow the editor access to.

Now Take the above app.yml snippet and extrapolate it across 4 or 5 slots, aImage, aVideo, aPDF, aSlideshow, aButton.

Then implement this into 2 or 3 Areas in a single template.

Then do it in the 6 page templates a modest sized site uses.

That's a lot of typing just to have the ability to create a few variants and say this one specific spot can use this one specific customization.

The end result is, creating variants and having them automatically enabled blows up a lot of stuff. I should be able to create my variants and selectively sprinkle them around, only granting slots access to them.

Otherwise, you end up with area calls in a template that look like this:

<?php a_area('body', array(
	'allowed_types' => array(
		'aRichText', 
		'aSlideshow', 
		'aVideo', 
		'aImage', 
		'aFeed', 
		'aPDF',		
		'aButton', 		
		'aText',
		'aRawHTML',
	),
  'type_options' => array(
		'aRichText' => array('tool' => 'Main'), 	
		'aSlideshow' => array("width" => 480, "flexHeight" => true, 'arrows' => true, 'constraints' => array('minimum-width' => 480), 'allowed_variants'=> array()),
		'aVideo' => array('width' => 480, 'flexHeight' => true, 'resizeType' => 's', 'allowed_variants'=> array()),		
		'aImage' => array('width' => 480, 'flexHeight' => true, 'resizeType' => 's', 'constraints' => array('minimum-width' => 480), 'allowed_variants' => array('normal','inset_left', 'inset_right')),
		'aFeed' => array('allowed_variants'=> array()),
		'aButton' => array('width' => 480, 'flexHeight' => true, 'resizeType' => 's', 'constraints' => array('minimum-width' => 480), 'allowed_variants'=> array()),
		'aPDF' => array('width' => 480, 'flexHeight' => true, 'resizeType' => 's', 'allowed_variants'=> array()),		
	))) ?>
	
<?php a_area('sidebar', array(
	'allowed_types' => array(
		'aRichText', 
		'aSlideshow', 
		'aVideo', 
		'aImage', 
		'aFeed', 
		'aPDF', 		
		'aButton', 
		'aText',
		'aRawHTML', 		
	),
  'type_options' => array(
		'aRichText' => array('tool' => 'Sidebar'),
		'aSlideshow' => array('width' => 200, 'flexHeight' => true, 'resizeType' => 's', 'constraints' => array('minimum-width' => 200), 'allowed_variants' => array()),		
		'aVideo' => array('width' => 200, 'flexHeight' => true, 'resizeType' => 's', 'allowed_variants'=> array()),				
		'aImage' => array('width' => 200, 'flexHeight' => true, 'resizeType' => 's', 'constraints' => array('minimum-width' => 200), 'allowed_variants' => array()),
		'aFeed' => array('allowed_variants'=> array()),		
		'aButton' => array('width' => 200, 'flexHeight' => true, 'resizeType' => 's', 'constraints' => array('minimum-width' => 200), 'allowed_variants'=> array()),
		'aPDF' => array('width' => 200, 'flexHeight' => true, 'resizeType' => 's', 'allowed_variants'=> array()),		
	))) ?>

Lots of empty arrays.

Change History

Changed 20 months ago by boutell

  • status changed from new to accepted

I hear you, but this breaks everybody's use of the currently documented variants feature. We'd need to enable this behavior in app.yml with something like app_a_variants_default_to_none. We can put that in the sandbox project and document the new behavior, so it'll be the new default with pknewsite, but we can't break people's existing projects by leaving out the app.yml check.

Changed 20 months ago by boutell

Actually, we could have app_a_allowed_variants which would actually let you set the default list of allowed variants for each slot type (if allowed_variants appears in the template it overrides this). If you just set it to ~ then all slots default to allowing no variants. If you want to allow some variants for some slots by default you can... this would be the bomb

Changed 20 months ago by boutell

Fixed in [1569]. See below for how to enable this behavior:

The new app_a_allowed_slot_variants setting determines which slot variants are permitted by default. You can always override it with an explicit allowed_variants option in an a_slot or a_area call. If your variants are typically specific to a page template, set app_a_allowed_slot_variants and leave it empty (as we now do in the sandbox project). If your variants are sometimes OK for use in all templates and sometimes not, provide a hash of lists of allowed variant names by slot name (see app.yml in the sandbox project for a commented-out example). As always the first allowed variant is the default behavior that you see on the first save of a slot.

Changed 17 months ago by tboutell

  • owner changed from boutell to tboutell

Changed 13 months ago by geoffd

  • status changed from accepted to closed
  • resolution set to fixed

Tom forgot to close this.

Note: See TracTickets for help on using tickets.