Jump to content

ukyo

Members
  • Posts

    248
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by ukyo

  1. 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.

  2. 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
  3. 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
  4. 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
  5. @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
  6. 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
  7. @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
  8. @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
  9. 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
  10. @modifiedcontent Can you put these files under a folder something like : templates/extends or site/src. After do that can you add this path to wire classLoader.

    You can do this on ready.php file or you can try it before apply your customizations (didn't try that).

    <?php
    // ready.php example
    
    $template = $page->template->name;
    
    if (in_array($template, ['template-with-comment-field'])) {
      wire('classLoader')->addNamespace('ProcessWire', wire('config')->paths->templates . '/extends');
      // or
      wire('classLoader')->addNamespace('ProcessWire', wire('config')->paths->site . '/src');
    }

    or (didn't tested)

    <?php
    wire('classLoader')->addNamespace('ProcessWire', wire('config')->paths->templates . '/extends');
    // or
    wire('classLoader')->addNamespace('ProcessWire', wire('config')->paths->site . '/src');
    
    $page->comments->render(['className' => 'CommentListCustom']);
    $page->comments->renderForm(['className' => 'CommentFormCustom']);

     

  11. I am currently working on custom comment form output and custom comment list output. I copied `CommentForm.php` as `CommentFormUikit.php` and copied `CommentList.php` as `CommentListUikit.php`.

    Renamed class names on these and extend base classes  files and removed not used codes and modified needed sections.

    When i want to use my custom outputs :

    <?php
    // include customization classes
    include __DIR__ . '/CommentListUikit.php';
    include __DIR__ . '/CommentFormUikit.php';
    
    // custom list output
    echo $page->comments->render(['className' => 'CommentListUikit']);
    // custom form output
    echo $page->comments->renderForm(['className' => 'CommentFormUikit']);
    ?>

    CommentListUikit.php

    <?php
    
    namespace ProcessWire;
    
    class CommentListUikit extends CommentList
    {
    // do your customizations
    }

    CommentFormUikit.php

    <?php
    
    namespace ProcessWire;
    
    class CommentFormUikit extends CommentForm
    {
    // do your customizations
    }

    Example output for uikit 3 frontend framework, still working on it, specially writing a javascript for comment form

    425478768_EkranResmi2020-12-2218_26_31.thumb.png.3a57f88e62a1c95ade560619b57244f1.png

    • Like 1
  12. On 6/20/2020 at 11:44 PM, Ivan Gretsky said:

    Hello, @ukyo!

    I absolutely love your module. And trying to incorporate it in my site-building workflow. I did install it without a problem and am using it for storing some output settings with great success)

    But today I found two (probably, related) bugs:

    1. I cannot create a new Page Reference field. I am getting this error: "Call to a member function getField() on null" (...\Mystique\FieldtypeMystique.module.php:71).
    2. I cannot view a list of pages with certain template (see the screenshot). The error message is the same.mystique.thumb.jpg.660ef9911db96c02569fca6ff185eee0.jpg

    Do you understand what it is?

    I fixed this error, but i can't update module on module directory. There is an error on module directory at the moment.

    170864102_EkranResmi2020-06-2219_47_18.png.5a36b1b6e0d0dac0b8d9c74915008faa.png

    You can update module by directly downloading it from Github.

    • Like 2
  13. On 4/10/2020 at 2:18 AM, gingebaker said:

    Hi.

    I had the same problem like @fliwire with changed resource property in template context not getting saved and outputted correctly.

    I changed the FieldtypeMystique::getBlankValue() method a bit:

    
    public function getBlankValue(Page $page, Field $field)
    {
        return new MystiqueValue($page, $page->template->fieldgroup->getField($field,true));
    }

    API Ref: https://processwire.com/api/ref/fieldgroup/get-field/
    With this change you are getting the field in context of the current page template. Then you have the correct resource filename in $field->resource.
    This works here in my setup, but I haven't been able to test much for now. Hope this does not break something else.

    Anyway, thanks for this module. Looks very promising!

    Suggested fix applied, module updated.

    • Like 3
  14. 4 hours ago, fliwire said:

    tested: resource showing propery but with empy values.  In database field saved with default resource and template resource.

     

    
    {"title":"","title1033":"","title1185":"","__json":null,"__name":"settings","__path":"D:\/Laragon\/www\/protest\/site\/templates\/configs\/Mystique.settings.php","video":"11111111","video1033":"22222222","video1185":"333333333","__resource":"settings"}

     

    Will check it

×
×
  • Create New...