Kirki: Enhancement: repeater field row's label

Created on 6 Apr 2016  Â·  17Comments  Â·  Source: kirki-framework/kirki

Hi Ari,

I am David from SingleStroke, we talked on email :)

I have a new feature suggestion. Just wondering if you can add a new argument when defining a repeater field, something like row_label. It works as a label for each row. When all rows are collapsed, it's a bit difficult to figure out which row which contains a specific value. The new attribute would bind a field's value inside the row, and change the label of each row.

For example:
I have a repeater field for "Social media links". Each row will have 2 fields, social_media and url. Say we filled it with 2 rows, currently it shows like this (on the Customizer):

  1. .............. [sort] [v] [x]
    social_media : "facebook"
    url: "http://facebook.com/mypage"
  2. .............. [sort] [v] [x]
    social_media : "twitter"
    url: "http://twitter.com/mytweets"

There should be an indicator on the row panel which row is "facebook" and which one is "twitter". It should be like this:

  1. facebook... [sort] [v] [x]
    social_media : "facebook"
    url: "http://facebook.com/mypage"
  2. twitter........ [sort] [v] [x]
    social_media : "twitter"
    url: "http://twitter.com/mytweets"

So when all the rows are collapsed, users would still know which row is "facebook" and the others. The row_label attribute declaration could be something like this:

    'row_label' => array(
        'value_from_field' => 'social_media',
    ),

Whenever user change the social_media field inside a row, the row_label would change to the new value.

What do you think?

Cheers!

feature

Most helpful comment

@PlayerThemes This overwrites button labels for the whole project. Is there a way to change a button label per repeater?

All 17 comments

+1 on this one.

I think it would be great to:
1) have the option to define a generic label (by default: "row") and use it as the label for repeater items and the button "Row 1" "Add new row"
2) have the option to define a text field as the label for items.

I also think the UI and UX of the repeater field should be closer to the menus and widget look and feel.

I agree with everything that's been said above.
both for the labels as well as the styling.

Marking this one as a feature request :+1:

I have opened a PR with a proposal of implementation. The repeater control now accept a new optional parameter row_label an associative array.

$row_label = array (
     'type' => 'text' or 'field'  [default 'text']
     'value' => 'a custom label of you choice' [default 'row']
     'field' => 'a-field-id' [only used if type = field, the field-id must exist in fields and be a text field]
);

I have some basic testing but I would appreciate some extra feedback.

Just Great !!! :+1:

'row_label' => array( 'type' => 'text', 'value' => 'a custom label of you choice', ), do the job, thanks

Just been testing this, it's a great idea. It would be good if you could link it to a select field as well as rather than just be limited to text fields.

@peterigz, It works for select field as well.

:100:

Thanks @guillaumemolter this works great for me.

@daviedR should this be marked as closed?

yes, closing this one.

Yes you can close this one 

On Wed, Jun 15, 2016 at 10:25 PM +0200, "Aristeides Stathopoulos" [email protected] wrote:

yes, closing this one.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Hi,

I'm creating some repeater and defined a custom row label. But how could I change the entire "Add new" button? I'm working in projects in pt_BR, and in portuguese we have a gender distinction for nouns, so we need to change the entire "Add new" text. (It's how register_post_type works, defining every label completely)

@allysonsouza

function my_theme_kirki_textdomain( ) {

    $config['i18n']['add-new']  = esc_attr__( 'My Add New Text', 'my-textdomain' );

        return $config;
}

add_filter( 'kirki/config', 'my_theme_kirki_textdomain' );

Have a look at get_strings() inside kirki/includes/class-kirki-l10n.php for full list of options you can play with. :)

@PlayerThemes This overwrites button labels for the whole project. Is there a way to change a button label per repeater?

Thanks @PlayerThemes,

At least in portuguese we can use the gender distinction inside () - "Adicionar Novo(a)". But would be great, how @hellor0bot said, the possibility to change for each repeater, instead of whole project : )

According to the code comment, the proper way is to use
add_filter( 'kirki/' . $my_config . '/l10n'

instead of
add_filter( 'kirki/config'

Anyway, thanks to @PlayerThemes, I've managed to translate everything in the repeater!

image

Hi guys! I've been using Kirki for quite some time and must say, It's awesome! Thank you so much for the excelent work!
I just wanna know if something have changed since the end of this thread. I tried everything suggested here, without success. I have the same issue of @allysonsouza and want to change the 'Add New' for something else..

I did not figured out from where came $my_config as @tivnet had pointed. I supose it's the name of the config I created, but it did not worked as expected. Using the code from @PlayerThemes I had no success either.

What I could possibly had missed out?
Using:
Wordpress 4.8.1
Kirki 3.0.9

//functions.php
function my_theme_kirki_textdomain() {
    $config['i18n']['add-new'] = esc_attr__( 'Adicionar', 'my_domain' );
    return $config;
}

add_filter( 'kirki/config', 'my_theme_kirki_textdomain' );

Many thanks in advance

Was this page helpful?
0 / 5 - 0 ratings

Related issues

2one2 picture 2one2  Â·  3Comments

rinkuyadav999 picture rinkuyadav999  Â·  4Comments

stylethemes picture stylethemes  Â·  6Comments

VladNov picture VladNov  Â·  6Comments

runnickrun picture runnickrun  Â·  3Comments