Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/19/2014 in all areas

  1. pwFoo - you can't keep asking the same question about the database and expecting a reasonable answer. What data is in the database and what you're doing with it has as much impact on performance as the structure. Also, uniquely with Processwire, the "every field is a database table" approach could be slower in some areas, but since PW only grabs the data you need it could be quicker too (as in if your template file wants only the data from two fields but behind the scenes the API has to make two queries, those two queries could still be faster than pulling data from another CMS with a table containing dozens of fields. On the flip side there will certainly be occasions where a single table in another system will be faster than many tables in ProcessWire - depending on how well you put together your fields of course as it's up to you to make sure you do it efficiently. There is no easy answer and the only way to really test this properly is to build the exact same functionality as another system and see what the difference is. As for the underlying structure? I should imagine most of the frameworks are built for some sort of speed, but they're all abstracting away from PHP so if raw speed is what you're after and every millisecond counts then the best speed you'll see is probably to build something just in PHP bespoke to every situation. Of course that's a little crazy for a lot of projects as it will just take too long and requires you to know a lot more about PHP. I would just keep going with Processwire, take advantage of things like Procache and/or other caching methods where appropriate and it can be lightning fast for your end users. If you use Procache on more static pages you can essentially be skipping PHP and MySql completely and serving just HTML which is the quickest for your visitors, though certainly not appropriate for all pages.
    6 points
  2. Based on objetive data: Size and number of files: Best Small to Midsize Business PHP CMS: Processwire 2.4 Tree menu: Joomla 3.3 Tree menu:
    5 points
  3. At the end of the day, when it comes to public voting, I think such contests are really judging assessing popularity rather than 'best in its class' which is a rather more difficult and nuanced concept to assess. So if 10 people like/vote for Joomla and 2 like/vote for ProcessWire, does it mean that Joomla is 'better' than ProcessWire? Not necessarily. Does it mean that Joomla is more popular than ProcessWire? Probably.
    3 points
  4. you can use whatever classes you want.. See the FAQ. But the main advantage of PocketGrid is, that you can use own semantic html/classes. I don't use such col-b1-b2-whatever classes. Better use head, sidebar, navigation, subnavi etc. classes like here. Makes more sense for me.
    3 points
  5. The dns server may take several days until it spreads but It's strange because it works on my pc and my mobile without any error. The traceroute: TraceRoute from Network-Tools.com to 88.26.248.41 [41.red-88-26-248.staticip.rima-tde.net] Hop (ms) (ms) (ms) IP Address Host name 1 0 0 0 129.250.202.253 xe-0-4-0-12.r01.dllstx04.us.bb.gin.ntt.net 2 0 0 0 213.140.52.217 - 3 34 34 111 94.142.120.94 xe-4-1-2-0-grtwaseq1.red.telefonica-wholesale.net 4 161 114 188 94.142.119.154 xe7-0-6-0-grtparix3.red.telefonica-wholesale.net 5 110 40 40 94.142.127.133 xe5-1-0-0-grtnycpt3.red.telefonica-wholesale.net 6 121 134 115 213.140.37.250 xe4-1-8-0-grtloneq1.red.telefonica-wholesale.net 7 132 Timed out Timed out 176.52.251.214 xe2-1-3-0-grtmadad1.red.telefonica-wholesale.net 8 132 161 133 213.140.51.14 - 9 160 164 160 88.26.248.41 41.red-88-26-248.staticip.rima-tde.net Trace complete Retrieving DNS records for 41.red-88-26-248.staticip.rima-tde.net... DNS servers rsdbgi1-10.rima-tde.net rsdmno1-13.rima-tde.net Answer records 41.red-88-26-248.staticip.rima-tde.net A 88.26.248.41 172800s Authority records red-88-26-248.staticip.rima-tde.net NS rsdmno1-13.rima-tde.net 172800s red-88-26-248.staticip.rima-tde.net NS rsdbgi1-10.rima-tde.net 172800s Good luck and sorry I can't provide any further help
    3 points
  6. Maybe PW could be compared against Drupal and WP. Build a simple blog with each and look how fast each view (list, search, post with comments) is generated on all those systems. Framework comparisons are difficult beast, since it's mainly testing for the architecture (how much stuff they load automatically). PS: Not that I would be very interested in that kind of comparison - but it would give us great headlines ("ProcessWire is even faster than WordPress")
    3 points
  7. Greetings, If you don't need to complete all the categories to compete for the Chromebook, then the instructions are false. They clearly state that you need to complete everything to win. Clearly, this will skew results with "blind voting," as Diogo said. I'm not doubting how they ended up with 3. It's just not very useful to have a "best free CMS" category with 3 CMSs! What do the results tell us about anything? Another question: why is Joomla listed as a "free" CMS and also as an "open source" CMS? Shouldn't all 3 be listed twice? Also, why is there a category for "Best Small to Midsize Business PHP CMS"? How in the world did they make that determination? And why is there no "Best Large Business PHP CMS"? Thanks, Matthew
    2 points
  8. Yeah, but remember this will only create one row, if that's what you want...Of course, that will be OK if you want to utilise the "automatic rows" feature
    2 points
  9. You won't regret it ....The Master himself uses it in his blog Same here. No more 'three columns small' stuff for me (no offence to other Grids out there )
    2 points
  10. Absolutely! You can change those. PocketGrid has only two classes; 'block-group' [which creates a row] and 'block' [which creates a column] . Have a look at the css file - it's only 43 lines long unminified ... The b1, etc you see on the demo site are custom classes to make it clearer what's going on. Edit: As you can see, it is very versatile and can be as semantic as you want (if you care about such things ). Btw, block and block-group can be applied to any element, not just <div>
    2 points
  11. @adrian Didn't try directory opus, sorry. But I tried Cyberduck and TC is much superior in terms of FTP handling: Encrypted passwords, up to 12 connections in tabs, working off the server, directory bookmarks, batch operations, sync local/remote, diff local/remote, double pane window and so on ... (not to mention the features for local file management) Give it a try. And, if you look for a free solution, TC isn't free but the tryout period is unlimited ...
    2 points
  12. Or simple one parent "plates" with all available pages (could be created ready to use) and just with a field to check "in use" ? So no page generation needed just a update on one field? And sorting/displaying would be easy... Just some mindgames - didn't setup something yet.
    2 points
  13. You can work the other way around without a regex. So basicly you have 2 parent folders: Available and In Use. All possibilities go in Available, then when chosen, change the parent of the code page. So move the page from Available and In Use. This way you can check if a code is already gone. And see which one is active.
    2 points
  14. i just came over a blog post of a friend of mine and thought that could be interesting for some of you: SSL Certificate Expiry Warning Script
    2 points
  15. Hi yabapolido and welcome to the forums. This should do it, although you'll need to tweak the preg_match because I wasn't sure whether you wanted exactly 2 numbers and two letters, or just a minimum of each. Currently it is set to just two of each. Also, this currently only works if you are talking about a page added to the root of your site, but this can be easily tweaked. The other thing you'll want to adjust is the template being assigned to the new page - currently I set it to basic-page. <?php /** * ProcessWire Auto Create Page * by Adrian Jones * * Automatically creates a page if it doesn't exist * * ProcessWire 2.x * Copyright (C) 2011 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class AutoCreatePage extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Auto Create Page', 'summary' => 'Automatically creates a page if it does not exist', 'version' => 1, 'autoload' => true, 'singular' => true ); } /** * Populate the default config data * */ public function __construct() { // determine the URL that wasn't found $url = $_SERVER['REQUEST_URI']; // if installed in a subdirectory, make $url relative to the directory ProcessWire is installed in if($this->config->urls->root != '/') { $url = substr($url, strlen($this->config->urls->root)-1); } $last_slash = strrpos('/', $url); $this->last = str_replace("/","",substr($url, $last_slash)); } public function init() { if (preg_match( '/^(?=.*[a-zA-Z].*[a-zA-Z])(?=.*\d.*\d).{4}$/', $this->last)) { $this->addHookAfter('ProcessPageView::pageNotFound', $this, 'createPage'); } } public function createPage($event) { if(!$this->pages->get("parent=1,name={$this->last}")->id){ $np = new Page(); $np->parent = $this->pages->get("/"); $np->template = 'basic-page'; $np->title = $this->last; $np->of(false); $np->save(); $this->session->redirect($np->url); } } }
    2 points
  16. 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.
    2 points
  17. Hi all, Here's a preview of a Gallery photo album module I am working on (very slowly! ). Development is currently in closed beta testing. The module will consist of a backend (as seen on video below) and a frontend that is framework and lightbox agnostic, aka plugin whatever and it will still work. Features Unlimited number of albums and sub-albums (easy to query using PW API) Multiple methods to add albums and photos (including uploading images and zip files, scanning a folder for FTP'ed photos, etc) Automatic album and photo creation based on names of folders and files respectively Bulk editing (moving, deleting, tagging, etc) Manager themes in several colours A bit of eye candy Etc... This is in beta so it is still rough around the edges. Feature suggestions? Yes please Apologies the video is way too long and you might get bored toward the end...
    1 point
  18. This tutorial will outline how to create a membership system that requires account activation via email. If you have a decent understanding of ProcessWire it isn't difficult at all! Create additional fields By default ProcessWire has a name, email, and password field for the user template. To allow for account activation we will have to add a couple more fields. Create the following fields and add them to the systems default user template. You can make ProcessWire show the system templates by going to setup -> templates -> toggle the filter tab -> show system templates -> yes. user_real_name user_activation Okay great, now that you have added the two additional fields to the user template we can start to code the registration form. I am not going to spend a lot of time on this part, because there is a tutorial that describes creating forms via the API. Create the registration form Once you have followed the tutorial on creating forms, you will have to add a couple of sections to your new form! <?php include("./functions.php"); require("/phpmailer/class.phpmailer.php"); $out = ""; $errors = ""; //create form //full name field //email field //username field //password field //submit button //form submitted if($input->post->submit) { $form->processInput($input->post); //instantiate variables taking in the form data $full_name = $form->get("full-name")->value; .... /* * Create the activation code * You can add a random string onto the * the username variable to keep people * from cracking the hash * ex $activation = md5($username."processwire"); */ $activation = md5($username); $activation_code = $config->httpHost."/activation/?user=".$username."&hash=".$activation; //check for errors if($form->getErrors() || username_validation($username) == 0) { $out .= $form->render(); //process errors /* * this checks to makesure that no one has the username * I have a functions file that I import to the pages I * need it on */ if(strlen($username) != 0){ if(username_validation($username) == 0) { $username->error = " "; $errors .= "Sorry that username is already taken!"; } } } //the registration was successful else { $out = "Thank you for registering!<br><br>"; $out .= "An email has just been sent to " . $email . " with the url to activate your account"; /* * In this example I am using phpmailer to send the email * I prefer this, but you can also use the mail() function */ $mail = new PHPMailer(); $mail->IsHTML(true); $mail->From = "email@domain.com"; $mail->FromName = "Register @ Your Site"; $mail->AddAddress($email); $mail->AddReplyTo("email@domain.com","Register @ Your Site"); $mail->Subject = "Registration"; $mail->Body = " Hi " . $full_name. ", <br>" . "Thanks for registering at Your Site. To activate your email address click the link below! <br><br>" . "Activation Link: <a href='http://".$activation_code."'>".$activation_code."</a>"; $mail->send(); //create the new user $new_user = new User(); $new_user->of(false); $new_user->name = $username; $new_user->email = $email; $new_user->pass = $password; $new_user->addRole("guest"); $new_user->user_full_name = $full_name; $new_user->user_activation = $activation; $new_user->save(); $new_user->of(true); } } //form not submitted else { $out .= $form->render(); } ?> <h2>REGISTER</h2> <div class="errors"><?php echo $errors; ?></div> <?php echo $out; ?> Okay so that outlines the entire form. Let me get into the important parts. Checking for a unique username /* * check if username exists * return 1 username is valid * return 0 username is taken */ function username_validation($username) { $valid = 1; $check = wire("users")->get($username); if ($check->id) { $valid = 0; } return $valid; } We don't want to try and add a username if the username is already taken, so we need to make sure to validate it. If this returns 0 you should output that the username is already taken, and the user needs to choose a different one. Generating an activation code /* * Create the activation code */ $activation = md5($username); $activation_code = $config->httpHost."/activation/?user=".$username."&hash=".$activation; This generates an activation code. It does so by encrypting the username variable and then combines the username and activation code into a url for a user to visit. Now we have to process the activation code. As the teppo recommended, it is a good idea to add an extra string onto the $username when encrypting it with md5. If you don't do this, people may crack it and allow for mass signups. $activation = md5($username."Cech4tHe"); Activate the user <?php include("./head.inc"); include("./functions.php"); /* * this will pull the username and * activation code from the url * it is extremely important to * clean the string */ $activate_username = $sanitizer->text($_GET['user']); $activate_hash = $sanitizer->text($_GET['hash']); if(wire("users")->get($activate_username)->id) { if(strcmp(wire("users")->get($activate_username)->user_activation, $activate_hash) == 0 || wire("users")->get($activate_username)->user_activation == 0) { echo "Your account has been activated!<br><br>"; $activate_user = wire("users")->get($activate_username); $activate_user->of(false); $activate_user->user_activation = "0"; $activate_user->save(); } else { echo "There was an error activating your account! Please contact us!<br><br>"; } } else { echo "Sorry, but that we couldn't find your account in our database!<br><br>"; } include("./foot.inc"); This pulls the username and activation hash from the url. It then goes into the database and looks for the user. Once it finds the user, it get's the user_activation hash and compares it to the one in the URL. If it matches, it activates the user by setting user_activation to zero. Clean the url You can user the built in $sanitizer->text() method to clean the url. This will keep people from inserting special characters that can break the page. Keeping unactivated users out You aren't done yet! Now you will have to choose which areas you want to restrict to activated users only. An activated user's user_activation field will now equal zero. So if you want to restrict a section check to make sure it is zero...... if($user->user_activation != 0) { echo "Sorry, but you need to activate your account!"; } else { // activated users }
    1 point
  19. Just received the nominees for the Critic's Choice CMS Awards. Processwire is in the 'Best Free PHP CMS' category. I was surprised that it is not in the 'Best Open Source Category'. You can vote now. Here are the nominees in each category: Best Cloud CMS for SMB Surreal CMS Acquia Cloud Light CMS Best Cloud CMS for Enterprise Acquia Cloud CrownPeak Clickability Best CMS for Corporate Intranets Entando Liferay ocPortal Best eCommerce Solution for SMB ASPx Commerce Prestashop Shopify Best eCommerce Solution for Enterprise BigCommerce Prestashop Shopify Best Free Forum Solution NodeBB MyBB Vanilla Forums Best Commercial Forum Solution IP.Board Ninja Post Vanilla Forums Best Enterprise PHP CMS eZ Publish Plone Typo 3 Best Enterprise Java CMS Adobe AEM Hippo Jahia Best Enterprise .NET CMS Kentico Sitecore Sitefinity Best Enterprise CMS (Other Langs) Mura CMS Paperthin Commonspot Plone Best Free PHP CMS Concrete5 Joomla ProcessWire Best Free Java CMS dotCMS Liferay Magnolia Best Free .NET CMS DNN Platform Sageframe Umbraco Best Free CMS (Other Langs) Mura CMS Plone Best Open Source PHP CMS eZ Publish Joomla! MODx Best Open Source Java CMS dotCMS Liferay Magnolia Best Open Source .NET CMS DNN Evoq Content Sageframe Umbraco Best Open Source CMS (Other Langs) Mura CMS Plone Best Small to Midsize Business PHP CMS CMS Made Simple Craft CMS ImpressPages Best Small to Midsize Business Java CMS Percussion CM1 Liferay Best Small to Midsize Business .NET CMS DNN Evoq Content Envisage CMS Orchard Best Small to Midsize Business CMS (Other Langs) Django CMS Movable Type Surreal CMS Best Website Builder Squarespace Weebly Wix ​EDIT: Irrelevant links removed.
    1 point
  20. Hi, Something weird going on, need help with a domain check. My Boss just had a visitor from a distributor who can open the following site on her wireless samsung tablet. She was not connected with our wifi but with her own mobile provider. http://distribucionesjuanperdomo.es But we ourselves can not open this on our computers ?? I already changed to another dns server in my network connection but without success. Also if I do a ping there is no reply. What can be the cause ?
    1 point
  21. I think the screencast I watched must be from old functionality. Is there nothing this module doesn't do?! Can it make the tea!?
    1 point
  22. Matthew - The categories were whittled down from larger numbers of systems, as voted for by people visiting and clicking, so this still applies: https://processwire.com/talk/topic/7328-critics-choice-cms-awards/?p=70570
    1 point
  23. @pwired, I was talkin about the cookies in the slider, yum yum... But yeah I could see the page & it loads quickly !
    1 point
  24. And remember that Critics Choice website is Powered by Processwire.
    1 point
  25. He Blad, nice comparison. I just voted.....Processwire afcourse and nothing else
    1 point
  26. I like Pocketgrid as well. Simple and flexible. To position contentblocks exactly where I want them I use by example the following <div class="block-group"> <div class="beforemyblock block"></div> <div class="myblock block"><div class="mycontentblock">Content</div> <div class="aftermyblock block"></div> </div> In my css with mediaqueries I can, depending on screensize, move my contentblocks around by changing the width property for the "beforemyblock" classes in every block-group, keeping the total width in every block-group on 100%. I let my "before" and "after "classnames correspond with the sort of content, by example logo, menu, top10, etc.
    1 point
  27. I don´t know how you can do a flushdns in a tablet but it would be a good idea. I use as my dns servers 8.8.8.8 and 8.8.4.4 (google). I have a fast response: http://distribucionesjuanperdomo.es/ Delay Check HTTP Success - response in 102 ms Good luck
    1 point
  28. No. I can only answer to that one
    1 point
  29. You don't need to unless you want to apply to win a Chromebook, and unfortunately they might convince a lot of people to do blind voting. The eager to get more and more people to vote might lead to less accurate result in the end. I also didn't like the "keyboard friendly" form. And I think and I think that, joining to the Chromebook problem that I referred, the result will be: 1. A. CMS with great chances B. CMS with no chance C. CMS with little chances 2. A. CMS with great chances B. CMS with no chance C. CMS with little chances 3. A. CMS with great chances B. CMS with no chance C. CMS with little chances and so on... I don't remember how PW was positioned, so I don't know what are the chances we have
    1 point
  30. Matthew , Isn't it the case that the 3 per category are those that won nominations in their categories? i.e. they've won in the 'primaries' so have already competed against other systems
    1 point
  31. Greetings, I really like the idea of this annual competition. But I am not pleased with the way CMS Critic is handling it this year. 1. Offering a free Chromebook, then requiring people to vote in all categories, will ruin the results. Obviously, many people will vote on systems they don't know just to complete the survey. 2. The voting system often hangs up or freezes on mobile (iPad Air in my case). 3. As Apeisa mentioned above, some categories are vague (e.g., "free" vs "open source"). 4. The number of eligible systems is rather unimpressive. I love ProcessWire, but winning doesn't mean much if it is only competing against 2 other systems. I think the idea of the CMS Critic Awards is terrific, and I would love to see CMS Critic gain an even bigger audience. But they are going in the wrong direction here. Thanks, Matthew
    1 point
  32. See the advanced mode - there are all kinds of "system" settings for fields and templates. (sorry in hurry now)
    1 point
  33. I have hard time understanding difference between free and open source here. I know the difference, but all the "best free php cms" are open source too.
    1 point
  34. Try Total Commander. Looks awful but is the best file managing and FTP solution on windows. Nothing comes close.
    1 point
  35. Thanks for all your answers and hints. I prefer PW because of simple module development (it's easy to understand), great api and additional proCache and other options should do it... Some modules planned to build with PW. I'll see how it compares to others
    1 point
  36. WOW. Adrian you blew my mind. I've been reading for the past hour about PW and understood that is powerfull, but this is just awesome. If I can just figure it out how, I'll try it right away, this is a module right? It's working like a charm. Thanks! Would it be very annoying to ask another thing? Given that new auto-created page, how should I proceed to let users add new comments and images to that page? I've been looking at Form modules (because Comments module doesn't allow pictures), but don't know if that's the best choice?
    1 point
  37. I come from drupal and expression engine communities. I hope Processwire have the impact it deserves. I think it´s great and i can´t find a cmf like it (Open Source and fast learning curve). My opinion about cms with custom fields https://processwire.com/talk/topic/6798-yet-another-cms-switch/#entry67224 .
    1 point
  38. This is incredibly rough, but throw this at the end of your main.php/main.inc/foot.inc or whatever you are using: if($user->isSuperuser()){ $fieldinfo = '<hr /><p>Field details for ' . $page->template . ' template</p>'; $fieldinfo .= '<table><th>Name</th><th>Label</th><th>Type</th>'; foreach($page->fields as $field){ $fieldinfo .= '<tr><td><a href="'.$config->urls->admin.'setup/field/edit?id='.$field->id.'" target="_blank">'.$field->name.'</a></td><td>'.$field->label.'</td><td>'.$field->type.'</td></tr>'; } $fieldinfo .= '</table>'; echo $fieldinfo; } This will give you a table of fields for the current template including name, label, and type. The name cell links to the edit page for the field if you need more info. I am actually thinking it make be nice to add the popup of field settings the way soma did it in https://github.com/somatonic/HelperFieldLinks which is a module you should definitely install by the way
    1 point
  39. One for my wishlist An Inputfield & Fieldtype that lists from every found page the first Image thumbnail. So the input fieldtype should look like an album & browsing the tree should show the first found image or the image field thats configured. This field can be used to build photo albums, select photo's with meta data etc.
    1 point
  40. @SiNNuT: it should probably be noted that Phalcon is not written in PHP but C and thus it's even more difficult to fairly compare it to any framework written in PHP. It's a different type of animal I'd really like to stress that Laravel and other web application frameworks are very different from ProcessWire by nature. ProcessWire does a ton of things they don't (the content management part) and they probably do a bunch of things ProcessWire doesn't. Apples to oranges and so on.
    1 point
  41. Just want to share this with you guys, To commemorate the launching of our new website https://processwire.com/talk/topic/7170-ed-design/ we decided to share a title font that we used on one of our projects under the SIL Open Font License (OFL). The font is available for download as otf and as webfont package on our site here and open for collaboration on Github and Open Font Library (you can also embed it from there). If you like it, use it and enjoy
    1 point
  42. 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.
    1 point
  43. With that method you posted, and the first argument is the product page. echo $modules->get("ShoppingCart")->renderAddToCart($product);
    1 point
  44. I reuse fields as much as possible and try to avoid having too many fields. I have a "firstname" field that could be used on different templates. I don't prefix fields. PW is designed to reuse fields. I wonder how many fields you have and why you need to prefix them. I think people tend to create new fields for every template and context, which could lead to 100s of fields. Remember there's template context for fields in PW, you can customize labels and some setting from within the template if you click on a field name.
    1 point
  45. 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'); }
    1 point
  46. 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.
    1 point
  47. I wonder if the Add Field dialog on the templates page could be enhanced to use the field's tags as optgroup dividers in the select field. I can see that might be useful if you have a lot of fields.
    1 point
  48. While there are certainly more and better things one could do with access to text files (i.e. importing to DB), it certainly wouldn't be hard to pull in a text file directly from your template and display it on every page view. At the simplest level: echo file_get_contents("/path/to/file.txt");
    1 point
  49. XML feeds would be a valid solution, without knowing the details of what the content is. But Ryan is doing it aswell in some of his sites to share content between installations. Other solutions would be to import them from text or html files. I'm doing a reports website of a company where we get static html files and I have a script to import them in 1 click. It's a matter of reading and parsing the files, create a new page, put them in the textfield and save. $content = file_get_contents($url_to_file); $content = str_get_html($content); // using http://simplehtmldom.sourceforge.net/manual.htm $p = new Page("basic-page"); $p->parent = "/news/"; $p->title = $content->find("h1",0)->plaintext; $p->body = $content->find("#main",0)->innertext; $p->save();
    1 point
  50. Nik is right about this. You probably want to change your selector to something like this: $field = $user->language->isDefault() ? "body" : "body.data" . $user->language; $matches = $pages->find("$field*=$q"); That will force it to not consider the default language in the matches at all. However, most of the time you should just do this, which already takes languages into account: $matches = $pages->find("body*=$q"); So whether the user searches for "Beer" or "Cerveza" they will still get to the right page. If you exclude the default language, then that fallback never happens.
    1 point
×
×
  • Create New...