Jump to content

SiNNuT

PW-Moderators
  • Posts

    1,011
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by SiNNuT

  1. I can see that that you don't use snailmail a lot , because it definitely is not customary to use a 'Gemeente' name to address a letter.
  2. Interesting. In my own little country, The Netherlands, there are already around 6500 settlements (cities, towns, villages etc.). If you were to take that to continental or even bigger scale you would be talking about possibly hundreds of thousands items. These could indeed be all pages in PW, no problem. It's important to find the most efficient and useful way of structuring the PW tree, specific to the project.
  3. If i understand correctly, you are trying to create a sequence of, 12 + (12*15) 180 + (180*20) 3600 = 3792 pages?? Should, for some reason, you need to repeat this often i would try to create your own specialized import script. There should probably be some mechanism in there to prevent memory issues and time-outs as well.
  4. @adrian getUnformatted is definitely the PW way , but i'm not entirely sure that it saves a conversion step. Seeing as a datetime field is a Y-m-d H:i:s field on the database side of things a strtotime is always necessary. I've always thought that getUnformatted on a datetime field gives you the wakeupValue: // in FieldtypeDatetime.module /** * Convert value from Y-m-d H:i:s string to timestamp * */ public function ___wakeupValue(Page $page, Field $field, $value) { if(empty($value)) return ''; $value = strtotime($value); if($value === false) $value = ''; return $value; } I'm guessing this wakeupValue is always present, if thats the case it does indeed seem to save a conversion
  5. It could be that you have some output formatting applied in the field settings. In that case you should first get the Unix timestamp, like this: $month = date("F", $page->getUnformatted("date")); // where date is your fieldname
  6. It's already very hard to do a good comparison between general purpose frameworks, like the ones you mentioned. What you see done a lot, is a "Hello World!" benchmark, where they measure stuff like requests per second and memory consumption, on the most basic configurations of the frameworks in the benchmark. Unfortunately, this doesn't say much about actual real-life applications and there are a lot more things to consider. Some of the newer frameworks like http://phalconphp.com/en/ show really great numbers (in fact, you could say that they blow the competition out of the water in a certain way). But it's not like everyone suddenly dropped the framework they use in favor of Phalcon. I would say that PW is a much more specialized framework, geared towards content management. PW also gives a nice admin interface application, built on top of the framework. If you would rebuild all of the functionality and power the PW API and admin gives you using some of the frameworks you mentioned then maybe you could make some kinds of representative comparisons. In general i think PW performs well. But if you start throwing around heavy and/or inefficient queries (using the api) things will slow down. So competent programmers/builders are important, but i think this is the case for whatever framework or CMS you use.
  7. There's not an an awful lot to it (i think), but just a handy feature allowing to change certain settings for a field on a per template basis. It is indeed something that helps to reduce the amount a fields you create. A google search 'site:processwire.com/talk field context' will reveal some additional info.
  8. I get the feeling that the field contexts are something that is easily missed but very useful to know. Once you make use of contexts you can also see and edit the different ones from the field page.
  9. What you are thinking is something that certainly is not wrong and should work fine, and this has also been discussed in the past on this forum. The native forum search isn't the best but if you do a Google search like this 'site:processwire.com/talk single page website' you should get some interesting results. Stuff like this could be good reads for you to get some inspiration: https://processwire.com/talk/topic/1283-a-single-page-site-using-pw/ https://processwire.com/talk/topic/5919-hide-children-of-home-from-indexing-single-page-site/ https://processwire.com/talk/topic/2845-single-page-websites/ https://processwire.com/talk/topic/3036-one-page-website-template-setup/
  10. Don't be too harsh Windows Phone 8.1 seems like a pretty decent platform. I wouldn't mind owning a Lumia 930, but for now i'll stick with Android
  11. Thanks teppo, Good tip on the include part. Updated the posted script with __DIR__ because i really don't want to encourage taking anything < PHP 5.3 into consideration Hell, even PHP 5.3 is already nearing end of life ( http://php.net/archive/2014.php#id2014-08-14-1 ) About Strava; There are a lot of activity trackers out there that do the basics right. In the past i've also briefly used Endomondo and Runkeeper and they are fine too. What i like about Strava: The non-intrusive social features; making friends, following, creating clubs etcetera. The famous Strava segments, where one can become "King of the Mountain". This should not be taken too seriously but me and my cycling buddies have been in serious competition with each other on our 'home' segments and having a lot of fun while doing so. There are quite a lot of Pro's on Strava, which can be nice to follow, if you're into that. It has a nice platform for developers. It just feels like it has some momentum going. What could be considered a downside is that they don't have an official Windows Phone app. So if you wanted to use your Windows Phone to do the tracking you are left out in the cold. Of course, there are ways around this with very decent third party apps, that allow to sync activities to Strava, but then you do miss some of the features. But you could always use the Strava website to fill in those gaps.
  12. 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'); }
  13. Glad you got things sorted, apart from number 2. About number 2: I don't think this is possible using the out-of-the-box admin tools. I have not needed something like this, so i can't do anything for you apart from digging up a quite old thread about just such a question: https://processwire.com/talk/topic/1176-hiding-uneditable-pages-from-users/ It's a good read, with comments from Ryan himself. If since then, new (admin) options have been introduced i'm sure someone else will guide you to a better solution.
  14. 2.5 release will be a blast, and probably not in the too distant future
  15. I'm not sure what PW version you are referencing but in the current dev version the search box makes use of the new Lister. By default the search box will only search 'title' fields, which in my opinion is a sane default. If you want 'advanced' search you can go directly to 'Find' via the top navigation. From there you can comprise a very detailed 'find' by applying filters. So 1-step is available. As an extra shortcut i wouldn't be against an 'advanced find' icon/link to the right of the default searchbox but i'm not sure this is needed. See screens for details:
  16. That could indeed be a nice addition and seems to be, at least in part, what TS is after. The other stuff, some form of namespacing fields, i don't quite understand.
  17. I'm also quite new to the RESTful approach but i think the whole point is that a given endpoint responds to the various http request methods, so: www.your-pw-site.com/products/ would respond to http GET by listing the products, and http POST would add a new product.
  18. Stop the presses! I must not have been thinking clearly yesterday. I pulled in the latest changes, updated the PW instance in question and went on to test it on the wrong domain, which still had the old code I guess this is a good lesson to not have too many quite similarly named test domains. So long story short: Latest dev has fixed the issue for me. As for the other one, this also seems to have to do with me exporting from an old install and importing that in a new (current dev) install. So everything is looking fine running the dev where the latest commit is '6ee2d96737fa64681fd3aefc65529ffca194f987'. I'm gonna go away now and hide in shame
  19. Argos' little bit off-topic post really took some of the focus away in this thread, but anyway: If we take a look at two open-source PHP systems that are generally considered 'enterprise-ready' -TYPO3 and Drupal-, i see some things they have in common A very big portfolio of use in professional and large organizations, be it commercial or non-commercial, for all kinds of projects/sites A vast amount of companies that offer (Drupal/TYPO3) services and products. If you need help an agency is never far away. Globally known. 'Official' certification programs If you look at it along those lines, which a lot of people do, PW does not (yet maybe) fit the bill. But this whole 'enterprise' thing is tricky and dependent on the way you you define it. I would much rather emphasize on PW as a rock-solid and technically sound CMS/CMF, ideal for delivering professional, high-quality web projects. I agree that it might be a good idea to re-arrange or add to the site, so that it showcases this more clearly. Maybe a section of featured projects that showcase PW very well and/or do something very interesting with it. Maybe companies that use PW could be mentioned somehow, like avoine.fi. Anyways, these are just some thoughts. From a personal viewpoint (not using it professionally) i'm perfectly happy with where PW and the site stand at the moment.
  20. Not sure but might this work?: EDIT (still looking, first thought was wrong :0 )
  21. I just pulled in the latest commits and tested again. The issue still is present: In my case the JSON always has "required": 1 no matter if the exported fields are not required. On top of that another issue might be introduced: With a datetime field present in imported fields it now takes multiple commits and no matter how may times i press 'Commit Changes' the same screen reappears (although the setting in question seems to be saved just fine). See screenshot. The Previously this wasn't the case.
  22. You should read up about what localhost means. MAMP (which i haven't used, because i'm on Windows) is just a convenience package for having PHP, MySQL and Apache run on your computer, in essence a webserver with PHP and MySQL available. This (Apache) webserver serves pages on http://localhost/ , most of the time on port 80, so that would be http://localhost:80/ . Localhost is basically a shortcut to the IP-adress that represents your own system, IP 127.0.0.1 So MAMP also makes http://localhost available. This will have a set document root. http://localhost[=docroot]/myproject[=subfolder]/ Sometimes this will cause problems with the rewritebase settings in the .htaccess file that comes with PW. So you need to change settings, and probably rechange when you put the stuff on a live domain, such as myproject.com. This is maybe not a real big deal but there can be other disadvantages of developing locally with sub-folders of localhost. One that comes to mind is links that you insert via a Rich Text Editor. Like the others have said, vhosts allow you to basically map a directory anywhere on your file-system to be the documentroot for a domain of your choosing. For example: http://myproject.development could be address that you could access in your browser while your project files could be anywhere. Of course, MAMP, also allows for these kinds of setups. MAMP PRO seems to have built-in options. For regular MAMP there are enough guides on Google, for example: http://sawmac.com/mamp/virtual/ http://foundationphp.com/tutorials/vhosts_mamp.php
  23. A bit OT. I always set up virtual hosts for every project or test install i do. This way the default .htaccess has never failed me and it saves headaches when deploying to live domains. Installing into (sub)folders of localhost is not optimal to my taste.
  24. Ryan, I've been playing around with the field export/import tool (dev branch, d.d. 11-8-2014 14:16:16 (UTC+0000). I've only used it for exporting and importing new fields from one install to another, on a set of about 25 fields. Types used: float, text, textarea, integer and datetime. It is already a huge time-saver! Recreating more than a couple fields fields manually is really time consuming and error-prone, and i also don't want to be doing this on the database level. So as far as i'm concerned a major improvement in (development) workflow. One thing i noticed: The created JSON always seems to be putting "required": 1 , even when the exported field is not required.
×
×
  • Create New...