Jump to content

kixe

Members
  • Posts

    802
  • Joined

  • Last visited

  • Days Won

    10

Posts posted by kixe

  1. It's not the same situation, but maybe interesting in this context. I work for a professional association with around 2000 members. Until recently the association had rented a root server to host web content, member management and email accounts for the members.

    Now we have switched to shared hosting including all the e-mail accounts. The members now can independently activate and deactivate their e-mail accounts via a ProcessWire interface (API to hoster) and further administrate via the webmailer provided by the hoster. The member management was transferred to an external cloud based service.

    Result: lower costs. less work (administration and support). Outsourcing responsibility for security and administration. The members are satisfied.

    • Like 5
  2. 9 hours ago, Ivan Gretsky said:

    For some reason we can’t just do

    
    $config->statusFiles['ready'] = 'ready-dev.php';

    and have to override the whole array. Maybe you PHP gurus can explain this in the comments.

    I am not a guru, but:

    When you access $object->property, a magic __get() method is called that returns a copy of the value of this property. If the value is an array and you try to add an item, only the copy is affected, not the original property value. For this reason, an error message is displayed that your attempt to change the value has no effect. The magic __set() method must be used to change the (whole) value of the property.

    Both ways (yours and @horst 's) are fine to set the value.

    • Like 2
    • Thanks 1
  3. As far I can see you handle only the array version of the get parameter 'level', but not the pipe separated version. I didn't tried it out, please check:
     

      if($input->get->level) {
    	if (is_array($input->get->level)) {
    		// Level is an array. Code adapted from Ryan's snippet here:
            // https://processwire.com/talk/topic/3472-enable-pagination-for-search-results/?tab=comments#comment-38042
            $level = array();
            foreach($input->get->level as $id) $level[] = (int) $id; // sanitize to INTs
            $level = implode('|', $level); // convert to 123|456|789 string, ready for selector
        } else $level = "$input->get->level";
      }
      else {
        $level = '';
      }

     

    @flydev ?? ... one second quicker ?

    • Like 1
    • Haha 1
  4. @Hurme

    On 5/4/2020 at 1:10 PM, Hurme said:

    If I try to use #ff000000 I get HTML 5 field error stating "Please match the format requested" and saving the page fails.
    If I try to use #000000 I get "InputfieldColor: Does not match required pattern: /#?[a-fA-F\d]{8}/"

    This looks like you have choosen the wrong input type:

    217156930_Bildschirmfoto2020-05-15um14_14_58.png.08825458e74dd386e1570a08ab5c6174.png

    On 5/4/2020 at 1:10 PM, Hurme said:

    EDIT: It would be awesome if I could use RGBA(0,0,0,0) as input value as well.

    For your needs please use SpectrumColorPicker as Input and add the following code

    showAlpha: true, showInput: true 

    in the color picker options field. This setup will provide something like:

    1579478737_Bildschirmfoto2020-05-15um13_07_40.png.2cce0d91017e7462df0a598a77be9b06.png

     

  5. I have added a new field type to the FieldtypeColor package. It is still in beta, but is already working quite well. The module is an extension of the Core FieldtypeOptions module and offers colors as predefined selectable options via 4 different input field types (Select, SelectMultiple, Checkboxes and Radios).

    Please try it out and if you like it, recommend it in the modules directory ?

    2 Screenshots

    1748004534_Bildschirmfoto2020-05-15um12_49_48.thumb.png.0b07dd9b376aa90b44dbebfbce3585f1.png1826288932_Bildschirmfoto2020-05-15um12_50_07.thumb.png.da3d6773a40262572b1621ef4e94d80b.png

    • Like 13
    • Thanks 2
  6. You need to enclose the api vars with curly brackets if there is more than one arrow in it.

    echo "<img src='$front_img_800->url'>"; // good
    echo "<h2>$item->front_productpage->title</h2>"; // bad
    echo "<h2>{$item->front_productpage->title}</h2>"; // good

    Read more:
    https://processwire.com/talk/topic/4439-when-do-we-need-curly-brackets/
    https://www.php.net/manual/de/language.types.string.php#language.types.string.parsing.complex

    • Like 3
    • Thanks 1
  7. 9 hours ago, Robin S said:

    Technically you might be able to use hooks and custom CSS to modify a core Page Reference inputfield such as AsmSelect to include a thumbnail image but it would be quite advanced/challenging.

    ... indeed ...

    18 hours ago, Pip said:

    and the title of page in the radio button? 

    For some other page reference inputfields like radio buttons or checkboxes the following hook example could be a first approach. I use it for a field to select a system user. Each label is preceded by a user icon. It should work for checkboxes as well. You need to hook in InputfieldCheckboxes then.
     

    $this->addHookBefore('InputfieldRadios::render', function($e) {
        $input = $e->object;
        // quick exit
        if ($input->name != 'clients') return;
        $options = $input->getOptions();
    	// $key = page ID
        foreach ($options as $key => &$label)  $label = "<i class='fa fa-user'></i> $label";
        $input->setOptions($options);
    });
    
    $this->addHookAfter('InputfieldRadios::render', function($e) {
        // quick exit
        if ($e->object->name != 'clients') return;
        $e->return = wire('sanitizer')->unentities($e->return);
    });

     

    • Like 1
  8. Steps to solve this:

    • create .js file which sends your sort criteria via form and receives the updated page list. Reload page or update content (ajax)
    • get the input (sort criteria) via PW API:
      $input->post

       

    • sanitize your input

    • select pages from DB
       

      $pages->find('template=xy, parent=xy,sort=criteria1,sort=criteria2, ... and so on);

       

    • render updated list.
    • Like 1
  9. This problem is still not solved. Strange results:

    // check if field is empty (NULL)
    $p = $pages->get("datetime="); // SQL Error
    $p = $pages->get("datetime=''"); // SQL Error
    $p = $pages->get("datetime=0000-00-00 00:00:00"); // SQL Error
    
    $p = $pages->get("datetime=0"); // expected result, will find a page with datetime = 1970-01-01 00:00:00
    $p = $pages->get("datetime=null"); // will find a page with datetime = 1970-01-01 00:00:00 why?
    var_dump($p->getUnformatted('datetime')); // if a page exists result -3600 due to the locale

    I need to check if the field is not set via selector. Any ideas? Currently I exlude this from the selector and loop the results (bad solution)

    https://github.com/processwire/processwire-issues/issues/973#issuecomment-625678587

     

     

     

     

     

    • Like 1
  10. On 5/4/2020 at 5:02 PM, ttttim said:

    Or is there a simple way to disable the JS colorpicker from https://modules.processwire.com/modules/fieldtype-color-picker/?

    With FieldtypeColor https://modules.processwire.com/modules/fieldtype-color/ you have multiple options for the Inputfield:
    Text, HTML5 Color, any Javascript ...

    If you are able to create a custom SQL table for your colors FieldtypeSelectExtOption https://modules.processwire.com/modules/fieldtype-select-ext-option/ is a possible solution for your needs, since you can use the hex code as the value here.

     

     

    • Like 1
  11. On 4/21/2020 at 2:32 AM, Robin S said:

    I actually ended up writing my own backup script because I wanted the backup to run by cron job at a fixed time rather than have the unpredictability inherent in LazyCron.

    I use this 5 lines of code, placed in an access controlled folder under root, to run a cronjob at fixed time. Just set 'cycle' in module settings to 'none' to prevent database backups triggered by LazyCron as well.

    <?php namespace ProcessWire;
    $root = dirname(__DIR__);
    include_once("$root/index.php");
    $cdb = $modules->CronjobDatabaseBackup;
    $cdb->cronBackup();

     

    On 4/20/2020 at 5:04 PM, horst said:

    The other way round, if I create manual dumps and want to delegate them to CDBs cleaning routine, I can include the identifier word

    Thanks for the input. I thought about it. In the end, I'll leave it as it is, and the inclusion of manually created dumps in the cleaning routine remains the standard. When I manually create a dump, I usually move or download it immediately. I rarely (never?) leave it on the live server and I want the files removed automatically. The default name created by ProcessDatabaseBackups is the database name. Just use this as the 'stopword' and use a different name format in the setup of CronjobDatabaseBackup and voila it works exactly as you want it.  Furthermore there is also the option to save the files in a user-defined directory. Manually created dumps are then never affected by the CDB's cleaning routine.

    • Like 3
  12. On 4/18/2020 at 4:37 AM, Robin S said:

    @kixe, I feel that the settings "Maximum number of backups" and "Remove backups older than" should only apply to backups created by CronjobDatabaseBackup. If the user has made manual backups, or backups have been made by a different module, then CronjobDatabaseBackup should never delete those backups. What do you think?

    This should have been already implemented with the option to set a custom storage path. Unfortunately I recognized a bug while looking in this. This bug is fixed now and I made some additional changements. Please update to v1.2.3.

    The automated cleanup effects only the custom path and not site/assets/backups/database/ used by ProcessDatabaseBackups. Currently you cannot use ProcessDatabaseBackups to edit backups stored under a custom path.

    I added functionality to protect files by 'stopword'. Files having this in its names or descriptions will be protected from beeing deleted by the cronjob. Just set the 'stopword' in the module config.

    @bernhard @horst @Robin S
    I hope the fix helps and feeds your needs (?)

     

    • Like 1
    • Thanks 2
  13. Example with a multidimensional array. RepeaterMatrix fieldname = 'fieldname'

    • first level: page where the repeater field lives in, indexed by ID
    • second level: per page repeater items indexed by ID
    • third level: field inside repeater indexed by name
    $rp = $pages->find('fieldname.count>0');
    $return = [];
    
    foreach ($rp as $p) {
        $return[$p->id] = [];
        // RepeaterMatrixPageArray
        foreach ($p->fieldname as $item) {
            if ($item->type  != 'basic') continue;
            $return[$p->id][$item->id] = [];
            // RepeaterMatrixPage
            foreach ($item->template->fields as $repeaterField) {
                if ($repeaterField == 'repeater_matrix_type') continue; // we do not need this
                if ($item->$repeaterField === '') continue; // if you want to ignore empty strings
                $return[$p->id][$item->id]["$repeaterField"] = $item->$repeaterField;
            }
            // remove if empty
            if (empty($return[$p->id][$item->id])) unset($return[$p->id][$item->id]);
        }
        // remove if empty
        if (empty($return[$p->id])) unset($return[$p->id]);
    }
    
    var_dump($return);

     

    • Like 1
  14. On 7/2/2019 at 12:27 AM, Robin S said:

    @jonassalen, open the ProcessSetupPageName.module file in your code editor and try replacing this section at the top of the createFromFormat() method...

    
    if ($languageID == null && $this->languageSupport == true) $languageID = $this->wire('languages')->getDefault()->id;
    $langID = $this->wire('languages')->get($languageID)->isDefault()? null : $languageID;
    
    if ($this->languageSupport) {
    	$userLang = $this->wire('user')->language;
    	$this->wire('user')->language = $this->wire('languages')->get($languageID);
    }

    ...with...

    
    $langID = null;
    if ($this->languageSupport) {
    	if ($languageID == null) $languageID = $this->wire('languages')->getDefault()->id;
    	$langID = $this->wire('languages')->get($languageID)->isDefault()? null : $languageID;
    	$userLang = $this->wire('user')->language;
    	$this->wire('user')->language = $this->wire('languages')->get($languageID);
    }

     

    Sorry for not looking in here. I replaced the code as recommended by @Robin S without further testing and hope it works well now. I didn't use the module by myself for a long time. Stay healthy!

    • Like 1
×
×
  • Create New...