-
Posts
11,176 -
Joined
-
Last visited
-
Days Won
371
Everything posted by adrian
-
Hey teppo, Thank you for the testing. I can replicate that same export error. I hadn't come across it before, but looking at your export JSON, I noticed that the page field you included has a parent_id of "home". I never anticipated that. The module will actually find all page field parent/child trees and add them to the export, so if for example you had a pagefield that linked to a categories/category tree, then it would grab that info, export it and import it on the new site, even though it is not directly under the parent you chose when exporting. I think the module actually handles this scenario quite well (despite the error which is an easy fix) - so if you do choose home, it won't try to export the entire home tree, but it will use the children of home on the new site, once you do the import, which is what happened for me when I imported your JSON. Does that make sense? EDIT: Actually that 1038 error is because your page field doesn't have a "Template of Selectable Pages" set. I have always been testing with page fields with both "Parent of ..." and "Template of..." defined in the Input tab. I'll have to make sure there aren't any further complications here. The message about importing template files should be hidden in this case, since it is clear you used the copy/paste approach. Obviously template files (*.php) can only be migrated with the "Save" output format. I'll take care of hiding that when it's not appropriate. Now for the confusing one, the errors with repeater fields. I haven't had any issues with those in quite some time now so I am curious on the exact setup. Would you mind testing one again and send me the errors you're getting and also the JSON, and if they're not being included in the export, perhaps you could sketch out their structure. One thing I am curious about on the repeater front - what option are you choosing for "Components to Export"? I have been doing almost all my recent testing with "Everything", so I am wondering if that might have something to do with it. I notice that none of your page fields have any content. Thanks again, really appreciate this! BTW, I have attached an export of a page tree that shows repeater and page fields working, along with images and RTE embedded images. Be sure to import "Everything" and choose "Replace". It should go into any parent, but I have been testing mostly with Home as the import's root is "About". It will replace your About (if you have one) and also install a US states page tree for the state selector field. There are a couple of repeaters at the bottom of the gallery child page. files.zip
-
Another pretty major update today. Here's the list of changes: Friendly error handling when modules/fieldtypes aren't installable on the destination site which also prevents any actions until you install the required modules. Support for migrating page data for all (hopefully) custom fieldtypes. I have tested with cropImage, MapMarker, Dimensions, and Phone. Let me know if you find one that doesn't work. Also, if you are playing around with MapMarker, be sure to make the changes shown in this PR: https://github.com/ryancramerdesign/FieldtypeMapMarker/pull/4/files - seems like it might only affect very recent devs of PW and hopefully Ryan will commit that change soon anyway. New Import Types: Append, Overwrite, Replace. Explained fully in the module, but the key new functionality is replace, which effectively allows you to edit the content in a section (Page Tree) of a site (say on your dev server), including changes to field settings, which fields are in the template (including repeater fields and their subfields), and the page data in the fields, and all these changes will be replicated on the destination site. This is very new, so let me know if you find something I have missed. Remember, there is one happy customer already .... But I am looking for more If you want a quick demo, don't forget you can try installing Ryan's blog profile as a child of your Home using the zip attached to this post.
-
delete($page, true) doesn't delete repeated fields on 2.3.0
adrian replied to joe_g's topic in API & Templates
Just wanted to add that I am experiencing this issue too. Seems like it is the same as reported here: http://processwire.com/talk/topic/2518-repeater-fields-via-api-it-has-no-parent-assigned/ Only difference I notice is that unlike teppo's report on his gist linked above, what I am finding left over is actually the "for-field" page, rather than the "for-page" page. As soon as I delete that page entry from the DB, everything works again as expected. Obviously this needs to be automated as part of the repeater cleanup. Thanks for looking into it Ryan. EDIT: Actually I am getting even more confused with this at the moment - a delete($parent_page, true) actually deletes a lot more repeater information than an admin delete of the same $parent_page, even after emptying the trash - which leaves behind the pages containing the actual repeater field content). I guess in reality, the for_field page should stay there unless you're actually wanting to delete the repeater field. All I want to do is delete all the pages and the pages that contain the repeater field content on those pages. I'll keep experimenting -
Hey Wanze, You're right for sure. I got thrown because I though it was just API related, but it actually seems like a bug between MapMarker and the latest version of PW. I looked back at a couple of sites that are working fine and MapMarker has always defined those as '' and not 0 and they have always been float fields. Not exactly sure what changed where, but this definitely fixes it. I'll submit a pull request for Ryan. Thank You!!
-
Hi everyone, Here's something I have been battling with. I am trying to create a new page via the API with a template that contains a MapMarker field. The template also contains two other custom field types (phone and dimensions, which are both fine). The problem comes down to the fact that the lat and lng subfields of the MapMarker fieldtype are floats. So, when you try to save the page, you get the following error: Warning: 1265 Data truncated for column 'lat' at row 1 which makes complete sense. Here is the generated SQL: INSERT INTO `field_map` (pages_id,data,lat,lng,status,zoom) VALUES('1494','','','','0','0') It's getting the zeros correct for status and zoom, which are integer fields. So, the way around it is to set those subfields to zero before saving. So, this works: $basic_page = $templates->get("basic-page"); $wp = new Page(); $wp->parent = $pages->get("/about/"); $wp->template = $basic_page; $wp->title = 'testme'; foreach($wp->fields as $pf){ if($pf->type=="FieldtypeMapMarker"){ $wp->$pf->lat = 0; $wp->$pf->lng = 0; } } $wp->save(); But I want to come up with a solution that will allow creating a page with any custom field that might use float sub fields. I even thought about setting the values of all fields and subfields to 0 before (to be overidden later), but can't even do that because it seems impossible to find out the subfield names until a page is created with that template - am I missing something obvious here? Then again, I feel like this is PW should handle properly in the core. I am not even sure I know why it is trying to set the values of fields on page save if they weren't specified anywhere. Any thoughts? EDIT: I am beginning to think this is actually an issue in general with MapMarker as I can't create new pages in the admin either - I'll investigate further.
-
How do we auto increment our title and name fields?
adrian replied to Zahari M.'s topic in API & Templates
Chiming in quite late here and to be honest haven't read things thoroughly, but my RedirectIds module might be of use for giving your clients an easy url over the phone: http://modules.processwire.com/modules/process-redirect-ids/ It means you can give them: mysite.com/videos/1356 where that number is the PW ID of the page. You can choose to have that link redirect to the normal full PW url for the video, or stay on the numbered url and just load the page content - simple config setting in the module. Not sure if this is your best approach, but thought I'd throw it in the mix. -
Pages Web Service query doesn't find result
adrian replied to verdeandrea's topic in General Support
@verdeandrea - you can't use commas with this module. Take a look at the instructions page again: http://processwire.com/talk/topic/1654-module-pages-web-service-servicepages/ Note that unlike regular ProcessWire selectors, multiple field=value sets are split with an ampersand "&" rather than a comma ",". -
Gotta love bitbucket and SourceTree
-
Just thought you guys might like to know that the priority setting just got another user Needed to solve the conflict between RedirectIds and 404Search modules. Thanks again Ryan for thinking of everything!
-
Store and output visited pages with $session or $_SESSION
adrian replied to nfil's topic in General Support
Actually I don't think that makes any difference in this hypothetical case. The $p->template check doesn't look to see if the template file exists, just the name of the template assigned to the page. So assume it hits a page with that template - it will then move to the "viewable" check. Assuming there is no template file, this will force the "continue". So this means that you still can't check just the assigned template and page status (not hidden or unpublished). I think that makes sense. But, yes, now we are really getting silly - sorry for starting it -
Store and output visited pages with $session or $_SESSION
adrian replied to nfil's topic in General Support
Since we're in a clarifying mood , the catch with $p->viewable is that there must be a template php file for the page, so this isn't a complete fix for using ->get and making sure it is not hidden/unpublished. Maybe this instead of viewable? !$p->status>=1024 I know it won't matter for this script because we are looping through pages that were at some point viewable (even if the status was changed in the meantime), so they must have had a template file at some point and likely still do. Sorry, I know I am getting too pedantic and off-topic now - time to sleep -
Thanks for the report - I was developing it on 5.5 and have now tested on 5.3, so hopefully we are covered now It makes sense that your include file was not added to the zip. Hopefully you noticed the message after the import to that effect - it mentions that you need to copy any .inc and other supporting files yourself. At the moment the migrator will only add template php files to the zip that are tied to the templates used in the pages that are exported. I have actually contemplated scanning through the template files looking for include, include_once, require, require_once and grabbing those files as well. I'll have a think about it and see if I think it makes sense to do that. The blog profile zip I attached a few posts back was manually modified to contain all the associated inc, js, and css files, but everything else was direct from the automatic export process.
-
Thanks Marty - glad to hear it is working for someone other than me - I was beginning to wonder Also, I just set up php 5.3 testing environment and everything seems to be working there now too, so hopefully I won't be wasting Pete and Antti's time when they try again! But please keep the bug reports and feature suggestions coming!
-
Oops - sorry about that Antti, and for the delayed response - was out enjoying some unseasonable sunshine! I just pushed a quick fix that should work for older versions of php. I need to set up a 5.3 testing environment. EDIT: Pete - the export process should now also provide friendly errors if a required option is not selected.
-
Hey Pete - sorry about that. Sounds like you are exporting. The issue is that you haven't selected anything in the "Parent Page" or "Components to Export" option. My bad for forgetting to provide a friendly error instead of failing, but if you choose something in that step, you should be fine! I'll fix it in the next version. Let me know how you go
-
I tend to agree with horst on this, but it can make life a lot easier if you learn some basic implementations of ternary operators, depending on how you want to structure your html and php. This can be easier: echo $page->Departure_AUI ? "<div>Aui: {$page->Departure_AUI}</div>" : ""; In my mind it really comes down to whether that div can be left empty, or if it must not be echo'd at all, which depends on your layout. It can also be easier sometimes to build up sections of content in a variable first. $out = ''; $out .= $page->Departure_AUI ? "<div>Aui:{$page->Departure_AUI}</div>" : ""; $out .= $page->Departure_MAG ? "<div>Mag: {$page->Departure_MAG}</div>" : ""; echo "<div id="block-parent">$out</div>";
-
Soma's right you guys, you just need to use json_decode to get it into an array. From there you can foreach through the array and do whatever you want with it. You could even extract the content to add to PW pages for storage if you want. Given kimonolabs limits on the free option, that might be a decent idea. Cache the results in PW. They have a limit of 100 per hour, so even once a minute would be ok.
-
Of course you could even add back in the user you want first: $users->add("name") And then add the role to that new user! PS some of these options only show in the cheatsheet if you click the "advanced" button.
-
$user = $users->get("test"); $user->addRole("superuser"); $user->of(false); $user->save(); Or if you want to actually do it through the database, you can go into PHPMyAdmin and find the page ID for the user you want to change (from the pages table) and then go to the field_roles table and change the "data" value for that pages_id to 38
-
kixe, Thanks for sharing those - I'll add them to the module, but I do have a question about the ITU E.123 format. It seems strange to me to have the extension appended directly to the number like that. I don't honestly know that much about phone number formats, but I took a quick read of this document: http://www.itu.int/rec/T-REC-E.123-200102-I/en and the key thing I got from it regarding extensions was: To show an extension number of a PABX without direct in-dialling, the nationally used word or abbreviation for "extension" should be written immediately after the telephone numbers and on the same line as the word "telephone", followed by the extension number itself. Example 2: Telephone international +22 607 123 4567 ext. 876 Any chance you could explain to me the difference between this and the format you have composed, which would output: +22 607 1234567876 Thanks
-
Store and output visited pages with $session or $_SESSION
adrian replied to nfil's topic in General Support
Hey teppo, Possibly I am missing something so wanted to clarify with you: I often chain get and find for finding all the children/grandchildren of a particular single parent. Compare this to "->get->children(selector)" which of course only returns first level children. I know that it doesn't work for what @nfil is after, but wanted to clarify how they can actually work together for those that are new to PW. Also, curious what you think of: $p = $pages->get($page_id); if ($p->template != "basic-page") continue; echo .... vs $ps = $pages->find("id=$page_id, template=basic-page"); foreach($ps as $p){ echo ......; } The first option (your suggestion) is likely more efficient, but just wanted to point out the second option to others and make the note that, in this case, you need a find rather than a get, because with a get, the id= selector overrides anything else after it. -
Hi again everyone - I have spent quite a lot of time on this the last few days and it is now much more robust and feature rich. In an effort to encourage some testing from you guys, I have attached an export of Ryan's blog profile that you can install into an existing PW site. Download the attached zip file Grab the latest version of Page Tree Migrator from Github (https://github.com/adrianbj/ProcessPageTreeMigrator) and install. Make sure your templates directory is writable by the server Run the module from the your Setup menu Choose "Import" and continue to Step 2 Choose the Parent Page - choose "Home" which will install the blog as a first level child of your homepage. Make sure "Everything, including all data pages" is selected for Components to Import. From Data Source, choose "Zip File Upload", browse to the blog.zip file. Click "Upload and Create Content" and wait a few seconds. That's it - you should have a fully functioning blog set up at: Home > Blog It comes complete with the same test entries, images, gallery, tags, categories etc that Ryan's original one does, although I did add in one extra photo, embedded into an RTE and resized - the photo comes from Joss' Foundation 5 profile. The one thing you'll notice is that the embedded Youtube link doesn't work, because the Video embedder module isn't installed. Page Tree Migrator will install core modules as needed, but obviously can't install other ones - yet You'll notice that the blog is installed with its CSS and script files in a subdirectory of the templates folder to avoid an overwriting of existing files. Please test and let me know what you think - Thanks! blog.zip
-
True, true - I use that sometimes too when dealing with small json snippets, but head to one of those others when things get larger. Lots of options I guess - in general it blows me away all of the cool dev tools we have available now - almost too many - could spend all your days investigating new things and not getting anything done
-
Hey teppo - the key thing for me is the ability to quickly collapse objects and arrays to make it easier to see what's what and avoid endless scrolling.
-
Hi Ralf, If I understand correctly, it should be a simple matter of: if($page->Departure_AUI){ echo "<div>Aui: {$page->Departure_AUI}</div>"; } There are shorter/cleaner ways of doing this, but I think this is the most understandable for someone new to php. Hope that helps!