https://twill.io logo
Join DiscordCommunities
Powered by
# ❓questions
  • i

    ifox

    02/14/2023, 6:31 PM
    indeed the conflict is created by https://github.com/lazychaser/laravel-nestedset/blob/v5/src/NodeTrait.php#L108
  • i

    ifox

    02/14/2023, 6:32 PM
    https://github.com/lazychaser/laravel-nestedset/issues/310
  • j

    jefsev

    02/14/2023, 6:34 PM
    Great thx!
  • j

    jefsev

    02/14/2023, 6:34 PM
    🙂
  • j

    jefsev

    02/14/2023, 7:49 PM
    @ifox any idea why this is happening?
  • i

    ifox

    02/14/2023, 8:30 PM
    @jefsev let me check. Is that the output of
    getNestedSlug
    ?
  • d

    dakaalim

    02/15/2023, 6:08 AM
    I notice Twill doesn't support simplified chinese when it tries to convert the title field into slug url field, so the slug url field ended up being null, and user has to manually update the slug url
  • t

    thingasd

    02/15/2023, 6:47 AM
    Hi, I am Chinses user too and I have created a pr on this, hope it helps https://github.com/area17/twill/pull/1907
  • d

    dakaalim

    02/15/2023, 6:55 AM
    nice, it works, maybe the maintainer can come up with a more flexible solution that fixes it for not only chinese and also other non alphabetic languages
  • b

    BA7YA

    02/15/2023, 8:24 AM
    I have an idea to add one more option 'Move to the next/previous page' to that three dots drop down. It will give the opportunity to move a records from a page to another
  • j

    jefsev

    02/15/2023, 9:25 AM
    That's how the slug is being saved in de database. So it reverses the first 2 when there is a second depth.
  • j

    jefsev

    02/15/2023, 9:27 AM
    My controller as per documentation:
    Copy code
    class PageController extends BaseModuleController
    {
        protected $moduleName = 'pages';
    
        public $permalinkBase = '';
    
        protected $indexOptions = [
            'reorder' => true,
        ];
        protected $nestedItemsDepth = 4;
    
        protected function form($id, $item = null):array
        {
            $item = $this->repository->getById($id, $this->formWith, $this->formWithCount);
    
            $this->permalinkBase = $item->ancestorsSlug;
    
            return parent::form($id, $item);
        }
    }
  • i

    ifox

    02/15/2023, 10:28 AM
    maybe I need more coffee but Twill doesn't save any nested slug in database, each record has a single slug (as in no / in them) and the full permalink is resolved dynamically
  • i

    ifox

    02/15/2023, 10:35 AM
    are you sure that your nested tree is valid?
  • i

    ifox

    02/15/2023, 10:36 AM
    https://github.com/lazychaser/laravel-nestedset#checking-consistency
  • j

    jefsev

    02/15/2023, 10:47 AM
    Your right my bad, i may need that coffee 😛 I\
  • j

    jefsev

    02/15/2023, 12:12 PM
    https://tenor.com/view/the-simpsons-homer-simpson-coffee-drinking-coffee-is-life-gif-17657468
  • k

    kerkness

    02/15/2023, 1:14 PM
    Any tips on creating blocks during an import process? I'm going to be migrating some content from another system so working on a Command that creates some Module records and want to add a string to a simple custom block. I'm trying to mimic the payload posted from the admin. Works for form inputs and translatable fields but can't seem to find where blocks are specifically created/updated in the source. Working with this so far
    Copy code
    // mimic format of admin PUT request
    $ta['name'] = $data[0];
    $ta['active'] = 1; // seems required for translations
    $ta['summary'] = $data[5]; // translatable input
    
    // Block content doesn't get created
    $ta['blocks'][] = [
        'id' => now(),
        'content' => $data[7],
        'type' => "a17-block-app-text",
        'is_repeater' => false,
        'editor_name' => 'default'
    ];
    
    $twillArtist = TwillArtist::create($ta);
    $twillArtist->setSlugs();
    $twillArtist->save();
  • k

    kalle

    02/15/2023, 1:20 PM
    I may be wrong, but you can check that on the repository with overloaded method like
    prepareFieldsBeforeSave
    . That method is called multiple times, firstly on the form save and for every block after. You can try with the
    Log
    facade to log that or Ray if you use it. Dont
    dd
    , it wont reach blocks.
  • i

    ifox

    02/15/2023, 1:53 PM
    @kerkness you need to use create/update functions from your TwillArtist repository class so that the blocks get saved
  • i

    ifox

    02/15/2023, 1:54 PM
    or you can directly create blocks themselves with the appropriate
    blockable_id
    and
    blockable_type
    values
  • k

    kerkness

    02/15/2023, 2:37 PM
    Great. Thanks for the tips. I'll explore those methods.
  • k

    kerkness

    02/15/2023, 3:39 PM
    Brilliant.. this will work for my needs
    Copy code
    $twillArtist = TwillArtist::create($ta);
    $twillArtist->setSlugs();
    $twillArtist->save();
    
    $block = [
        'content' => ['content' => ['en' => '<p>THIS IS SOMETHING</p>']],
        'type' => "app-text",
        'position' => 1,
        'editor_name' => 'default',
        'blockable_id' => $twillArtist->id,
        'blockable_type' => TwillArtist::class,
    ];
    
    $blocked = Block::create($block);
  • i

    ifox

    02/15/2023, 3:41 PM
    nice! not mandatory but I would recommend setting up morphmaps for your twill model
  • k

    kerkness

    02/15/2023, 3:43 PM
    googling morphmaps
  • k

    kerkness

    02/15/2023, 3:56 PM
    Okay... Cool. Didn't realize Eloquent has a
    getMorphClass
    method. I'll do this for my larger package as well as I use polymorph relationships on a bunch of models
  • v

    VadimG

    02/15/2023, 7:44 PM
    Hi! Team, is it possible to use one repeater but with dynamic data? Let's say we have a repeater with select, but this select must take options from dynamic array, which we can provide? There's second question, how we can provide dynamic data to repeater? I tried to use ViewComposer, but I always got the same data in all repeaters... Reason is: we try to use the same repeater in two blocks but settings of repeaters depend on block. Seems this task is mind blowing 🙂
    i
    • 2
    • 13
  • o

    Olivier

    02/16/2023, 3:47 PM
    What's the status of stand alone nested repeaters in Twill 2.x? I'm building a menu module and I need to allow for a second level of nesting (submenu). From my research, I would need to either switch to using blocks or JsonRepeaters? I started playing a bit with this, and nothing feels strong. I'm thinking of maybe having a browser to choose a child menu instead, but this is not ideal.
    i
    • 2
    • 2
  • d

    dakaalim

    02/17/2023, 10:17 AM
    how do i add route prefix for singleton modules that are in capsule form
  • f

    fabiancz

    02/19/2023, 11:20 AM
    Hi, I'm new in Twill. I really like it! Now I'm solving how to do photo gallery. Is it good idea to use Medias? Or do you have better recommendation? Thanks
    i
    • 2
    • 1
1...467468469...484Latest