Jump to content

heldercervantes

Members
  • Posts

    389
  • Joined

  • Last visited

  • Days Won

    15

Posts posted by heldercervantes

  1. @wbmnfktr Strange. If I do that on a template file directly, it works fine. But if I put it in a file that's included, it breaks. WTH? ?

    Also, I just tested on another site that I'm working on and it works there. Both projects were setup the same way, in fact, the one that has this issue started from the other (basic setup with a docker-compose that sets up a container running the PW installer). Environment is exactly the same and the only difference I can see is that in the other one I selected the languages profile on install.

  2. 3 hours ago, wbmnfktr said:

    Wow... had this bug years back. Most have been one of my very first posts here.

    Nontheless... it's either the global or autojoin flag (can't remember it anymore) in the advanced settings tab for the title field that is somehow the reason for this.

    But yes, adding another language solves the problem as well.

    First time I ran into it in some 7 or 8 years making stuff in PW ?

    • Haha 1
  3. Hey guys.

    First time I'm having this issue. Started a new project, downloaded the current master 3.0.165, set it up using the languages template. First field I add is a repeater with a title and image field, add that to the home template, edit the page, put some content, save... and the title is blank.

    Further testing and all other fields seem to work. This is the only one that reverts to blank when I save. Being required or not makes no difference. Nothing in the log.

    Any idea what's going on? I'm about to give up and make a new field.

    SOLVED
    For anyone who hits this snag, it seems this happens when you have languages but only one is set up. As soon as I added a second language, this behaviour stopped.

  4. On 3/17/2021 at 3:21 PM, DV-JF said:

    Stumble upon this.... After reading and reading again I don't get it... In German we say "Ich stehe auf dem Schlauch ? " Which ID do I have to add to which field in order to use the selection in this field as a condition of visibility for another field?

    Hints are welcome ? many greets!

    Sorry, only noticed this message now. If you're still wondering about this, go to the InputfieldSelectFile.module file and look at line 96. Should be something like this:

    $output.= "<select name='" . $this->name . "' id='" . $this->name . "' class='uk-select'>" . implode('', $array) . "</select>";

    In your file you're probably missing this id=... part. You just need to add that.

  5. Long time no post. Here's my latest:

    https://maisliberdade.pt/

    Mais Liberdade is a liberal think-tank in Portugal, promoting the values of liberal-democracy, individual freedom and free market economy. It's a non profit that gathers collaboration from people from multiple portuguese political parties, members of the european parliament, economists, professors, etc.

    During development, an announcement page was set up with a registration form for founding members. In that period of about a month, around 200 subscriptions were expected, but in the end we got over 6000 subscribers.

    This website features essays, events, videos and a free library that, at the time of this post is counting 400 books.

    The frontend was built using web components (Stencil js). Basic pages are built with a modular approach, I'm attaching a video of how they are created. The approach is a simple repeater with a custom block type selector interface. That selector is basically a modified version of FieldtypeSelectFile. I've hacked that module to expect a PNG to be available for each PHP file in the blocks folder, and modified the input field to generate a button grid after the select.

    This is lovely to use from the editor's perspective, but it's something to improve for the developer experience, because in the end this is a repeater, that has to contain all fields that each type of block needs, and for each of those fields I have to set it to show only if the blockType field equals X, Y or Z. With a lot of different block types this takes some planning and easily becomes hard to manage, but it's the best approach I found yet and the benefit for the editor's experience is well worth it.

    • Like 17
  6. Ok this one is mindblowing, looks like a perfect upgrade from the solution I'm currently using.

    I'm getting by with a repeater and a modded version of FieldtypeSelectFile that basically lets you select a php from a given content blocks directory, assumes there's a png that goes with it, and renders a neat block selector. From there, it's just hiding and showing fields depending on the value of that selector. It's not the most elegant of solutions from the "setting up" perspective, but quite nice and comprehensive for the editor and the php code on the frontend super understandable.

    Brad seems to try to do just enough. Looks great for custom, controlled content blocks. Too much freedom and the editor usually makes a mess ?

    content-blocks.png

    • Like 5
  7. Found the solution. Thanks @teppo for your help. Your suggestion gave me the clue I needed. Here's the fixed code:

     

      $results = ** a somewhat complex search that returns a pagearray **
    
      $perPage = 20;
      $start = ($input->pageNum -1) * $perPage;
      $results->setLimit($perPage);
      $results->setStart($start);
      if ($input->get->f) $input->whiteList('f', $input->get->f);
      if ($input->get->l) $input->whiteList('l', $input->get->l);
      if ($input->get->a) $input->whiteList('a', $input->get->a);
      if ($input->get->t) $input->whiteList('t', $input->get->t);
      $pager = $modules->get('MarkupPagerNav');
      $pager->setPageNum($input->pageNum);
      $pagination = $pager->render($results, [
        'nextItemClass' => 'next',
        'previousItemClass' => 'previous',
        'currentItemClass' => 'current',
        'separatorItemClass' => 'separator',
        'numPageLinks' => 5
      ]);
    
      foreach($results->slice($start, $perPage) as $item) {
        // render the thing
      }
    
      echo $pagination;

    Basically all that was missing was that setStart() call. Makes sense, as usual.

    • Like 4
  8. 47 minutes ago, teppo said:

    This sounds eerily familiar. Some  situations where this might happen are if you have a "start" specified in your selector, if page numbers are not enabled for the template, or if you have multiple pagers resulting in some kind of conflict.

    If nothing else helps but $input->pageNum has the correct value, you could perhaps go at this the other way around — not tested, but if you instantiate MarkupPagerNav manually you can try to force the page num:

    No cigar.

    "Start" is only used on that "slice" when I'm rendering the results. Page numbers are enabled on the template and there's only one pager in the page.

    I also double-checked, and $input->pageNum outputs the correct value. 

    Got to keep hacking at it ?

  9. Hi guys

    I'm having a weird issue with pagination. This is a not too straightforward search that in some circumstances even joins two pagearrays. The pagination renders correctly, with working links, whitelists the variables, the items list is correct as I navigate the pages but... for some reason the pagination always marks the first page as being the current one even if I go to the second, third, and so on.

    Here's my abbridged code:

      $results = ** a somewhat complex search that returns a pagearray **
    
      $perPage = 20;
      $results->setLimit($perPage);
      if ($input->get->f) $input->whiteList('f', $input->get->f);
      if ($input->get->l) $input->whiteList('l', $input->get->l);
      if ($input->get->a) $input->whiteList('a', $input->get->a);
      if ($input->get->t) $input->whiteList('t', $input->get->t);
      $pagination = $results->renderPager([
        'nextItemClass' => 'next',
        'previousItemClass' => 'previous',
        'currentItemClass' => 'current',
        'separatorItemClass' => 'separator',
        'numPageLinks' => 5
      ]);
    
      $start = ($input->pageNum-1) * $perPage;
    
      foreach($results->slice($start, $perPage) as $item) {
        // render the thing
      }
    
      echo $pagination;

    Any ideas?

    Thanks

  10. 4 hours ago, sambadave said:

     

    @kongondo - When rendering out the base image on the page I tried to add a width using processwire's standard image->width($x, $options) approach however I can't seem to get the image to ender when this is applied.

    Does not passing $options produce a different result? It's weird, I've used this module a bunch of times and never had such an issue, but I usually don't specify options on resize and go with the default.

  11. Found the issue. To whoever it may concern, as of this day the select file fieldtype doesn't support being a condition for other field's visibility.

    It's easy to hack though. On the module's file, find the render function and add the id property to the <select> element that it outputs, with $this->name as value. That will make it work

    • Like 1
  12. I've used page field visibility according to a select options value before with good results. But can't seem to get it to work with a file select field. Here's what I'm doing:

    This all lives in a repeater. The file select (call it myFile) points to a folder and I can select files correctly.

    Then there's a (call it description) field that should be if a specific file is selected on myFile (say x.php).

    Editing the fields inside the repeater, `Show this field only if` is set to:

    myFile="x.php"

    I tried it with single or double quotes, with or without the `.php`, and the result is the same, the field is always hidden.

     

    In previous similar implementations, I've used select options with a validation such as `myFile=1`, now I'm hoping to improve this method, excluding the need to update the files field every time something is added, and also make it a bit less cryptic to manage the fields' visibility.

  13. 17 minutes ago, Torsten Baldes said:

    I did just that. I changed the col types for x & y in the DB from int(11) to decimal(5,2) and replaced the (int) with (float) for x & y in the module files.

    I have also on occasion tweaked the styles for the markers, so that the active one is opaque and the others transparent. That helps when you have a bunch of them close together.

    • Like 1
  14. Sorry this is going to be vague but...

    I've hacked it to support floats in some projects. It's not too hard. Just had to look in the module's code where the fields are defined and it's relatively easy to find the INT and change it to float. You may have to do the same in the DB as well. Takes some fiddling.

    I wish I could be more specific, but after formatting my machine I'd have to go through a bunch of backups to find actual code.

    • Like 2
  15. Hey there.

    Anyone know of a clever approach to illustrate an options field with an image?

    I often do modular content editors using a repeater and an options field for the type of block. The repeater has all fields, and each fields' visibility is configured so it appears only when it's relevant to the chosen block type. This is cool, allows a lot of flexibility, but on more complex solutions I sometimes find that the admin could benefit from seeing an image that illustrates the option that's chosen. Kind of like the theme choosing step when you install PW.

    Any ideas on how to do something like this?

     

    Thanks

  16. Disclaimer: Complete noob in security here.

    So, at the risk of sounding silly, would it make sense to keep the key in a different server?

    I mean, if the site's server is compromised, the key would be visible in the code. So, I'm thinking the key could be stored in a different server that's "completely airtight", and the only thing it does is listen to a key request from the main site's server, checks the IP and lends it the key. So any site scripts that needed to handle an encrypted field would have to make that request first.

    Does this make sense? Or would a breach where someone can access the DB + PHP files be so far gone that they'd also easily make the server request and expose the key?

    • Like 2
  17. 19 hours ago, szabesz said:

     

    Well, encryption per-se is not mandatory, but "Data protection by design" is: https://gdpr-info.eu/art-25-gdpr/

    They give leeway to choose an approach, but ask us to do something about it and not just let the info lying around for easy picking. Since pseudonymization is too complex for small to medium projects, I'd say our best bet would be on encrypting sensitive info like emails, names, id numbers, phones and addresses. As far as the things we build, there shouldn't be much hassle. Unless you're building apps that store medical records or something like that.

  18. Well I just finished writing up the privacy policy for my site. That was a hand full.

    Yeah, information backups will have to be considered carefully. Or just don't do backups like most people :D

    Now, about personal data anonymization and pseudonymization. What can we do in a PW installation to comply? Can something be made to automatically encrypt PW users data or pseudonymize it?

    This particular part of the requirements is what's driving me crazy. 

×
×
  • Create New...