Jump to content

elabx

Members
  • Posts

    1,479
  • Joined

  • Last visited

  • Days Won

    21

Everything posted by elabx

  1. I know you asked for a configuration but, maybe hook here? <?php $wire->addHookAfter('ProcessPageAdd::getAllowedTemplates', function($e){ $templates = $e->return; $specialTemplate = wire('template')->get('specialOne'); $parent = $pages->get(wire('input')->get->parent_id); if($parent->template != "sub"){ unset($specialTemplate->id, $templates); $e->return = $templates; } });
  2. Reading more on your project I think this is the right way to do it, RockFinder and RockGrid are very oriented in display the data in one shot using the browser for what I understand. You shouldn't really have that much issues using the built in pagination. I have a project where I paginate about 2 million pages and works (not blazing fast) but it does work at a reasonable speed. As @horst suggests, ProCache makes a whole world of difference too.
  3. Definitely take a look at RockFinder3 along Rock2Tabulator.
  4. Set the form's select field's name to "tag[]" so the inputs are put in an array. Then $input->get->tag should return an array. I'm still not very sure in your code where you are doing the search for tags but you seem to be very close ? As for the selectize, "on load" values: https://github.com/selectize/selectize.js/issues/236#issuecomment-73763003
  5. On your first if statement you are checking for a URL segment, not a GET variable. Should be like this for GET variables: if($input->get->tag){ // find with tag } else{ //find all } To select one or more tags you basically need to submit a form with the tag selection using a select field with multiple attribute enabled. Or if you need something more fancy, check selectize: https://codepen.io/i_cant_rap/pen/qNdXyj
  6. Are you sure the $input->get variable is set? Is this code executing on form submission? Otherwise, it won't work because the $input->get->tag variable won't be filled. Second on this loop: foreach($found as $image){ ... } $image is not an image object, it's a page object, $found is an array (more precisely, a PageArray) of pages. Check again this code: foreach($found as $p){ $imagesWithTag = $p->images->findTag($tag); foreach($imagesWithTag as $image){ //this is now possible $image->size(100,100); } }
  7. The image field have a builtin tag field, activate it on the field config. Well you could approach this by setting a form with a select input with the possible categories, then on the backend: <?php //form submits to domain.com/search/?tag=sometag $tag = $input->get->text('tag'); //All pages with image field and certain tag $found = $pages->find("images.tags~=$tag"); foreach($found as $p){ $imagesWithTag = $p->images->findTag($tag); //do your stuff }
  8. Is this meant to work on the frontend templates or on the processwire admin?
  9. Didn't want to imply your module needs anything or that it is "missing" something or that I was asking for a feature, I apologize if that's how it came out! Just wanted to give an example of an exception to the norm in case anyone finds this thread and of course, I agree it's the mission of all of us to contribute to open source and I must say this community has inspired me a lot to thrive into that direction rather than just consuming the work of others but also contributing, first step is to solve the very serious personal time management issues I have and just force me to do get open source done lol. So basically how it's useful for me is that, I keep a bunch of sites on one server and they all share template files and fields configuration. I keep files in sync using git and git worktrees, and with a shell script I make merges from the dev branch into the rest of the branches, including the migration files (each site is a branch). Then, if I need to make an update that involves any adding/removing fields I also have another shell script that goes on every site directory and runs a specific migration. It saves me a lot of time to run this for the 50+ sites I manage, I can very easily see if an error occurred, if migration was already run, if it didn't exist (then it means that site is now correctly wired up to the git repo), etc. Probably this is the least likely scenario of most PW users lol, as I have the feeling that most of PW users build heavily customized sites, for very specific requirements.
  10. Just to throw an opinion here, I still use @LostKobrakai module due to the command line support and I do like the way it works and how it keeps track of migrations run, which I'm not sure it's done in RockMigrations. But I guess RockMigrations could be made to work by invoking migrations script with the php command and add some tracking, I do like a lot how the field migrations are described here.
  11. Guys I wanna shoot myself, I randomly restarted the script, no updates, and it is going smooth at 16M of memory usage, now I feel the server hates me lol. I have no idea how this could have happened. Wow I had no idea this could happen, in this case I've already tested iterating trough the whole CSV and no memory issues even a count($records) works really well. Thanks everyone for your help! I'll get back on what I find out.
  12. Hi! I am iterating a CSV with a few million rows, that I have already imported into ProcessWire and I want to add some more information. This is a sample of the script (the part that matters), ran on the command line, which iterates through the CSV tries to find an existing record and if successful, updates a page reference field. The problem I'm having is that the script is bulking up memory, and well, eventually passes out. I'd love to know if anyone knows what I could be doing wrong in terms of releasing memory. // This function is called once in the next foreach loop, on every iteration. function getCategories($record, $limit){ $categories = new PageArray(); for ($i = 1; $i < $limit; $i++) { $code = wire('sanitizer')->selectorValue($record["Field_" . $i]); if ($code) { $selector = "template=category, title=$code"; //echo "$selector \n"; $found = wire('pages')->get($selector, ['cache' => false]); if ($found->id) { $categories->add($found); } } } return $categories; } $csv = Reader::createFromPath('./file.csv', 'r'); $csv->setHeaderOffset(0); //Iterable object from PHP CSV League class $records = $csv->getRecords(); foreach ($records as $offset => $record) { if ($offset == 1) { $database->beginTransaction(); } if ($offset % 100 == 0) { if($database->inTransaction()){ $database->commit(); } $database->beginTransaction(); echo "Passed $offset... \n"; //Here's where I check the memory usage echo round(memory_get_usage(true) / 1048576.2) . PHP_EOL; } $existing = wire('pages')->get("template=supplier, unique_id={$record['Unique ID']}", ['cache' => false]); if($existing->id && !$existing->categories->count){ $categories = getCategories($record, 15); $existing->of(false); $existing->categories = $categories; $existing->save('categories'); } $pages->uncacheAll(); } So far, what I've tried is removing the $pages->get() call and it just works fine, memory stays at around 16M. I've also used a similar script when creating the pages, and in that scenario $Pages->uncacheAll() seemed to worked well.
  13. I'd say the most intuitive way in ProcessWire is the approach @BillH mentions, I've sometimes also approached it using a repeater field, with with url, menu label and another repeater field for second level menus.
  14. Try to put the $myRole variable definition inside the hook's anonymous function.
  15. Throwing a wild guess, but do you have the page-publish permission added to the employee role??
  16. Was thinking more of these, because I've seen all the github issues.
  17. I'm going to die if any of the hosting providers I use suddenly flips the switch to mysql 8 lol
  18. Well its just a simple listing of content, I basically I was just wanted to give RockFinder a shot to see if it performed faster and it does! Basically brings down the time to nothing. Took a dive into the code and notice how you strip down the SQL select, I am guessing that's why it peforms faster since the original db query includes SQL_COUNT_FOUND_ROW. So, I'm starting to think I have no way to solve this without counting? Unless I make a prev/next pagination only maybe? Of course, I can always cache all of this, but just wanted to see if I could squeeze out a bit more of performance from the raw request.
  19. Question, how do you go about rendering the paginator with RockFinder3?? I am testing on a table with about a million pages, and it indeed loads each page (as in paginated page) super fast! BUT, I can't seem to figure out how to actually render the paginator. I'm going to take a wild guess that the counting is going to take a long time.
  20. There is a sort property on pages that can be set: https://processwire.com/api/ref/pages/sort/ So most likely you'll have to use the callbacks in UIkit to sort this out ?
  21. Got this working on your codepen: var accordions = $("[uk-accordion]"); accordions.each(function(index, item){ UIkit.util.on(item, "beforeshow" , function(e){ accordions.not(item).each(function(index, item){ var opened = $(item).children('.uk-open'); var openItemIndex; if(opened.length){ openItemIndex = opened.index(); } if(openItemIndex !== undefined){ UIkit.accordion(item).toggle(openItemIndex); } }); }) });
  22. Isn't that the default behaviour of the accordions? That's what it would seem like from the examples on the page, the component has a "multiple" option that is set by default on false. Maybe you need to update UIkit? EDIT: Just re-read, that it's ANOTHER accordion. I'd try something like this, just wrote it on the fly so there are probably errors, but the idea is to close any other accordions with the component's API, rather than adding/removing classes. var accordions = $('.uk-accordion'); accordions.each(function(index, item){ UIkit.util.on(item, "show" , function(){ accordions.not(item).each(function(index, item){ var opened = $(item).children('.uk-open').index(); UIkit.accordion(item).toggle(index); }) }) })
  23. There's gotta be some CSS file loading (if the site has any actual styles), check your Network tab on chrome to check what's loaded, also if you inspect any element it should indicate the style's source. Otherwise, it might have been output right into the html body.
  24. ☝️ I'd love to help while learning! In my personal experience Fieldtype/Inputfield development is like one of the few things of the modular approach of ProcessWire that isn't completely clear to me, so I think a tutorial would be super useful for a lot of people. I'd like to stop abusing RuntimeMarkup some day haha (which is and awesome module of course!)
  25. Could post a brief code snippet of what you are trying to do? I am assuming you should have something like this: On _main.php: <footer id="footer-region"> ... </footer> On other_template.php <div id="footer-region" pw-append> <script>...</script> </div> @huseyin Just to give my personal opinion, I just really like that with markup regions you can code the markup pretty much like if you were doing normal template output, no string concatenation to fill up a variable to output content, instead of doing that you wrap your markup with the Markup Regions conventions. That would probably be the downside, that you have to understand that maybe not all markup visible in your code, will actually end up in the output markup (depending on how you use it!), and this has sometimes caused me confusion while coding, but nowadays I practically code all my templates with markup regions strategy. So in conclusion, I see it more as a "style" rather than something better or worse.
×
×
  • Create New...