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

    24kappa

    08/05/2022, 7:42 AM
    I'm following the guide about multilanguage website on twill documentation
  • d

    dakaalim

    08/05/2022, 10:43 AM
    Generateblocks has a library of re-usable
    patterns
    (https://generateblocks.com/library/) for wordpress developers to pick and use on any template. Can Twill.io achieve something similar?
  • i

    ifox

    08/05/2022, 1:35 PM
    hi @dakaalim, definitely. Twill Packages and Capsules can help with creating reusable modules and blocks. The frontend rendering aspect is more freeform in Twill making that part a bit different ultimately, but I think you totally could map a set of reusable UI components to a set of reusable modules and blocks.
  • d

    dakaalim

    08/05/2022, 2:31 PM
    @ifox I understand this -> https://twill.io/docs/packages/creating-a-package.html#generating-your-first-twill-package can be used for making reusable modules. What about reusable blocks? Is this what you meant by reusable blocks -> https://twill.io/docs/block-editor/development-workflow.html
  • i

    ifox

    08/05/2022, 4:46 PM
    https://github.com/area17/twill/pull/1446#issuecomment-1060453111
  • i

    ifox

    08/05/2022, 4:47 PM
    what I mean is that you can store blocks blade files in a package and have your application register it
  • i

    ifox

    08/05/2022, 4:48 PM
    https://github.com/area17/twill/pull/1306
  • d

    dakaalim

    08/06/2022, 6:13 AM
    twill's tag table name is the same as spatie tag's, not sure if theres a workaround trhis
  • i

    ifox

    08/06/2022, 7:25 AM
    @dakaalim https://github.com/area17/twill/blob/844d38a0bb698974b280b0b3d1f5ba26472e0c1a/config/twill.php#L136
  • d

    dakaalim

    08/06/2022, 7:54 AM
    thankyou so much
  • d

    dakaalim

    08/07/2022, 8:29 AM
    if I guess correctly, atm it goes like this
    load project folder modules -> load project folder capsule modules -> load vendor folder capsule modules
    I managed to submit a Laravel package containing some Twill Capsules that I normally use. The issue I'm facing now is, I'm not sure how I can allow people to override my Twill Capsules (i.e. migrations, forms), just in case if they want to modify them (adding or removing fields) At the moment, I have included the line below in the package's `TheiaTwillServiceProvider`:
    Copy code
    $this->publishes([
                __DIR__ . '/Twill/Capsules' => app_path('Twill/Capsules'),
            ], 'theia-twill-capsules');
  • d

    dakaalim

    08/07/2022, 8:31 AM
    So people can run
    vendor:publish
    and it will duplicate all the capsules to the project's app path, my assumption was after they do the below as well, they should be able to override the capsules in the package:
    Copy code
    Setup a new CMS menu item in config/twill-navigation.php:
    
        'testModules' => [
            'title' => 'TestModules',
            'module' => true,
        ],
    
    Setup your new Capsule in config/twill.php:
    
        'capsules' => [
            'list' => [
                [
                    'name' => 'TestModules',
                    'enabled' => true,
                ],
            ],
        ],
    
    Migrate your database.
    of course this didn't work, it gave me errors such as migration file for xyz table already exists etc, I'm just showing my attempt.
  • i

    ifox

    08/07/2022, 5:13 PM
    I'd suggest reading Laravel docs about packages. There's no such thing as publishing a PHP class, package publishing is for config, translations, views etc... capsules are already capable of being installed with a "copy" mode though
  • d

    dakaalim

    08/07/2022, 9:56 PM
    @ifox After the capsules are installed with a "copy" mode from the package 'composer require', can the developer modify the capsules? e.g. adding or deleting fields in the migrations, or adding or deleting fields in the blade form. Or the developer just have to use the capsules the way they are included in the package from the beginning
  • i

    ifox

    08/07/2022, 10:01 PM
    if you copy a capsule in your project all the code sits in your /app folder so yeah, all of it can be changed
  • d

    dakaalim

    08/07/2022, 10:07 PM
    True, that works 100%. However, instead of copying and pasting capsules from other places into the project, I'm publishing them from /vendor into the project folder, the idea behind this is I want the capsules in the package to be extentable.
  • d

    dakaalim

    08/07/2022, 10:13 PM
    kinda like laravel jetstream, you can publish the files and modify it eg add phone number auth etc...
  • i

    ifox

    08/08/2022, 8:51 AM
    What jetsream publishes is views and config too, see https://github.com/laravel/jetstream/blob/b1f66c278ea62463eabfdf1627bc53395bfde0bf/src/JetstreamServiceProvider.php#L154
  • i

    ifox

    08/08/2022, 8:54 AM
    a Twill package is a standard Laravel package so you can decide how you want it to be extendable. Config would be a place that'd make sense to me if you want to allow developers to swap a class in your capsule for example. Also capsules have a config file that is automatically merged with your capsules config in twill.php. so a lot is already in place for you to create extendable capsules
  • m

    MedvedOurs

    08/09/2022, 11:27 AM
    Hello! Does anyone know of a simple way to tell twill to use a different session cookie than the front part of the website? Can this be done through an env variable?
  • k

    kalle

    08/09/2022, 11:35 AM
    Something like this?
  • m

    MedvedOurs

    08/09/2022, 11:43 AM
    Not exactly - the other way around actually. I have my session domain as .something.com (and it needs to stay that way because I have multiple subdomains). But I'm also using the Auth facade in a totally different way. So it logs out my Twill user when they go back to the admin panel. Ideally if I could save the session cookie with a different name on twill side, that would solve my problem
  • k

    kalle

    08/09/2022, 12:20 PM
    Hmm, yeah I understood your question, but mine answer was more to the suggestion of changing domain name with some prefix, but Im not sure if that would resolve the case, more likely is going to destroy something. Ill need to take a look on how Twill assigns cookie, but maybe @ifox is more familiar with this.
  • m

    MedvedOurs

    08/09/2022, 12:23 PM
    If I could change that name, it would help a lot! Thank you for support
  • m

    MedvedOurs

    08/09/2022, 1:21 PM
    There's probably a better way of doing it, but at least as a poc, this worked for me:
    Copy code
    class ChangeSessionCookieNameForCms
    {
    
        /**
         * @param  \Illuminate\Http\Request  $request
         * @param  \Closure  $next
         * @return mixed
         */
        public function handle($request, Closure $next)
        {
    
            if (request()->getHost() == Config::get('twill.admin_app_url')) {
    
                $newSession = Config::get('twill.cookie_name');
    
                Session::setName($newSession);
                Config::set('session.cookie', $newSession);
    
            }
    
            return $next($request);
        }
    
    }
  • s

    Shiftless

    08/09/2022, 2:39 PM
    hello. ist it possible to use a browser in a settings page?
  • i

    ifox

    08/09/2022, 2:50 PM
    Hi @Shiftless, no, settings are limited to text/wysiwyg/selectors/medias fields, browsers, repeaters and blocks are not supported. We're planning to refactor Settings soon but in the meantime we recommend using a Singleton
  • s

    Shiftless

    08/09/2022, 2:50 PM
    okay i did this in the past but was hoping for a leaner solution via settings. looking forward to the refactor.
  • i

    ifox

    08/09/2022, 2:50 PM
    Hi guys, I'm not aware of a way that Laravel would provide by default to customize the cookie name depending on the auth guard, unfortunately
  • d

    dakaalim

    08/09/2022, 10:33 PM
    php artisan twill:make:capsule --singleton AboutPage
1...370371372...484Latest