Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/11/2025 in all areas

  1. Hi psy, If you are looking for a quick-but-reliable way to get CSV docs into PW pages, here's a snippet I've been using for years. It might not do as much as the official module, but it will get you up and going. <?php // Script to create pages from rows in a CSV file //Open CSV file. $fileHandle = fopen("replace-with-file-name.csv", "r"); //Iterate through CSV rows. // NOTE: if you have a header row, it will be used to create a page. while (($row = fgetcsv($fileHandle, 0, ",")) !== FALSE) { // Create a new ProcessWire page from each CSV row, using the row's array 0-based index matched with the correct fields. // Set up pages in the ProcessWire page tree. $np = new Page(); // create new page object $np->template = $templates->get(xx); // Set the template to use for created pages. $np->parent = $pages->get(xxxx); // Set the parent ID for created pages. // Turn output formatting off $np->of(false); // Set field values from the 0-based index of the CSV row. $np->title = $row[0]; $np->name = $row[0]; $np->field_name1 = $row[1]; $np->field_name2 = $row[2]; $np->field_name3 = $row[3]; // Save the page $np->save(); }
    1 point
  2. @ryan I'd be interested to hear how you work on a project with multiple developers and manage keeping each developer's development instance in-sync. For example, are you using a migrations module like RockMigrations or writing migrations in a module specific to the site that adds/updates fields/templates/pages/settings when the module is updated using a version compare? Or are you doing something completely different? I'd be interested to hear how you handle this given that ProcessWire stores much of its configuration in the database.
    1 point
  3. Not tested, but try replacing count() with wireCount()
    1 point
  4. Ok, so I decided to scratch my own itch on this one... I need to handle WebP's which include transparent regions so I've created a modified version of the @Robin S module (https://processwire.com/modules/webp-to-jpg/) but which allows you to choose between PNG or JPEG as the target format. https://gitlab.com/applab/pw-uploadwebp
    1 point
  5. Yeah, you can probably replace that line with this if($page->id && $page->if('ImportPagesCSVData')) { to make it work on your end. For a permanent solution the module will have to be updated.
    1 point
×
×
  • Create New...