https://twill.io logo
Join Discord
Powered by
# ❓questions
  • m

    mateoD

    06/13/2022, 10:34 AM
    Hello everyone, I was trying to catch the last element within the foreach loop but it always returns the message "Last" for each element
  • m

    mateoD

    06/13/2022, 10:36 AM
    can you help me with any solution ?
  • d

    dedli

    06/13/2022, 11:38 AM
    Hi guys ) How can I translate url with slugs for language toggler? Whet I use:
    Copy code
    @foreach(LaravelLocalization::getSupportedLocales() as $localeCode => $properties)    <li class="language__item"><a class="language__link" href="{{ LaravelLocalization::getLocalizedURL($localeCode, null, [], true) }}"  rel="alternate"                                  hreflang="{{ $localeCode }}"                                  class="language__link {{App::getLocale()==$localeCode?'active':''}}">{{ $localeCode=='uk'?'UA':strtoupper($localeCode) }}</a>    </li>@endforeach
    I get url without slugs translation, only adds language prefix
  • d

    dedli

    06/13/2022, 11:46 AM
    Hi ) Try to dump inside foreach $loop variable and $position variable
  • m

    mateoD

    06/13/2022, 12:30 PM
    $block->getRelated('positions') must return all existing elements or only 1 element ?
  • a

    afatmustafa

    06/13/2022, 12:38 PM
    My colleague used the instructions here : https://twill.io/docs/form-fields/multi-select.html#multi-select-with-dynamic-values BTW it works in create view, it just throws an error on the form page, the browser is not responding.
  • m

    mateoD

    06/13/2022, 12:45 PM
    thanx i fixed it
  • d

    dedli

    06/13/2022, 2:46 PM
    Please, could anybody help with this question?
  • i

    ifox

    06/13/2022, 2:47 PM
    did you follow the guide to work with this package? if you don't setup the routing system and translated routes correctly it won't work.
  • i

    ifox

    06/13/2022, 2:48 PM
    https://twill.io/docs/guides/building_a_multilingual_site_with_twill_and_laravel_localization.html
  • d

    dedli

    06/13/2022, 4:57 PM
    Yes, I follow this guide and everything is work except language switcher. When I switch language only language prefix adds but ulr does not change.
  • d

    dedli

    06/13/2022, 5:53 PM
    I think I do something wrong in routes in group https://monosnap.com/file/tLAkljKc7bK6yOo30RujiEZniZTZ5O. This route works correctly with translation
    Copy code
    Route::get(LaravelLocalization::transRoute('routes.personal'), [PageController::class,'index'])->name('personal');
    But all routes in group works wrong with switcher:
  • k

    kalle

    06/13/2022, 9:37 PM
    Any idea why textarea get original value of the field but it should get custom string which is edited in Repository before serving to the form. Even
    Copy code
    @dd($form_fields)
    show right value but component gets original field value?
  • i

    ifox

    06/13/2022, 9:39 PM
    is it a translated field or not?
  • k

    kalle

    06/13/2022, 9:39 PM
    Non translated
  • i

    ifox

    06/13/2022, 9:40 PM
    ok so the logic is here https://github.com/area17/twill/blob/2.x/views/partials/form/utils/_translatable_input_store.blade.php#L16
  • i

    ifox

    06/13/2022, 9:40 PM
    it takes it directly from the model itself of form_fields
  • i

    ifox

    06/13/2022, 9:41 PM
    I guess you;re expecting it to prioritize form_fields
  • k

    kalle

    06/13/2022, 9:41 PM
    I guess so too
  • k

    kalle

    06/13/2022, 9:41 PM
    Any way to make it work like this or should I change something?
  • i

    ifox

    06/13/2022, 9:47 PM
    since it checks on
    $item
    , you'd need to either use an accessor, or you could override
    form()
    in the controller or
    getById()
    in the repository to set it on the model before it gets to the form. or you could push into the store with some inline js. none of those is super clean but there are options.
  • i

    ifox

    06/13/2022, 9:47 PM
    accessor is the cleanest I think
  • i

    ifox

    06/13/2022, 9:48 PM
    you can use a different field name and then set it before saving
  • k

    kalle

    06/13/2022, 9:50 PM
    Yeah setting diffrent field name has done the trick (its just for display anyway). Thank you @ifox 🙂
  • d

    dedli

    06/13/2022, 10:28 PM
    Solve problem. If urls is static or mixed with (static and dynamic parts) you should put all variations of such urls in lang/route.php. Sorry for disturb and thanks for help
  • i

    ifox

    06/13/2022, 11:06 PM
    no problem @dedli, yeah that part is a bit hard to get with that package but once it is setup it's working very well. Glad you figured it out
  • d

    dedli

    06/14/2022, 11:26 AM
    Thanks again ) Find mistake, everyThing is working now thanks for help and patience )
  • b

    bmau

    06/14/2022, 12:29 PM
    Hi guys, im getting started with using this amazing product. I hope you can point me out into the right direction. Im having issues rendering blocks on de site's frontend. Generated block:
    php artisan twill:make:block paragraph-two-third-column
    admin/blocks/paragraph-two-third-column.blade.php
    Copy code
    @twillBlockTitle('Paragraph Two Third Column')
    @twillBlockIcon('text')
    @twillBlockGroup('app')
    
    @formField('input', [
        'name' => 'title',
        'label' => 'Title',
        'translated' => true,
    ])
    
    @formField('wysiwyg', [
        'name' => 'text',
        'label' => 'Text',
        'placeholder' => 'Text',
        'toolbarOptions' => [
            'bold',
            'italic',
            ['list' => 'bullet'],
            ['list' => 'ordered'],
            [ 'script' => 'super' ],
            [ 'script' => 'sub' ],
            'link',
            'clean'
        ],
        'translated' => true
    ])
    sites/blocks/paragraph-two-third-column.blade.php
    Copy code
    <div>
        <h1>{{$block->input('title')}}</h1>
        <p>{{$block->input('text')}}</p>
    </div>
    This results in an error when using the preview function for this page in the cms admin
    Copy code
    "message": "htmlspecialchars(): Argument #1 ($string) must be of type string, array given (View: .../site/blocks/paragraph-two-third-column.blade.php)"
  • i

    ifox

    06/14/2022, 12:35 PM
    Hi @bmau because your field has translated set to true you'd need to use
    $block->translatedInput('title')
  • b

    bmau

    06/14/2022, 12:36 PM
    Thanks @ifox ! I can see the issue now, this project supports only one language. I thought it would be easier to start without localisation haha
1...344345346...484Latest