Jump to content

Search the Community

Showing results for tags 'import'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Hallo, i'm searching for a way to import entries from a css file. I have a csv (or txt) file with some comma-separated data and want to import just 1 entry into a list (text or textarea field) in the PW (3.0.33) backend. I tried the "Import Pages from csv files" module. I'm not sure if this is the right solution. The file can't be imported, because after Step 2 and starting the import, the "Unable to import page because it has no required 'title' field or it is blank" error message appears. I'm doing something wrong or is using this module the wrong way of importing csv entries? Mario
  2. [Posted this in another post, but realized it's doesn't really pertain to it, so I've moved it to this new topic -- again sorry] Hi Ryan (and everyone else!), Just starting using PW and I'm loving it... I've got a site build that requires a bunch of CSV loading and would like some help with API Importing, as I am running into some glitches with page fields. So far I have a bunch of CSVs that work fine with my php code, but I have one that crashes, unless I put in the pageID. I think it may be something larger as I have tried using both BatchChildEditor & ImportPagesCSV modules with a modified CSV, and both get the same error as my code. So, here's my code, it does the following: Reads a page field to get CSV filename Reads 1st row of file to figure out what template and parent to use Reads 2nd row for field titles Processes the remaining rows as data, it also echoes out what it is doing -- not elegant, but it's only for my use // If no filename exit if ($wire->page->getUnformatted('section_slogan') == '') throw new Wire404Exception(); // File Pointer $myfile = "http://" . $config->httpHost . $config->urls->templates . "loaders/" . $wire->page->getUnformatted('csvfilename'); $content = "<p>Using Loader File '{$myfile}'</p><hr/>"; // Read The Data File if (($handle = fopen("$myfile", "r")) !== FALSE) { // Get the Setup Info if (($data = fgetcsv($handle, 0, ",")) !== FALSE) { $myTemplate = $templates->get("$data[0]"); $myParent = $wire->pages->get("path='$data[1]'"); if (($myTemplate->id == 'NullPage') || ($myParent->id == 'NullPage')){ throw new Wire404Exception(); } } else { throw new Wire404Exception(); } // Setup the parent $newItem = new Page(); $newItem->template = $myTemplate; // Tell User what's going on: $content .= "<p>Adding New Pages based on the '{$newItem->template->name}' template to parent '{$myParent->title}' path: '{$myParent->path}'</p><hr/>"; // List out the fields in the template $num = count($newItem->fields); $content .= "<p> $num fields in template</p><ol>"; foreach($newItem->fields as $itemfd) { $content .= "<li>" . $itemfd->name . "</li>"; } $content .= "</ol><hr/>"; // Read header record and match-up fields to template $fieldmatchup = ''; if (($data = fgetcsv($handle, 0, ",")) !== FALSE) { $num = count($data); for ($c=0; $c < $num; $c++) { foreach($newItem->fields as $itemfd) { if($data[$c] == $itemfd->name) { $fieldmatchup[$itemfd->name] = $c; } } } } // Show the File's Field Array $content .= "<p>Display the Field Array</p><ul>"; foreach($fieldmatchup as $item_key => $item_value) { $content .= "<li>['" . $item_key . "'] = '" . $item_value . "'</li>"; } $content .= "</ul><hr/><h4>Reading File</h4><hr/>"; // Now add the data $row = 0; $newItem = ''; while (($data = fgetcsv($handle, 0, ",")) !== FALSE) { $num = count($data)-1; $row++; $mySel = "parent=" . $myParent->id . ", title='" . $data[$fieldmatchup['title']] . "'"; $dupPage = $wire->pages->get($mySel); if($dupPage->id == 'NullPage') { $content .= "<p>newItem (" . $mySel . ")<br/><b>-- Creating from File</b>.</p>\n"; // Setup blank WireArray based on a template $newItem = new Page(); $newItem->template = $myTemplate; $newItem->title = $data[$fieldmatchup['title']]; $newItem->parent = $myParent; $newItem->save(); } else { $content .= "<p>Duplicate Found (" . $mySel . ")<br/><b>-- Updating from File</b>.</p>\n"; $newItem = $dupPage; } $content .= "<p> {$num} fields in record {$row}: <br /></p>\n"; $newItem->of(false); foreach($newItem->fields as $itemfd) { $key = $itemfd->name; if ($key != 'title') { $value = $data[$fieldmatchup[$key]]; $content .= "[{$key}] = [{$value}]<br />\n"; $newItem->set($key, $value); } } $newItem->save(); $content .= "<b>-- Saved: </b> <a target='_blank' href='" . $newItem->editUrl . "'>" . $newItem->title . " [" . $newItem->id . "]</a><hr/>"; } fclose($handle); } $content .= "<b>{$row} records added/updated</b>"; And here's a sample of data that works: (associated_stat & special_category are page fields) skill,"/systems/sol/" title,associated_stat,multiplier,special,special_category,body Alien Archeology,Int,4,,,"Skill description" Alien Tech,Tech,4,,,"Skill description" Alien Weapons,Ref,4,1,Weapons,"Skill description" And the file that's giving me issues:(pc_role_category, associated_book, sa_skill are page fields, career_skills is a multiple page field) cp-role,"/systems/sol/" title,pc_role_category,associated_book,page_no,verified_via,sa_skill,career_skills,body "Merc","Combat Related","Book Name","8","Book Review","Combat Zen","Athletics|Alien Tech|Drive|Shoot","Role Description" It's the associated_book field that's giving me the issue, if I blank it or put in the PageID it works, but with anything else it errors out with this: Fatal Error Call to a member function __unset() on boolean search Source File: ...\core\wire\modules\Fieldtype\FieldtypePage.module:439 431: if($value instanceof Page) { 432: // ok 433: } else if($value instanceof PageArray) { 434: $value = $value->first(); 435: } else if(is_string($value) || is_int($value)) { 436: $value = $this->sanitizeValueString($page, $field, $value); 437: if($value instanceof PageArray) $value = $value->first(); 438: if($value->_FieldtypePage_remove === $value->id) { 439: $value->__unset('_FieldtypePage_remove'); 440: $value = null; // remove item 441: } 442: } So, looking at this field, and the associated page template, everything is setup the same as all the other page fields, except that the page template in question (books) has a field that references a page field (associated_system) that I'm not even referencing, so I'm not sure if that's the culprit or not, but that is the only thing that separated this template from the others is this custom label code and that the pages are outside of the parent: And yes, I've removed the custom label and it still has the same error. With my luck it's something simple, but I can't see it... Any help would be appreciated
  3. Hi all, We have this huge website (over 7000 pages and a few dozen templates). We've used TextLanguage and TextAreaLanguage fields for all textual fields, and all image and file fields have their own description input boxes for different languages too. Now we'd need to export all pages and send them to our translator so they can translate all site contents with their specialized programs, and a way to import the translations back to our site alongside the content in original language. Has anyone done anything similar to this? How did you solve it? Maybe there already is a solid way to do this, or an idea we've not thought of yet. Thanks for any thoughts!
  4. So I ran into a snafu the other day and all my fields etc were deleted. I do Have a backup of the fields, but was wondering how to I go about importing this rtf into processwire. Nvm, I was stupid.
  5. I'm creating a general function for batch import, for a site migration, and while looping through fields (field names) to be imported for a page, I need to check whether the field is an image (or other file type), so that it can be imported after the first pave save. What would be the recommended way to check this, with PHP code?
  6. I'd like to read up on importing content from Textpattern into a fresh ProcessWire installation. I know there are more than a few Textpatrons here: Is there a tutorial or thread or blog post covering this? I've used Textpattern for years. I'm very familiar with it's database schema and pretty comfortable exporting and manipulating it with MySQL. ProcessWire's schema uses a totally different paradigm, and I'm not confident that I could simply dump the data and import it into ProcessWire with the same facility. I'm happy with Textpattern for most of the sites in which I use it, but there are a few that I think using ProcessWire would be a significant boon. Thanks in advance!
  7. Hello, I was getting a setOutputFormatting error for a CKEditor field that had Content Type set to "Markup/HTML with image management" while trying to save HTML to that field in the course of importing about 150 pages through the API. This happened although $p->of(false) was set. It took me quite a while to figure out that this error was thrown only when there were image tags in the HTML that should be saved to that field. Then I went and switched Content Type for that field to "Unknown". Now the import worked fine. After switching Content Type back to "Markup/HTML with image management" and running the import again, there were no errors anymore. I just thought I'd mention this here in case someone else is facing similar problems. This happened on a 2.6.15 dev install.
  8. Hi I'm new to PW so please be nice I've an existing site that I have backed up from previous host. Trying to move it to new host presented some errors so I decided to start fresh. I've a fresh install working OK but I'd like to import the old site to the new site. What's the best process to do this? Thanks for your help R
  9. Hi, I'll confess to having only just discovered ProcessWire, and am currently getting my head around the fundamental differences between it and other CMSs/CMFs I've used in the past. I'm very impressed with its potential though. I have a question however that I hope you guys can help me with. I'm involved in a project to implement a searchable database of dams from across the world (in fact something akin to the Skyscraper demo except that the dams will be searchable on many more criteria). We already have a database table containing all 600+ dams and I'm wondering how to import those into ProcessWire in a way that it can handle. Is it possible simply to add that table to the ProcessWire database and tell it how to interact with it, or will that complicate things further down the line? I don't fancy having to manually add all the dams to ProcessWire, since quite apart from the time and hassle it would also introduce human error. All advice is gratefully received Tony.
  10. In my home.php (a template, as you'd expect for the homepage) then I take a look at the URL segments. I want to provide some shortlinks, e.g. example.com/php redirects to example.com/languages/php/. That all works. But if I want to display a 404, by using "throw new PageNotFoundException();" then things go pearshaped: Fatal error: Cannot redeclare renderNav() (previously declared in /var/www/pw/public_html/site/templates/_init.php:20) in /var/www/pw/public_html/site/templates/_init.php on line 20 I'm not sure how to get around this? (or exactly why it's coming up) This is the case if I try to declare a 404 at the top of any template.
  11. Hi, i want to import stuff from Drupal to Processwire and have create an importscript but some things doesn't work. I import a list of questions from users and i will manipulate the page created date (thats work fine) and change the User to the right one. If the User dosn't exist, i will creat a new one. But this is the first problem i have, no user will be change or create... The second problem is to find out if the page does alrady exist or not. If the Page exist i will only modify some fields, otherwise i will create a new page..... To find out if the Page exist and whats the Page ID do i also need to import the Comments..... readCSV.php: // Read the CSV file and get an array of rows function readCSV($file){ $lines = array(); foreach(file($file, FILE_IGNORE_NEW_LINES) as $line){ $lines[] = str_getcsv($line); } return $lines; } import.php: while($i < $countArray){ // Initzalisierung der Variablen $title = $data[$i][0]; $date = $data[$i][6]; #$summary = ''; $body = $data[$i][1]; $categorys = $data[$i][4]; $tags = $data[$i][3]; #$images = ''; $authorName = $data[$i][5]; $sanitizTitle = $sanitizer->pageName($title); $post = $pages->get("template=$template, name=$sanitizTitle"); if(empty($post)){ $p = new Page(); // create new page object $p->template= $template; //set template post $p->parent = wire('pages')->get('/$parent/'); //set the parent $p->name = $sanitizTitle; // SANITIZE!!!! $p->title = $title; // added by Ryan: save page in preparation for adding files (#1) $p->save(); $p->created = $date; // Timestamp!!! $p->save(array('quiet' => true)); // To save the created Date $p->body = $body; // $p->summary = $summary; // Looking for the inizialisation $p->tags = $tags; $p->categories = $categorys; $p->save(); echo 'Created Page: '. $title .'<br>'; $authorNameSanitiz = $sanitizer->name($authorName); if($users->get($authorNameSanitiz)){ $authorID = $users->get($authorNameSanitiz); $p->createdUser->name = $authorID; } else { $u = new User(); $u->name = $authorNameSanitiz; $u->addRole("author"); $u->addRole("guest"); $u->save(); echo 'creat User: '. $authorName .'<br>'; $authorID = $users->get($authorNameSanitiz); $p->createdUser = $authorID; } $p->save(); #} // populate fields //$p->images->add('path/to/image1.jpg'); // add multiple to images field $i++; } The CSV: "Titel","Inhalt","E-Mail","Schlagworte","Thema","Benutzername","Beitragsdatum" "digitale Filme in der Strahlentherapie","Hi,<br>zur Zeit suchen wir in unserer Abteilung für Strahlentherapie in Regensburg eine digitales Filmsystem.<br>Welche Firmen bieten den solche Systeme für die Strahlentherapie an?<br>MfG<br>Jan<br>","janmee@web.de","","Strahlentherapie","pete","1437587189" "Gehalt MTA R","Hallo,<br>ich interessiere mich für den Beruf. Wo kann ich erfahren, was ich ausgelernt verdiene? Gibt es einen Tarifvertrag? In welchem ist man da wie eingruppiert? Vielen Dank<br> <br> <br> <br> <br> <br>","sweetmic@web.de","Gehalt","Radiologie","guest","1437303471" what am i doing wrong?
  12. Hello, i try to write an Import Script. Some basic skills i've learned from different postst. But its not really enough so i try to start a new Topic. I have an zip file with xml and images inside. The different objects have three different actions "ADD | CHANGE | DELETE" so the Idea is at the ADD Action to check is the page ID I use for the ID the Object Number alredy exist. If not create page if the Change Action than check if ID exist grab this Page and write new values if Delete Action then Grab this ID if exist and change Parent. IMPORTANT: After all I have to delete the Zip file and all the TEMP Files. How to handle in the right way temporary fils with processwire ? Maybe i dont need the external extract Script ? This is my current CODE: <?php $userRolesSelector = 'superuser'; // bootstrap ProcessWire. Update the path in the include if this script is not in the same dir include("./index.php"); if( ! wire('user')->hasRole($userRolesSelector)) { header('HTTP/1.1 403 Forbidden'); exit(1); } include "import/op_file.php"; // Different functions to handle the zip file EXTRACT Read etc.... // here some (pseudo/example)code set_time_limit( intval(60 * 5) ); // give it 10 minutes, you may also increase this echo "<pre>"; readXML(); exit; //******************************************** /** ----------------------------------------------------------------- * @desc Finde XML/ZIP, entpacken und einlesen der daten */ function readXML() { $opfile = new OPfile(); // dbg is a wrapper for "echo", so you can ignore it via one Flag in op_tools echo "DOC ROOT: ".$_SERVER['DOCUMENT_ROOT']; // Set your path here ... $ropa=dirname($opfile->GetTheRoot())."/"; //opfile $ropa=$ropa . "demo/"; echo "ROOT: ".$ropa; $modpa=$ropa; $projpa=$ropa; $origfolderfrom=$ropa."import/ftpin/"; $ftptemp=$ropa."import/temp/"; $folderfrom=$origfolderfrom; // Find the ZIP/XML File in the FTP Folder // $fileinfo will be used by following functions. you can add more information if needed $fileinfo= $opfile ->GetUpload($origfolderfrom ); // return = assoc-array $fileinfo ['temp']=$ftptemp; $fileinfo ['folder']=$origfolderfrom ; // Extract or Copy the Files, so we can prozess the xml info if ($fileinfo['type'] =='zip') { // if it is ZIP , extract it to temp $xmlfilename= $opfile ->ExtractZIP($fileinfo); echo "<p> XML ist:".$xmlfilename."</p>"; echo "<p>Kopiere: " .$fileinfo ['folder'].$xmlfilename ." <br> nach: ". $ftptemp.$xmlfilename."</p>"; }else{ // if it is XML copy it to temp $xmlfilename = $fileinfo['file']; copy ($fileinfo ['folder'].$xmlfilename , $ftptemp.$xmlfilename); echo "<p>Kopiere: " .$fileinfo ['folder'].$xmlfilename ." nach: ". $ftptemp.$xmlfilename."</p>"; }//if // XML File from temp folder $stat = $opfile ->LoadXML($ftptemp.$xmlfilename); $path = $ftptemp.$xmlfilename; if (file_exists($path)) { $xml = simplexml_load_file($path); echo "<p>Erfolgreich geladen <br></p>"; $nodeList = $xml->xpath('//immobilie'); } // you can access the XML Object by: $opfile ->XMLdata; if ($stat == true) { // read basic infos form XML File $xinfo= $opfile->decodeUTF8($opfile ->XMLinfo()); // print_r($xinfo); echo "Objekte im Import: ".$xinfo['anzimmo']."<br >"; echo "Anbieter ID: ".$xinfo['anbieterid']."<br >"; }else { // Error in Processing. Stop the run. $xinfo['anzanbieter'] =0 ; $xinfo['anzimmo'] =0; echo "Fehler In der XML Datei"; // exit can be put away. The For Loop does not run with azi=0 exit; }//if $azi=intval($xinfo['anzimmo']); // get the number of Objects in archive // save our start time, so we can find which pages should be removed $started = time(); // keep track of how many changes we've made so we can report at the end $numChanged = 0; $numAdded = 0; $numTrashed = 0; // the parent page of our items: /about/what/ is a page from the basic profile // update this to be whatever parent you want it to populate... $parent = wire('pages')->get('/about/'); if(!$parent->id) throw new WireException("Parent page does not exist"); for ($ni=1; $ni<=$azi;) { //$xinfo['anzimmo'] echo "<h2>=======Object=".$ni."======</h2>"; $idata = $opfile->GetOneImmo( $ni, $xinfo); // $idata stores all the values in the Array for current Object $action=$idata['verwaltung_techn'] ['aktion']['aktionart']; if ($action =='') { $action="ADD"; }//if $page = wire('pages')->get($idata['verwaltung_techn']['objektnr_extern']); if($action == 'ADD') { if(!$page->id) { $page = new Page(); $page->parent = $parent; $page->template = 'immo'; // template new pages should use $page->name = $idata['freitexte']['objekttitel']; echo "Adding new page:".$idata['verwaltung_techn']['objektnr_extern']." Titel ".$idata['freitexte']['objekttitel']." <br>"; $numAdded++; } // print_r($idata); // now populate our page fields from data in the feed $page->of(false); // ensure output formatting is off $page->title = $idata['freitexte']['objekttitel']; $page->summary = $idata['freitexte']['dreizeiler']; $body = "<h2>".$idata['freitexte']['dreizeiler']."</h2>"; $page->body = $body; } if($action == 'CHANGE') { echo "CHANGE"; if(!$page->id) { $page = new Page(); $page->parent = $parent; $page->template = 'immo'; // template new pages should use $page->name = $idata['freitexte']['objekttitel']; echo "<h2>Change page data:</h2>".$idata['verwaltung_techn']['objektnr_extern']." Titel ".$idata['freitexte']['objekttitel']." <br><br>"; $numChanged++; } } if($action == 'DELETE') { echo "DELETE"; $numTrashed++; foreach($changes as $change) echo "\nUpdated '$change' on page: $page->name"; } $ni++; }//for Object echo "\n\n$numAdded page(s) were added"; echo "\n$numChanged page(s) were changed"; echo "\n$numTrashed page(s) were trashed\n"; }//funktion ?>
  13. Hello together, I had a deeper look into the forum but didn’t found anything, so I like to ask the following simple question. Is there a module or a simple technique to export all users from the backend into a file? Afterwards, it should be possible to import the users again. I have a ProcessWire installation on a dev server and I don’t like the idea to add all users again by hand on the live server Thanks so much for your ideas. -Thomas
  14. Hello all, on a new project I want to use https://github.com/stevenrskelton/flag-icon which implements svg icons for country flags via webcomponents import. In the <head> I import the webcomponents polyfill js and the flag icons html with <script src="<?php echo $config->urls->templates; ?>bower_components/webcomponentsjs/webcomponents.min.js"></script> <link rel="import" href="<?php echo $config->urls->templates; ?>bower_components/flag-icon/flag-icon.html"> But I get a 403 error: NetworkError: 403 Forbidden - http://dev/pwtest/site/templates/bower_components/flag-icon/flag-icon.html For testing I did: 1. a clean install of html5-boilerplate (not in PW), added flag-icons through bower and linked the resources as above. Here I don't get the 403 error. 2. a clean install of processwire with the blank profile, added flag-icon through bower and linked the resources as above. And here I get the error again. I did this on 2 different servers. Same result. I also checked permission of the import file and they are fine (644). Then I tried to make a demo install on lightning.pw but the service exits with "We're sorry, but something went wrong." To me this seems to be a ProcessWire related problem. Maybe somebody can confirm this or has an idea what is happening? Thank you.
  15. Hello, I exported a profile of a running live site (PW 2.5.2) with ProcessExportProfile module. Then cloned latest stable branch 2.5.3 to my local vagrant box dev server, copied the exported profile folder into PW root and installed. Everything went smoothly so far. All my templates, fields, modules and template files are there. I can access all but one specific page of my site. That page always throws a 404 error. The page sits under /profile and has template userprofile assigned. It is published and not hidden. The template file site/templates/userprofile.php is there. Only difference to the working pages is that this /profile page requires login before it can be accessed. After successful login the user is redirected to the /profile page with if($user->isLoggedin()) $session->redirect($pages->get('/profile')->url); But also if I enter the URL path manually, I get the 404 error. On the live site /profile only throws a 404 if you enter the URL path manually and are not logged in. So on my local install the /profile page acts as if the user was not logged in even if the user is logged in. I checked that the user really is logged in with if($user->isLoggedin()) echo "LOGGEDIN"; and has the correct roles with if($user->isLoggedin()) echo $user->roles; I haven't made any changes to my userprofile.php or any other files in the fresh install. And the code in there is working perfectly fine on the live site and on a copy of the live site that runs in the same dev environment as the site I'm having problems with. Now I'm really lost and don't know which steps to take for debugging this (debug is set to true in config.php - no messages or errors). Any help would be greatly appreciated. EDIT: I also installed the site on a different non local server to be able to rule out server environment issues. But same behaviour. Still get 404 for profile site
  16. Hi everyone, i've build the recommended setup for processwire to work with tags, which means i have a page tree "Tags" and this page tree hold several title-only pages, each represents a tag. for the gallery items i like to tag, i've build a template with an categories field of the type "page", this template will be used by every item to hold the tags. the field is "free tagging" field, so it would create the tag-pages autmaticly. now i need to import a csv file and this is where i have a problem: when i'm using "the import pages by csv" module, i am not able to select the category field as csv target. the tags column of my csv holds comma separated words as tag, so the schema looks like this: PICTURE NAME | TAGS ---------------------------------- Some title | birds, unicorns, kittens Another title | hearts, stars, pie so i need to be able to select a page reference field as target for the TAGS column of the csv, and for every comma separated word i need to create a page tag automaticly and add this tag to the gallery item i hope it's understandable what i like to do, otherwise feel free to let me explain it again
  17. Resources (Ryan's own): ImportPagesCSV FieldtypeMapMarker So I edit the accepted $fieldtypes on :76: /** * List of Fieldtypes that we support importing to * */ protected $fieldtypes = array( 'FieldtypePageTitle', 'FieldtypeText', 'FieldtypeTextarea', 'FieldtypeInteger', 'FieldtypeFloat', 'FieldtypeEmail', 'FieldtypeURL', 'FieldtypeCheckbox', 'FieldtypeFile', 'FieldtypePage', 'FieldtypeMapMarker', 'FieldtypePassword', 'FieldtypeRepeater' ); Page, MapMarker, Password and Repeater were added by me. Then alter importPageValue: /** * Assign a value to a page field * */ protected function importPageValue(Page $page, $name, $value) { $field = $this->fields->get($name); if($field->type instanceof FieldtypeFile) { $value = trim($value); // split delimeted data to an array $value = preg_split('/[\r\n\t|]+/', $value); if($field->maxFiles == 1) $value = array_shift($value); $data = $page->ImportPagesCSVData; $data[$name] = $value; $page->ImportPagesCSVData = $data; } elseif($field->type instanceof FieldtypePage) { $value = trim($value); if(wire("pages")->find("$name=$value")) $page->set($name, $value); } elseif($field->type instanceof FieldtypeMapMarker) { $value = trim($value); $page->set($name->address, $value); } elseif($field->type instanceof FieldtypeRepeater) { // } else { $page->set($name, $value); if($name == 'title') $page->name = $this->sanitizer->pageName($value, 2); // Sanitizer::translate elseif($name == 'fullname') { $page->name = $this->sanitizer->pageName($value, true); } } } Page import works with ID values, which was trivial to incorporate; passwords too. MapMarker and Repeater as you might guess do not. How can I save the map->address value? Hopefully it will update the corresponding map fields too but one thing at a time. As for the repeaters... LostKobrakai tipped me off to foreach($page->engines as $e) { foreach($e->fields as $field) { echo $field; echo $e->get($field); } } which works for their names and values, but in this function you're passed the field, and something like foreach($page->$field as $e) { foreach($e->fields as $field) { echo $field; echo $e->get($field); } } doesn't work... and what it would need to do inside anyway is check for a subfield whose name is equal to the column header (choose the repeater field itself e.g., engines in the select per repeater subfield value, e.g., engine_fueltype), then explode that cell value by pipes ('|'), and for each subvalue, populate the repeater#->subvalue... but before all that I need to be able to iterate through the subfields from the field in this function. Anyone have any ideas?
  18. This works for me to support page references in Ryan's ImportPagesCSV.module, in function importPageValue: elseif($field->type instanceof FieldtypePage) { $value = trim($value); if(wire("pages")->find("$name=$value")) $page->set($name, $value); } I need to also be able to import repeater fields though.. Anyone know how to do that?
  19. Disclaimer This is not a step by step tutorial, but the script posted serves as an example of how easy it is to bootstrap ProcessWire(PW), query an external API (in this case, Strava) and import stuff into PW pages using the PW API. To the import! So i wanted a quick, easy and automated way to import someones Strava activities into his/her own 'activity feed' on a certain PW website. Strava has an API which you can use to -amongst other things- get your own activity data. After setting up my Strava app i had access to the API. Next step was to import the JSON data i wanted into PW pages. This was as easy as creating a PW bootstrapped script (see code below) and using the PW API to import the data into Pages. For convenience in talking to the Strava API i used a library that is available on Github. To keep track of what was happening i decided it would be nice to log the import results to a log file. Luckily, PW had me covered by using the WireLog class (/wire/core/WireLog.php). Result With some googling on Strava and a (very) basic knowledge of PHP and the PW API i was able to get things working in no-time. With no other CMS i've worked with -and i've had dealings with quite a few- it would have been so easy to get the desired result. Some notes about the script: PW version used: 2.4.12, but should work in earlier versions as well. It does not create templates, fields and pages for you. If you would want to use it (maybe as a starting point), create templates, fields and pages for your own needs and adjust the script accordingly. Also remember to adjust script paths. In the posted example i don't do any sanitizing on the Strava data. You maybe should In production you would maybe call these kind of importers via a cronjob, and make it non-accessible from the outside. It served my purposes. There might be better ways of handling this stuff. All suggestions and/or questions are welcome. In this case the script was/is called importer_strava.php , located at mydomain/importer/importer_strava.php and requested manually. See notes above, number 3. <?php /** * Strava Importer * * This crude script will import your own Strava activities into newly created * PW pages under a given parent page. The import result will be logged in: * /site/assets/logs/importer_strava.txt, using the WireLog class. * * For this to work you first need to create an app via http://www.strava.com/developers * Strava API reference: http://strava.github.io/api/ * * The PHP library used for working with the Strava v3 API can be found at: * https://github.com/iamstuartwilson/strava * */ // Bootstrap Processwire include __DIR__ . '/../index.php'; // Include the PHP Library for working with the Strava v3 API include __DIR__ . '/StravaApi.php'; // Strava credentials (you can get these from the Strava app page you've created) $clientId = "Your clientId"; $clientSecret = "Your clientSecret"; $accessToken = "Your accessToken"; // Connect to Strava $api = new StravaApi( $clientId, $clientSecret ); // Set the parent where activities will be stored as child pages $activity_parent = wire('pages')->get("/activities/"); // Get new activities $results = $api->get( 'athlete/activities', $accessToken, array( 'after' => $activity_parent->strava_last_checked ) ); // Uncomment if you want to inspect the $results response onscreen // echo "<pre>"; // print_r($results); // echo "</pre>"; // Import new Strava activities to PW Pages if (empty($results)) { // Log that no activities have been imported $text = "No new activities have been imported"; $options = array('showUser' => false, 'showPage' => false); wire('log')->save('importer_strava', $text, $options); } else { $numImportedPages = 0; // Start counter for number of imported pages foreach ($results as $result) { $p = new Page(); // Create new page object $p->template = 'activity'; // Set template $p->parent = $activity_parent; // Set the parent // Assign $result data to the corresponding Page fields $p->name = $result->id; $p->title = $result->name; $p->act_distance = $result->distance; $p->act_moving_time = $result->moving_time; $p->act_elapsed_time = $result->elapsed_time; $p->act_total_elevation_gain = $result->total_elevation_gain; $p->act_type = $result->type; $p->act_start_date = substr($result->start_date_local, 0, 10); $p->act_average_speed = $result->average_speed; $p->act_start_lat = $result->start_latlng[0]; $p->act_start_long = $result->start_latlng[1]; $p->act_end_lat = $result->end_latlng[0]; $p->act_end_long = $result->end_latlng[1]; $map = $result->map; $p->act_map_polyline = $map->summary_polyline; $p->save(); // Save the Page object $numImportedPages++; // Increment counter } // Log the number of activities that have been imported $text = ($numImportedPages == 1) ? "$numImportedPages new activity imported" : "$numImportedPages new activities imported"; $options = array('showUser' => false, 'showPage' => false); wire('log')->save('importer_strava', $text, $options); // After the import, update Field 'strava_last_checked' to current Unix timestamp // This could also be placed outside of the 'else' to update on each script run $timestamp = $activity_parent; $timestamp->of(false); // Turn off output formatting before saving things $timestamp->strava_last_checked = time(); $timestamp->save('strava_last_checked'); }
  20. Hey guys, I need to import a Jekyll-based website, basically a collection of 3000+ static html pages, into ProcessWire, or in other words, import them into PW's database. Is there an easy, automated way to do this? Could you please point me in the right direction? Thanks.
  21. I did a big beginner mistake. I've deleted MAMP PRO to use XAMPP and in the process of the uninstalation of MAMP PRO I deleted all my databases... Fortunately my projects are already live so I have a working copy on the FTP of my client. I would like to have all this data as it is online so it works local on my computer. This is working with a processwire CMS, the url is http://www.fem-k.com/ if in need... Please let me know how to solve this problem so I can go on playing with processwire on my computer. Thank you very much!!!
  22. I m updating an old install of PW onto a new server with latest version of PW. Have changed alot of stuff but am still looking to retain some pages: e.g. all the news children pages. Been trying to use the import from CSV module for this by exporting using mySQL but im not really sure what im doing and I've managed to get an CSV with the page titles but not any content - Is there an easy way to do this? Or does any one have a module or mySQL script to select all the pages with child of id=x in a form they can be imported? Thanks!
  23. Hi, folks! We're working on our first big website project using ProcessWire. We're no longer in "fiddle and play with PW" mode. We're committed. My question: The site will have a directory of organization members, each needing a login/pw and a profile page. We're planning to use the existing Users/Roles model of ProcessWire, but we need to generate several thousand users from a pre-existing text file. Now, I won't have a problem writing a plain PHP script to parse the text file and interacting with the database. BUT i could use some help understanding how the user details and fields are laid out in PW's default install. I'm discovering, as many of you already know well, that even users are just pages. This, however, makes it a bit less than obvious how one might generate users programmatically on the fly. I would welcome any input or guidance you might have in helping me know *where* to insert *what* into the DB schema. I'd also welcome any anecdotal experiences you may have had doing something like this yourself. Caveats?
  24. Hello everyone, I'm new to Process Wire and I'm trying to set up a website for a magazine. My first task was to import a bunch of videos from another site into PW and it actually worked out quite good. Now I've got a bunch of pages with an external image reference in the image field. My idea was *not* to copy the whole lot of images, but to download and resize the ones that are requested. The first naiive attempt was this: <img src="<?=$article->video_image->size(350,88)->url; ?>"> With 'video_image' being a full path to an image on another remote server. Soo ... that didn't work. Do I need to copy the image to my server before resizing it? Or is there a trick to resize it and save only the "new" image on my server? Thanks for any help! Loving PW so far! thomas
  25. Below, I'll write how you can move your site from Drupal to ProcessWire. It's quite simple. In Drupal you will need: - Views Module, - Views Data Export Module, - Views UI Module (integrated with Views), - Chaos tools Module - required by Views. Install these modules and switch them on. In ProcessWire you need only: - CSV Page Import Process (Import Pages from CSV). Install this module. When you are ready, you have to create a new View (select: "Create a page") in Drupal with all fields which you want to export. Then, add "Data export" subpage and make sure, that format is CSV file. It's a good idea, to use Pager when you have lot of nodes (pages). You have to setup an url to download your CSV files. When you are ready - download your data. Next step: In ProcessWire, you have to prepare a template with your fields. When that's finished, you can import your data from CSV files using "CSV Page Import". That's all. If you have any questions, write them below. I can also write complete scenario for my website (if there will be anyone interested in that).
×
×
  • Create New...