• Resolved zenigma

    (@zenigma)


    Hi,

    I’m having the following problem.

    I’d like to create three Controls (all part of one repeater control) for the creation of one CSS line.

    Now in the past I’ve been able to call values from other controls by using {{id_of_another_control.VALUE}}, {{id_of_another_control.SIZE}} or {{id_of_another_control.UNIT}} etc. But inside of a Repeater control I’m having troubles accomplishing this. Is this something that has yet to be implemented or am I unfamiliar to the syntax?

    Ex:

    
    $repeater = new Repeater();
    
    //here I've created two repeater controls with the id's: ID_OF_MAIN_COLOR and ID_OF_SECONDARY_COLOR. Commented out to spare the reader of too much code.
    
    $repeater->add_control( 'tertiary_color', [
    'label'  => __( 'Tertiary Color', $this->text_domain ),
    'type'   => Controls_Manager::COLOR,
    'scheme' => [
        'type'   => Scheme_Color::get_type(),
        'value'  => Scheme_Color::COLOR_1,
        ],
    'default'   => 'rgb(255, 255, 255)',
    'selectors' => [
       '{{WRAPPER}} {{CURRENT_ITEM}}' => 'background: radial-gradient(circle at 50% 55%, {{ID_OF_MAIN_COLOR.VALUE}} 40%, {{ID_OF_SECONDARY_COLOR.VALUE}} 60%, {{VALUE}});',
        ]
    ]
    );
    

    Another question concerning ‘condition’ (in a repeater control). I’ve read somewhere that non-repeater controls are outside of the bound of a Repeater control, therefore not accessible in the ‘condition’-field. Is this still the case?

    Ex:

    
    $this->add_control(
    'bubble_fixed_sizes', [
       'label' => __( 'Use a Fixed Size?', $this->text_domain ),
       'type' => Controls_Manager::SWITCHER,
       'default' => 'no',
    ]
    );
    
    //Now I can't seem to use 'bubble_fixed_sizes' inside of a 'condition'-case in a $repeater->add_control();
    

    Hope this was the right place to ask these questions. I have been searching quite a bit on the web and went through the documentations, but there wasn’t much to find concerning these two topics (especially ‘selectors’; might be nice to have that documented somewhere, concerning keys like: {{WRAPPER}}, {{CURRENT_ITEM}}, obtaining values from other controls, etc.).

    Wanted to post this on GitHub but wasn’t sure whether this was a bug or just a lack of knowledge on my side concerning the Repeater Control.

    Thanks in advance!

    • This topic was modified 6 years, 4 months ago by zenigma.
    • This topic was modified 6 years, 4 months ago by zenigma. Reason: Fixed some mistakes in the shared code
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Using ‘selectors’ and ‘condition’ in a Repeater Control.’ is closed to new replies.