Jump to content

ukyo

Members
  • Posts

    253
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by ukyo

  1. 7 hours ago, Clarity said:

    Hello everyone and @ukyo!

    Can you please tell me how to deal with this error?

    Argument 1 passed to ProcessWire\FieldtypeMystique::loadResource() must be of the type string, null given, called in /home/i/ivangr/tverkurort.ru/public_html/site/modules/Mystique/InputfieldMystique.module.php on line 175.

    My Mystique code is:

    <?php
     
    namespace ProcessWire;
     
    return function ($page = null, $field = null, $value = null) {
       ...
    };

    Be sure you selected your resource name from your input config and be sure you saved your input config

    • Thanks 1
  2. On 7/23/2022 at 2:44 PM, Ivan Gretsky said:

    Hey, @ukyo! I read the module description, but I can't say I fully grasp what it does) Could you please write why this module, what problems it solves, what are typical use cases. Looking forward to learn more about this one, as I already use and love other modules of yours))

    This module help you to organize your events in files. Module using CORE hook system. After i wrote many events inside my module, it was confused to find what is where. After that i think to write a EventLoader module for separate events in files and load them by using a prefix like `ready.` or `init.`.

    Think, you have api, page method, page property etc. events on your /site/ready.php file or module. If you write all of these events on a single file, it could be hard to find what is where. At this point you can separate your events inside event files.

    I will write 2 example file, may you have 5 - 15 or more event files and all file may have events more than 1.

    /site/templates/configs/events/ready.api.php

    <?php
    
    namespace ProcessWire;
    
    /**
     * Api calls
     **/
    return [
        'events' => [
            '/hello/world' => [
                'fn' => function (HookEvent $e) {
                    return 'Hello';
                }
            ],
            '/hola/world' => function (HookEvent $e) {
    			return 'Hello';
            },
            '/hello/(earth|mars|jupiter)' => [
                'fn' => function (HookEvent $e) {
                    return "Hello " . $event->arguments(1);
                }
            ],
    		'/hola/(earth|mars|jupiter)' => function (HookEvent $e) {
    			return "Hello " . $event->arguments(1);
    		}
        ]
    ];

    /site/templates/configs/events/ready.page.php

    <?php
    
    namespace ProcessWire;
    
    return [
        'events' => [
            'Page::hello' => [
                'type' => 'method',
                'fn' => function (HookEvent $e) {
                    $message = is_string($e->arguments(0)) ? $e->arguments(0) : '';
                    $e->return = $message;
                }
            ]
        ]
    ];

    Loading /site/ready.php events from event files

    <?php namespace ProcessWire;
    
    if(!defined("PROCESSWIRE")) die();
    
    // this will load all event files, starts with `ready.` prefix
    // __DIR__ . '/templates' => /processwire-root/site/templates/configs/events/
    EventLoader::load(__DIR__ . '/templates', 'ready.');
    • Like 2
  3. 20 hours ago, Ivan Gretsky said:

    Hey @ukyo!

    Every time I write here I want to start with a thank you, as I like the module so much)

    Now to the question. Is it possible now or could it be implemented to support repeater / repeater matrix fields?

    P.S. Are  there any rumors about when is the next branch going to be merged?

    Mytqiue works inside repeater fields.

    If you mean, create repeater field via Mystique, the answer is no.

  4. Basically

    <?php
    
    namespace ProcessWire;
    
    // create field
    $field = new Field();
    $field->name = 'my_field';
    $field->label = 'My Field';
    $field->type = 'FieldtypeText';
    
    // save field
    wire('fields')->save($field);
    // get field
    $field = wire('fields')->get('my_field');
    
    // Create fieldgroup
    $fieldgroup = new Fieldgroup();
    // if you want to edit fields in this field group via admin panel, name need to be same with template name
    $fieldgroup->name = 'my_template';
    $fieldgroup->add('title');
    $fieldgroup->add('body');
    $fieldgroup->add($field);
    
    // save fieldgroup
    wire('fieldgroups')->save($fieldgroup);
    // get fieldgroup
    $fieldgroup = wire('fieldgroups')->get('my_template');
    
    // Create template
    $template = new Template();
    $template->name = 'my_template';
    $template->label = 'My Template';
    $template->fieldgroup = $fieldgroup;
    
    // save template
    wire('templates')->save($template);
    // get template
    $template = wire('templates')->get('my_template');

     

    • Like 3
  5. 1 hour ago, Clarity said:

    Somewhy when I save a page with fields given by Mystique, content from these fields disappear after saving. Is it a problem with next branch?

    I have many web projects using mystique fields, i didn't see an error like this. You can make a try with clean processwire install, after that if this error continue for your create an issue on github repo.

    • Like 1
  6. Quote

    In addition, Mystique will search files in form Mystique.*.php in site/templates/configs, not in site/templates.

    Yes, json or php file. I see my mistake on readme.md i will fix it.

    {Mystique.*.php,mystique.*.php,Mystique.*.json,mystique.*.json}

     

    Quote

    Current variant of Mystique in "master" branch gives the error "You need to select a resource and save field before start to use Mystique." after creation of the page. I don't see that it is possible to select a resource just after creation of the field. Switching to the branch "next" solves the problem.

    Long time i am not working with master branch, i have many updates on next branch, i will merge these 2 branch soon.

    • Like 1
    • Thanks 1
  7. @Ivan Gretsky You can also try next version of Mystique field type.

    Now, its possible to display custom fields depend on template name or page, you imagine it.

    Here is an example usage:

    <?php
    
    namespace ProcessWire;
    
    /**
     * Resource: magic of mystique field
     */
    return function ($page = null, $field = null, $value = null) {
    
        $fields = [
            'hello' => [
                'label' => 'Are you ready for a Magic ?',
                'type' => 'select',
                'options' => [
                    'no' => 'No',
                    'yes' => 'Yes'
                ],
                'required' => true,
                'defaultValue' => 'no'
            ]
        ];
    
        if ($page instanceof Page && $page->template->name == 'page') {
            $fields['current_page'] = [
                'label' => 'Current page title : ' . $page->title,
                'value' => $page->title,
                'showIf' => [
                    'hello' => '=yes'
                ],
                'columnWidth' => 50
            ];
        }
    
        if ($field instanceof Field) {
            $fields['current_field'] = [
                'label' => 'Current field label : ' . $field->label,
                'value' => $field->label,
                'showIf' => [
                    'hello' => '=yes'
                ],
                'columnWidth' => 50
            ];
        }
    
        return [
            'name' => 'magician',
            'title' => 'Do A Magic ?',
            'fields' => $fields
        ];
    
    };

     

    • Like 1
  8. 5 hours ago, Ivan Gretsky said:

    Good day @ukyo!

    Is there a way to manipulate field data from the API? Like batch setting / changing it?

    This should work

    <?php
    
    $page->of(false);
    
    $page->mystique_field_name->property1 = 'data';
    $page->mystique_field_name->property2 = 'data';
    $page->mystique_field_name->property3 = 'data';
    $page->mystique_field_name->property4 = 'data';
    $page->mystique_field_name->property5 = 'data';
    $page->mystique_field_name->property6 = 'data';
    
    $page->save();
    • Like 1
  9. @szabesz

    No need new Module for Uikit source files !

    Node example only for theme development, if you need admin theme customizations you can import uikit source files on your side. Node usage example is not for ProcessWire users, its only for theme development by @ryan or @bernhard.

    User can import uikit source files inside /site/templates/admin.less

    You can add @uikit-source-path variable on wire/modules/AdminTheme/AdminThemeUikit/uikit-pw/pw.less

    You can change variable value normally on lately loaded file on less.

    // Import uikit, use less variable for uikit source
    @uikit-source-path: "../../node_modules/uikit/src/less/uikit.less"
    
    @import $uikit-source-path;

    Change @uikit-source-path variable /site/templates/admin.less

    @uikit-source-path: 'source/to/uikit/less/uikit.less';
    
    div { border: 1px solid red; }

     

    • Like 3
  10. @bernhard @ryan Thanks for admin theme customization option

    But i didn't like uikit source files under AdminThemeUikit/uikit, no need these files. Folder size is big !

    I can give an idea about using uikit less or scss files:

    - You can install uikit via node with package.json file
    - You can load source uikit files from node_modules/uikit/src/less/uikit.less
    - You can add node_modules folder to .gitignore
    - If a user want to modify admin theme, user can define uikit source from less file

    With this way, we don't need uikit source files under AdminThemeUikit folder

    • Like 1
  11. 2 minutes ago, fruid said:

    I actually have a very specific issue that I'm stuck with…

    How do I make the module create the template files, not just the templates in the database via API but also the corresponding php files in the webcontent when being installed?

    You can create your templates inside your modules folder, like "MyModule/templates/" on module installation you can copy these templates to "site/templates/" folder.

    • Like 1
×
×
  • Create New...