Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/15/2013 in all areas

  1. Hi there, first the compliments: I found Processwire about a week ago (where have you been all this time PW?), and I found it mind blowing, basically because how easy is to create a site. I had my homepage made with Symphony CMS, and it was fun to develop with, but XSLT still gives me headaches (even I still have love for Symphony and its simple approach, and the power that XSLT gives). I've worked before with Drupal, Wordpress and some little experience with Joomla!, and always found myself programming hacks to make the CMS do exactly what I wanted. The I found Processwire and it took me less than three days to learn and migrate my homepage. And I love it. I'll buy the cache module even if I don't really need it, just for the support, Ryan's work here is simply amazing. So now I'm preparing myself to start to work with PW for future clients. So here is my question, maybe a dumb one, but I need advice on how to approach this: A client needs a frontend for managing some data stored in his database (separated from PW). They manage their own users and even an authentication system by their own from their portal. So probably the pages I will have to create within PW are the needed admin sections, and then make internally calls to their database. So here's where I need some advice, to make it the correct PW way: Should I use mysqli_query directly in the file template to obtain the data, or is there a method in the API to query external databases? Also I could create pages directly from the queries (let's say, I make a query returning 5 integer values, and then create these values automatically in pages, so I can have them directly in PW, but I'm not quite comfortable with that because redundancy). Also the authentification system, is there a way I could integrate their authentification? I was thinking on adding a request in the head.inc to see if the users is authenticated, and if not, redirect them accordinlgy. So there are the questions, sorry if they seem dumb (or with obvious answers), but I'm just diving into PW, and I want to do it right. Cheers
    2 points
  2. Thanks for posting this Matthew. A couple things I found that I wanted to mention, since this is a front-end form: // Set a temporary upload location where the submitted files are stored during form processing $upload_path = $config->paths->assets . "files/contact_files/"; You want your temporary upload path to be a non web accessible path. Also, if you've got multiple users uploading at the same time, it seems like there is potential for filename collisions, though not sure how big of a concern that is in this case. But you can at least make the directory non web accessible by preceding it with a period, i.e. ".contact_files" rather than "contact_files". $other_photos->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); Keep in mind that WireUpload is only validating the extension. It is not telling you for sure that it's an image. It could very well be some kind of executable with a jpg extension. I don't necessarily know how such a thing could be exploited, other than that I'm not so comfortable with letting a front-end user upload files that end up untouched in a publicly accessible directory. What would probably be safer is to make a new copy of any uploaded images before adding them to the page, and validate the size is within allowed limits while you are at it. $error = ''; $imageInfo = getimagesize($pathname); if($imageInfo) list($width, $height) = $imageInfo; if(!$imageInfo) { $error = "Image is not valid"; } else if($width < 105 || $height < 105) { $error = "Image is too small"; } else if($width > 1600 || $height > 1200) { $error = "Image is too big"; } else { // create your own, slightly smaller copy $sizer = new ImageSizer($pathname); if(!$sizer->resize($width-10, $height-10)) $error = "Unable to resize image"; } if($error) { unlink($pathname); echo "<p>Error: $error</p>"; } else { // add image to page }
    2 points
  3. Another good tutorial: http://webdesign.tutsplus.com/sessions/foundation-for-beginners/
    2 points
  4. Thanks guys, much appreciated! Apologies for the late reply, I have been busy learning/building my first PW sites, hope to finish them soon. For anybody just starting out I highly recommend this video Marty_Walker was kind enough to share, helped me understand the basics really quickly: cheers
    1 point
  5. Hi pnikosis, Welcome to PW and to the forums! Yes, PW does give that Eureka! feeling I'm heading out so will answer your questions briefly. Others will chip in am sure. These topics might be helpful http://processwire.com/talk/topic/1684-reading-and-displaying-data-from-a-custom-table/ http://processwire.com/talk/topic/2242-interact-with-external-database-mysql/ http://processwire.com/talk/topic/669-using-a-secondary-database/ ProcessWire has its own database class that you can use if you wanted to. You will see (and will hear) that if at all possible, move over the data in the external database to PW as pages. However, if that can't be done, then of course, you can use an external db with db class or direct SQL queries. BTW, internally, near future versions of PW will use PDO.
    1 point
  6. Glad you got it! I'll have to remember that one too. No doubt these CKEditor 4.1+'s ACF system is a mixed blessing. On the whole, I'm glad to have it (especially with clients that like to copy/paste from Word, etc.) but I can see it being a real bear when trying to do something out of the norm. I've gone ahead and updated the CKEditor version so that it now supports options for: Enable ACF (Advanced Content Filter)? [Yes/No] (default=Yes) Enable HTML Purifier? [Yes/No] (default=Yes, if installed) When upgrading to this version, revisit all your textarea fields using CKEditor in Setup > Fields, and see the new options on the Input tab. Hit save, even if you don't change anything, just to commit the new settings.
    1 point
  7. On the __contruct(), the MailChimp Api class gets called looks like there's something broken there. The MCAPI.class.php should be loaded there. I strongly advise not to use this plug-in now. As it is standing still for months now. Recently I started to look at it again. ( Actually I'm busy with it now, building in Segmenting options ) My wish is that it will be workable soon, but time's not on my side. ( Next weeks gonna be very busy, vacation, doing nothing but drink beer & make some fun) I will post it here when it's in Beta...
    1 point
  8. Greetings, I am preparing another forum post about different ways to deal with duplicate titles in front-end forms. But in the meantime... What about appending the date/time onto the titles? That would ensure unique titles, and give you useful information right in the title. Of course, this would only be good in cases where you are not going to display the page to the public (which is the case here). Thanks, Matthew
    1 point
  9. I understand now, thanks So we just need to link to http://akismet.com/plans/ rather than http://en.wordpress.com/api-keys/ -- I will update.
    1 point
  10. Hey all, I thought this might be useful for anyone who uses preprocessing tools (like the excellent CodeKit: http://incident57.com/codekit). I came across Prepros the other day: http://alphapixels.com/prepros/ I always used CodeKit up until recently. However, it's only available for mac and recently I have had to dip my toes into the waters of the dark side again with a PC laptop I needed something that would work cross-platform (Prepros works across PC, Mac and Linux). From what I have seen so far Prepros is growing quickly, free, supports nearly every type compiled CSS, has real time refreshes and works across platforms.
    1 point
  11. It's not supposed for anything "serious". Only "Do you think David Beckham is hot?" type of questions for that module
    1 point
  12. Online polls and ratings are always a tricky thing just because if someone is motivated, they can manipulate it. And depending on how creative they are, there's not much you can do about it. Even PollDaddy isn't immune to this. What you did last time, by requiring a social network login, is a definitely improvement over security by IP address. But still not foolproof, and you do end up with a lot of votes coming from people that know nothing about the product, other than someone asked them to vote. But at least a social network login increases the cost to any individual trying to manipulate results. But if it were me, I would use your own custom form (or Form Builder) and place some burden of proof on the voter, like an example of a site where they have used the CMS. For example, these form fields: • How many sites have you used with this CMS? [ ] 0 [ ] 1 [ ] 2-3 [ ] More than 3 • List one example of a site you have used this CMS on? (must be currently running the CMS) [Enter the URL] • For the site you listed above, please provide one URL where we can confirm the CMS. This may be any one of the following: 1. Any URL that refers to the CMS (like a login, info or credits URL–we will keep confidential). 2. Any URL that contains a link to CMSCritic.com. 3. Any URL that references you as an employee, author, editor, designer or developer of the site. [Enter the URL] • How do you use the CMS? [ ] As a web developer [ ] As a web designer [ ] As an editor [ ] As a user [ ] I don't use it • What is your favorite feature of this CMS? [Text field] • Enter your email address (we will send you a email to confirm your vote) (confirm) I think questions like the above would really help to keep the control away from those looking to manipulate results. It would also keep the votes focused on people that actually have experience with the product. I would also include IP filtering and email verification, but not rely upon it. If there's any question of feasibility, this is all stuff that Form Builder (or other form services) can do without too much effort.
    1 point
  13. If you would like to get Twitter via RSS, it is still possible with (free) services like these: http://www.rssitfor.me/
    1 point
  14. Not specific to multi-language page names, but since it's in the dev branch and related, I figured I'd mention it here… Multi-language page fields inherit the default language value when they are blank. While probably a good default, sometimes this behavior is not desirable. So on the latest dev commit, you can now configure that behavior on a field-by-field basis (for any multi-language field). The screenshot below probably explains it best.
    1 point
  15. One idea came up, and was just curious about the feasibility of it: What if the "active" tab was based on the current user's language? So if I had my language set as Spanish, I'd see the Spanish tabs active (rather than default language tab) when editing a page?
    1 point
  16. Wasn't intended, sorry ;-) There is nothing wrong with that. What I wanted to say was: If someone can't afford it, there will be no contract. And if someone has a plenty of money, he gets more features. But I usually don't adjust my hourly rate depending on the clients. Of course. But it is not the way I want to work. See: Creating things is exciting, putting text on websites isn't. I am alone, I don't want to spend my time copying&pasting text on websites. It is something completely different if you are a.) not fully engaged or if you have b.) some (cheaper) employees with which you can handle such tasks. this is how agencies usually handle it, but as I said, I am alone and want to concentrate on the creative processes like concept, design and realization.
    1 point
  17. Thx to all! It's done per individual script as explained here. Doesn't happen here. But since there some JS actions triggered when resizing the window there can sometimes go something wrong. Especially when resizing very fast over two breakpoints. Shouldn't be a "real world" issue, though ;-) (at least I hope that) It's just an Iframe with content from their booking provider. Perhaps they had some loading issues? After clicking on "Buchungsanfrage" you have to click on one of the buttons because the site represents two hotels with two booking forms (also one those weird decisions to run two different booking forms for two hotels which are side by side)
    1 point
  18. Did I already say I love you?!
    1 point
  19. Based on what I'm understanding from your last message, I think you should skip keeping the separate table. It just sounds like extra, unnecessary work, unless there's something more to this project that I don't yet understand. Instead, I think you should have your cron job execute a script that bootstraps ProcessWire and takes care of all the adding, updating and deleting of records consistent with the web service you are reading from. This is something that I think ProcessWire is particularly good at, because it's been designed for this from the beginning (it's something I have to do with a lot of my client work). Whether XML or JSON doesn't matter much, as PHP includes the ability to read from either type quite easily. Though like the other guys here, I generally prefer JSON just because it's less verbose and less fuss. If JSON, you'll pull the feed and use PHP's json_decode() to convert it to an array. If XML, you'll use PHP's SimpleXML to convert it to an array. Once you've got the array of raw data, you'll iterate through it and add, update, or delete pages in ProcessWire to make it consistent with the data you are pulling from the web service. Live, working example I think that the best way to demonstrate it is with a live, working example. This one uses the existing modules.processwire.com/export-json/ feed. You might also want to see the feed in human-readable mode to get a better look at the format. Below is a shell script that bootstraps ProcessWire, reads from that feed and maintains a mini "modules directory" site, on your own site. I made this feed so that it can be tested and used on a brand new installation using the basic profile (included with PW). If left how it is, it'll create a mini modules directory site below the '/about/what/' page and use the template 'basic-page' for any pages it adds. But you can run this on any ProcessWire installation by just editing the script and changing the parent from '/about/what/' to something else, and changing the template from 'basic-page' to something else, if necessary. This script assumes that the template used has 3 fields: title, body, and summary. The 'basic-page' template in PW's default profile already has these. If you adapt this for your own use, you'd probably want to change it to use more specific fields consistent with what you need to store on your pages. In this example, I'm just building a 'body' field with some combined data in it, but that's just to minimize the amount of setup necessary for you or others to test this… The purpose is that this is something you can easily run in the default profile without adding any new templates, fields, pages, etc. 1. Paste the following script into the file import-json.php (or download the attachment below). For testing purposes, just put it in the same directory where you have ProcessWire installed. (If you place it elsewhere, update the include("./index.php"); line at the top to load ProcessWire's index.php file). 2. Edit the import-json.php file and update the first line: "#!/usr/bin/php", to point to where you have PHP installed (if not /usr/bin/php). Save. 3. Make the file executable as a shell script: chmod +x ./import-json.php 4. Run the file at the command line by typing "./import-json.php" and hit enter. It should create about 95 or so pages under /about/what/. Take a look at them. Run it again, and you'll find it reports no changes. Try making some changes to the text on 1 or 2 of the pages it added and run it again, it should update them. Try deleting some of it's pages, and it should add them back. Try adding some pages below /about/what/ on your own, run it again, and it should delete them. import-json.php #!/usr/bin/php <?php // replace the path in the shabang line above with the path to your PHP // bootstrap ProcessWire. Update the path in the include if this script is not in the same dir include("./index.php"); // if you want to run this as a PW page/template instead, remove everything above (except the PHP tag) // 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; // URL to our web service data $url = 'http://modules.processwire.com/export-json/?apikey=pw223&limit=100'; // get the data and decode it to an array $data = json_decode(file_get_contents($url), true); // if we couldn't load the data, then abort if(!$data || $data['status'] != 'success') throw new WireException("Can't load data from $url"); // 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/what/'); if(!$parent->id) throw new WireException("Parent page does not exist"); // iterate each item in the feed and create or update pages with the data foreach($data['items'] as $item) { // see if we already have this item $page = $parent->child("name=$item[name]"); // if we don't have this item already then create it if(!$page->id) { $page = new Page(); $page->parent = $parent; $page->template = 'basic-page'; // template new pages should use $page->name = $item['name']; echo "\nAdding new page: $item[name]"; $numAdded++; } // now populate our page fields from data in the feed $page->of(false); // ensure output formatting is off $page->title = $item['title']; $page->summary = $item['summary']; // To keep it simple, we'll just populate our $page->body field with some combined // data from the feed. Outside of this example context, you'd probably want to // populate separate fields that you'd created on the page's template. $body = "<h2>$item[summary]</h2>"; $body .= "<p>Version: $item[module_version]</p>"; foreach($item['categories'] as $category) $body .= "<p>Category: $category[title]</p>"; $body .= "<p><a href='$item[download_url]'>Download</a> / <a href='$item[url]'>More Details</a></p>"; $page->body = $body; // print what changed $changes = $page->getChanges(); if(count($changes)) { $numChanged++; foreach($changes as $change) echo "\nUpdated '$change' on page: $page->name"; } // save the page $page->save(); } // now find pages that were not updated above, which indicates they // weren't in the feed and should probably be trashed $expired = $parent->children("modified<$started"); foreach($expired as $page) { echo "\nTrashing expired page: $page->name"; $page->trash(); // move to trash $numTrashed++; } echo "\n\n$numAdded page(s) were added"; echo "\n$numChanged page(s) were changed"; echo "\n$numTrashed page(s) were trashed\n"; import-json.php.txt Running the script as a cron job: You can instruct your cron job to run the script and it should be ready to go. You may want to move it to a non web accessible location for more permanent use. You'll also want to update your bootstrap "include()" line at the top to have the full path to your ProcessWire index.php file, as your cron job probably isn't executing it from the web root dir like you were manually. Running the script as a template file: You can run this script as a template file on a page by removing the include() line and everything above it with this line: <pre><?php Place it in your /site/templates/ directory, add the template from PW admin, and create a page that uses it, then view it.
    1 point
×
×
  • Create New...