Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


heldercervantes last won the day on March 28 2018

heldercervantes had the most liked content!

Community Reputation

474 Excellent

1 Follower

About heldercervantes

  • Rank
    Sr. Member

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Porto, Portugal

Recent Profile Visitors

3,628 profile views
  1. 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. covered-compressed.mp4
  2. 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 🙂
  3. 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.
  4. 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 😕
  5. 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
  6. 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.
  7. Just to add a suggestion. This field can't be used as a condition for another field's visibility. It's an easy fix though, just have to add an ID to the field (matching the name) and it starts working.
  8. 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
  9. 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.
  10. 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.
  11. 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.
  12. heldercervantes


    Hey guys. Fresh off the oven. We're still polishing a bit, but went live anyway: https://inovtex.com/ Sorry this one is in Portuguese only, so you'll probably need the old google translate for it.
  13. Yep, that's exactly the behavior I was looking for. Time to get experimenting Thank you all
  14. 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
  15. Yup. Add /wp-admin to the URL and you're in the login screen. They made some design changes. Maybe whoever did it was more comfortable in WP?
  • Create New...