Skip to content

Instantly share code, notes, and snippets.

@chrispymm
chrispymm / twill-nested-module-urls.md
Created June 10, 2020 07:26
[Support nested urls for nested modules] #twill

By default Twill will disply the url of a module item to be {siteurl}/{module}/{slug} e.g. mysite.com/pages/about. With the 'about' section being the editable slug. This is understandable as Twill knows nothing of your frontend routing. However it is likely confusing for editors, as that url presented will not be the final url of the content.

Remove module name form url

This will give us more correct urls e.g. mysite.com/about

// app/Http/Controllers/Admin/PageController

	protected $permalinkBase = '';
@chrispymm
chrispymm / twill-nested-module-sorting.md
Created June 10, 2020 07:11
[Enable hierarchical/nested sorting on a twill module] #twill

This method is slightly different from the docs site, and is pulled from this pull-request (which has been approved)

Model

//app/Models/Page.php
class Page extends Model implements sortable 
{
use Has Position, NodeTrait
...
public static function saveTreeFromIds($nodeTree)
@chrispymm
chrispymm / twill-settings-media-upload.md
Created June 10, 2020 06:51
[Enable media upload on settings pages] #twill

In order to upload the image in the crops for the image need to be added to the settings array in the twill config file.

'settings' => [
        'crops' => [
            '[NAME]' => [
                '[CROP]' => [
                    [
                        'name' => 'foobar',
 'ratio' => 1,