Jump to content

ukyo

Members
  • Posts

    262
  • Joined

  • Last visited

  • Days Won

    6

Posts posted by ukyo

  1. Just now, LAPS said:

    For sure!

    Just say to me what I've to make possibly without uninstalling the module since it's used in many templates and populates many pages e.g. can I just copy-paste the files from the repo to the /.../site/modules/FieldtypeFontIconPicker folder?

    Copy / Paste files enough

  2. 16 hours ago, bernhard said:

    @ukyo I haven't had time to look into that issue, but I'd highly recommend that you use the built in file tools of ProcessWire - that minimizes the risk of such errors and if there are still any bugs we can fix them globally on one place once for all.

    It's as simple as using $this->files->find(...) in your module, see https://github.com/BernhardBaumrock/RockTabulator/blob/6670f2647fcbbb1f5ad4c5237ea9fd03b8899315/InputfieldRockTabulator.module.php#L52-L58 for example.

    See also https://processwire.com/api/ref/wire-file-tools/

    How to use core files()->find() function like php glob() function ?

    https://github.com/trk/FieldtypeFontIconPicker/blob/master/FieldtypeFontIconPicker.module#L50

    15 hours ago, LAPS said:

    About the $paths in the code you linked:

    
    echo wire("config")->paths->siteModules . "**/configs/IconPicker.*.php";
    
    // output is: /..../site/modules/**/configs/IconPicker.*.php
    
    
    // (manual :)) matching is:
    //
    //   ftp://.../site/modules/FieldtypeFontIconPicker/configs/IconPicker.fontawesome.php
    //   ftp://.../site/modules/FieldtypeFontIconPicker/configs/IconPicker.ionicicons.php
    //   ftp://.../site/modules/FieldtypeFontIconPicker/configs/IconPicker.uikit.php
    
    
    
    echo wire("config")->paths->templates . "configs/IconPicker.*.php";
    
    // output is: /.../site/templates/configs/IconPicker.*.php
    
    // no matching:
    //
    //   "No such file or directory"

     

    ?

    @ukyo please consider refactoring $pathss definition ASAP. ?

    
    $path = $this->wire("config")->paths->siteModules . "**/configs/Mystique.*.php";
    $path .= "," . $this->wire("config")->paths->templates . "configs/Mystique.*.php";

     

    If you don't have custom icons inside templates folder result look like ok.

  3. 4 hours ago, LAPS said:

    @adrian I deleted the MarkupFontIconPicker folder and I no longer get the error. Thank you! ?

    It was my fault in trying to solve things ? as of the original issue: in the Edit Field > Input > Icon library, the libraries (IconPicker.*.php) are not loaded.

    Is there any reason for having no loaded libraries (note: I haven't added any new libraries, I'm just using the default ones.)?

    Can you check paths are true on your server ? on this line :

    https://github.com/trk/FieldtypeFontIconPicker/blob/master/FieldtypeFontIconPicker.module#L43

    @bernhard have similar error with my other Mystique module

     

    Repo function line : https://github.com/trk/Mystique/blob/next/Mystique.module.php#L88

    I can't find the issue. On my mac (macos mojave with valet (php 7.4.3)) and on my server (centos 7.7 with php (7.3)) i can't see this issue.

  4. On 1/24/2020 at 3:01 PM, bernhard said:

    Thx @ukyo,

    it is, as I thought, a windows problem. I've tried the "next" branch - no change. It works on my linux server. Would be great to get a fix for this.

    As you can see in my screenshot the strange thing is that the FilenameArray is populated on line ~118 but it is empty on line ~174 (where the select field on the input tab of the pw field should get populated).

    @bernhard i don't have a Windows PC and can't test it, Can you try to change ready function for next branch :

        public function ready()
        {
            $path = $this->wire("config")->paths->siteModules . "**/configs/Mystique.*.php";
            $path .= "," . $this->wire("config")->paths->templates . "configs/Mystique.*.php";
            
            foreach (glob("{" . $path . "}", GLOB_BRACE) as $file) {
    
                $dirname = dirname(dirname($file));
                $base = strtolower(str_replace([dirname(dirname(dirname($file))), "/"], "", $dirname));
                $name = str_replace([dirname($file), "/", "Mystique.", ".php"], "", $file);
    
                $this->resources[$base][$name] = $file;
            }
        }

    with

        public function ready()
        {
            $path = $this->wire("config")->paths->siteModules . "**" . DIRECTORY_SEPARATOR . "configs" . DIRECTORY_SEPARATOR . "Mystique.*.php";
            $path .= "," . $this->wire("config")->paths->templates . "configs" . DIRECTORY_SEPARATOR . "Mystique.*.php";
            
            foreach (glob("{" . $path . "}", GLOB_BRACE) as $file) {
    
                $dirname = dirname(dirname($file));
                $base = strtolower(str_replace([dirname(dirname(dirname($file))), DIRECTORY_SEPARATOR], "", $dirname));
                $name = str_replace([dirname($file), DIRECTORY_SEPARATOR, "Mystique.", ".php"], "", $file);
    
                $this->resources[$base][$name] = $file;
            }
        }

     

  5. 16 hours ago, bernhard said:

    Hi @ukyo,

    I've just tried your module for the first time, but unfortunately it does not find any resources! This is the tracy dump:

    PWaFGFU.png

    Somehow the resources array is empty:

    lrcMVym.png

    I have the following files in my setup:

    
    C:\laragon\www\kaum\site\modules\Mystique\configs\Mystique.example-dive.php
    C:\laragon\www\kaum\site\templates\configs\Mystique.mystique.php

    No matter what I try - the resources select is empty:

    sxXg2TJ.png

    I've even tried to do a $config->paths->normalizeSeparators() on the path without success (thought it might be a windows issue).

    Thx for your help!

    Hi @bernhard

    Can you try @next branch https://github.com/trk/Mystique/tree/next, this will be next version.

    • Thanks 1
  6. 20 hours ago, gmclelland said:

    Haven't used it yet, but I think I read that Mystique is also a good module for this kind of stuff.  

     

    I have also used SettingsFactory and can say that it works great.

    Yes, it's possible to do these kind of stuff. Create 1 Mystique field and do what you want with that field.

    Mystique config files

    130130474_EkranResmi2020-01-0317_15_34.png.10ca8007b9f64f85d7144abaddc58990.png

    Mystique seo configs

    297584177_EkranResmi2020-01-0317_18_03.thumb.png.178f798f51deafb7363f9f763c879e42.png

    Mystique admin edit for seo configs

    204400863_EkranResmi2020-01-0317_17_31.thumb.png.bc125c84ac7e68f00d445aa9094e2e96.png

    • Like 2
  7. @neophron Always using this method may cause headache for you. What about add this method as property for each image field and use it like $imageField->alt. We need to add a hook method.

    Add hook method to existing /site/ready.php or create new /site/ready.php, copy below code and paste it in to /site/ready.php :

    /site/ready.php

    <?php
    
    namespace ProcessWire;
    
    wire()->addHookProperty('Pageimage::alt', function(HookEvent $event) {
        /* @var $image Pageimage */
        $image = $event->object;
        $event->return = $image->description ?: str_replace('.' . $image->ext, '', $image->basename);
    });

    Usage ($imageField->alt) :

    <?php
    foreach($page->images_slider as $image) {
    	$slide = $image->size(0,700);
    
    	echo "<li class='uk-width-3-4'>";
    	echo "<img class='photo' src='{$slide->url}' alt='{$image->alt}' width='{$slide->width}' height='{$slide->height}' />";
    	echo "</li>";
    }
    ?>

     

    • Like 3
    • Thanks 1
  8. 1 hour ago, neophron said:

    The image field is »array of items« with 0=no limit. And this is the code the template:

    
    <?php
            foreach($page->images_slider as $slide_image) {
              $slide = $slide_image->size(0,700);
                echo "
                  <li class='uk-width-3-4'>
                    <img class='photo' src='{$slide->url}' alt='{$slide_image->basename}' height='700' />
                  </li>
    
                  ";
                }
            ?>

     

    @neophron A solution about using filename as image alt info. You can try code below :

    <?php
    foreach($page->images_slider as $image) {
    	$slide = $image->size(0,700);
    	$alt = $image->description ?: str_replace('.' . $image->ext, '', $image->basename);
    
    	echo "<li class='uk-width-3-4'>";
    	echo "<img class='photo' src='{$slide->url}' alt='{$alt}' width='{$slide->width}' height='{$slide->height}' />";
    	echo "</li>";
    }
    ?>

     

    • Like 3
    • Thanks 1
  9. 7 hours ago, Jonathan Lahijani said:

    Upon further inspection, setting the 'type' to 'InputfieldAsmSelect' does work and does save properly.  Awesome.

    Nice to hear that.

    Processing input field there is not special check for input field. https://github.com/trk/Mystique/blob/master/InputfieldMystique.module.php#L135

    Little bit worked on a base field type (basically this field type will get entered field type's database schemas and will create 1 database table for all entered fields), if i success about this field type, i will try to use input field based checks.

    For the moment getting and setting directly posted data.

    • Like 3
  10. 42 minutes ago, buster808 said:

    got it working now by doing this - really need to learn php basics

    <?php $content .= "<div class='uk-child-width-1-1 uk-child-width-1-3@m' uk-grid>"; ?>
     
    <?php
    foreach ($entries as $entry) {
     
    $content .= "<div> <a href='{$entry->url}'> <h2>{$entry->title}</h2><h4>{$publish_date}</h4></a>";
    $content .= shortText($entry->body, 100);
    $content .= "<br><a href='{$entry->url}'> Read More </a></div>";
    }
    ?>
     
    <?php $content .= "</div>"; ?>

    A tip, if your all code php in your template, you don't need to clode php tag. And no need to close and open tag again again

    <?php
    
    $content .= "<div class='uk-child-width-1-1 uk-child-width-1-3@m' uk-grid>";
    
    foreach ($entries as $entry) {
    	$content .= "<div> <a href='{$entry->url}'> <h2>{$entry->title}</h2><h4>{$publish_date}</h4></a>";
    	$content .= shortText($entry->body, 100);
    	$content .= "<br><a href='{$entry->url}'> Read More </a></div>";
    }
    
    $content .= "</div>";

     

  11. I am using this module for SEO, LANGUAGE and ELEMENTS (uikit components)

    USAGE EXAMPLE : LANGUAGE

    On my private module, i added my custom configs path to Mystique module by using :

    Mystique::add('my-module-configs-path');

    - Create config file

    <?php
    
    namespace ProcessWire;
    
    // Filename: MyModule/configs/Mystique.language.php
    
    // This options normally coming from a file array, i added 2 options for example
    $options = [
    	'tr' => 'Türkçe',
    	'en' => 'English'
    ];
    $defaultValue = 'en';
    
    /**
     * Resource : MyModule => Language
     */
    return [
        'title' => __('MyModule: Language'),
        'fields' => [
            'title' => [
                'label' => __('Language title'),
                'description' => __('Title of language'),
                'type' => Mystique::TEXT,
                'columnWidth' => 50
            ],
            'code' => [
                'label' => __('Code'),
                'description' => __('Language short code'),
                'type' => Mystique::SELECT,
                'options' => $options,
                'defaultValue' => $defaultValue,
                'required' => true,
                'columnWidth' => 50
            ],
            'flag' => [
                'label' => __('Flag'),
                'description' => __('Language flag code'),
                'type' => Mystique::TEXT,
                'columnWidth' => 50
            ],
            'direction' => [
                'label' => __('Direction'),
                'checkboxLabel' => __('Right to left'),
                'description' => __('Direction of language'),
                'type' => Mystique::TOGGLE_CHECKBOX,
                'type_fallback' => Mystique::CHECKBOX,
                'columnWidth' => 50
            ],
            'currency' => [
                'label' => __('Currency'),
                'description' => __('Code of currency'),
                'type' => Mystique::TEXT,
                'columnWidth' => 50
            ],
            'symbol' => [
                'label' => __('Symbol'),
                'description' => __('Symbol of currency'),
                'type' => Mystique::TEXT,
                'columnWidth' => 50
            ],
            'grouping_separator' => [
                'label' => __('Grouping separator'),
                'description' => __('Thousand separator for amount'),
                'type' => Mystique::TEXT,
                'columnWidth' => 50
            ],
            'decimal_separator' => [
                'label' => __('Decimal separator'),
                'description' => __('Decimal separator for amount'),
                'type' => Mystique::TEXT,
                'columnWidth' => 50
            ],
            'separator' => [
                'label' => __('Use separator'),
                'checkboxLabel' => __('YES'),
                'description' => __('Apply space between amount and currency symbol ?'),
                'type' => Mystique::TOGGLE_CHECKBOX,
                'type_fallback' => Mystique::CHECKBOX,
                'columnWidth' => 33
            ],
            'show_decimal' => [
                'label' => __('Decimal'),
                'checkboxLabel' => __('YES'),
                'description' => __('Show amount decimals ?'),
                'type' => Mystique::TOGGLE_CHECKBOX,
                'type_fallback' => Mystique::CHECKBOX,
                'columnWidth' => 33
            ],
            'symbol_after' => [
                'label' => __('Symbol after'),
                'checkboxLabel' => __('YES'),
                'description' => __('Display symbol after amount ?'),
                'type' => Mystique::TOGGLE_CHECKBOX,
                'type_fallback' => Mystique::CHECKBOX,
                'columnWidth' => 33
            ],
        ]
    ];

    - Select config file from Mystique field settings

    - Add Mystique field to language template

    158007518_EkranResmi2019-04-1617_07_26.thumb.png.fc0ee438f50c25c17ac9b4fc66cd76e2.png1675030088_EkranResmi2019-04-1617_08_24.thumb.png.b24c6734f5c16bcd65d79882903f81e4.png

    Access data via api (in this example mystique field name is : lang)

    <?php
    
    $language = $user->language;
    // lang is Mystique field
    echo 'Title : ' . $language->lang->title . '<br>';
    echo 'Code : ' . $language->lang->code . '<br>';
    echo 'Flag : ' . $language->lang->flag . '<br>';
    echo 'Direction : ' . $language->lang->direction . '<br>';
    echo 'Currency : ' . $language->lang->currency . '<br>';
    echo 'Symbol : ' . $language->lang->symbol . '<br>';
    echo 'Grouping separator : ' . $language->lang->grouping_separator . '<br>';
    echo 'Decimal separator : ' . $language->lang->decimal_separator . '<br>';
    echo 'Separator between amount and symbol : ' . $language->lang->separator . '<br>';
    echo 'Show decimal : ' . $language->lang->show_decimal . '<br>';
    echo 'Show symbol after amount : ' . $language->lang->symbol_after . '<br>';

    Output:

    Title : English
    Code : en
    Flag : gb
    Direction : 0
    Currency : GBP
    Symbol : £
    Grouping separator : ,
    Decimal separator : .
    Separator between amount and symbol : 1
    Show decimal : 1
    Show symbol after amount : 0

     

    • Like 10
    • Thanks 1
  12. 2 minutes ago, LostKobrakai said:

    My question was less about the field definitions, but more about the data stored in a field defined by your module. E.g. say I want to change an integer field to a float field.

    Keep the field name same, do what you want. Because all data on database in string format (i am not checking user posted data), you can set field settings by using processwire fields api and you can limit user by settings.

    Hook methods could be used for custom usages.

    • Like 2
  13. 6 hours ago, BitPoet said:

    Maybe you could get some inspiration there from (or even improve on) my JsonNativeField module since MySQL supports searching inside JSON data.

    @BitPoet will check it, but i don't want to limit user's database options and if you need an important searchable field i am not advising to use this field, use a fully searchable field.

    3 hours ago, LostKobrakai said:

    Can you share a bit more details on how data is handled. E.g. what happens if I change a field or even remove it.

    @LostKobrakai I will add more details on readme.md file and will update this post and module page.

    About your question : as you see on youtube video, updating fields config file will update data entry form for admin page. If you remove field, you won't see this field on admin pages anymore. I am not caching your configs, always trying to get configs from selected config files.

    • Like 1
×
×
  • Create New...