Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/12/2013 in all areas

  1. Update: Pushed new version to GitHub just moments ago. This fixes some minor glitches and adds new "quick diff" feature. See attached screenshot for more details. It's very primitive at the moment, but I'm hoping to improve it (and some other parts of this module) soon. This is first actual "feature update" for this module, so I'm a bit nervous and would very much like to hear how it works for you. Tested it here with multiple browsers and fields etc. but I've probably again overlooked some issues. Regarding the diff feature, Google did most of the heavy lifting there; all I did was integrate their Diff Match and Patch library (JavaScript version) to my code. For the record I was going to use jQuery PrettyTextDiff, but that really didn't feel necessary considering that it's just an attempt to simplify the (already simple) DMP API.
    7 points
  2. Thank you so much apesia, soma and adrian. @soma and @apeisa - I followed your advise. Thanks again now it is working fine (happy). @adrian - Yes adrian I put news-pager-index.php file under template directory. Just to recap: if we need use external template file other than the template name we have to use altFilename property. In the normal scenario we can use name property if the template file name and template name were same. Here is the working copy thanks to processwire and friendly community members. It might be helpful to newbies like me. class NewsPager extends WireData implements Module{ public static function getModuleInfo() { return array( 'title' => 'News pager', 'version' => 001, 'summary' => 'News pager template', 'singular' => true, 'autoload' => true, ); } public function init() { //todo add some listeners } /** * Install the module * */ public function ___install() { // new fieldgroup $fg = new Fieldgroup(); $fg->name = 'news-pager-index'; $fg->add($this->fields->get('title')); // needed title field $fg->add($this->fields->get('body')); // needed body field $fg->save(); // new template using the fieldgroup and a template $t = new Template(); $t->name = 'news-pager-index';//Used different name other than file name /* * altFilename property will accept file-name or file-name.php * or even $this->config->paths->templates . 'file-name.php' * Note: template file needs to be placed under * template directory */ $t->altFilename = 'news-pager-index-file';//name of the template file which is under tml dir. $t->fieldgroup = $fg; // add the field group $t->save(); } /** * Uninstall the module * */ public function ___uninstall() { $templateNeeded = $this->templates->get("news-pager-index"); $fgOld = $this->fieldgroups->get('news-pager-index'); if ($templateNeeded->getNumPages() > 0) { throw new WireException("Can't uninstall because template been used by some pages."); }else { wire('templates')->delete($templateNeeded); wire('fieldgroups')->delete($fgOld); } } }
    3 points
  3. Your simplest best would be to just extend ProcessWire most basic starting point, which is Wire. This enables your class to have access to API variables (through $this), enables any of your methods to be hookable (that you precede with 3 underscores), and makes the file possible to translate with language support. Another option is to extend WireData. This is the same as Wire, except that you gain $this->set() and $this->get() methods that are accessible both in and outside of the class. It essentially means your class can function as a shared data container. The set() and get() can also be accessed by $this->key = 'value'; and $value = $this->key. The last utility class to mention would be WireArray, which is meant for storing an array of objects. This one is a little more complex than the other two (though it's still quite simple), and I'm guessing it's not what you need in this case, so won't go into detail unless you want me to. You don't necessarily have to extend any of PW's classes. But if you want $this->property; access to the API variables, you'd want to implement your own __get() method in your class: public function __get($property) { return wire($property); // or Wire::getFuel($property); }
    3 points
  4. Yeah well, to paraphrase an old adage... Give a man a fish, and he'll have food for a day. Give a marketing exec a CMS, and he'll ruin a site in no time. We're really not responsible for a) the look and b) the actual content. (some translations are an atrocity... guess it's all done in-house or with housewives who do a bit of hobby translation on the side...)
    2 points
  5. Here is a quick guide to using the comments system. We start from the simplest usage, and get down into more configuration options further in the post. Making use of the Comments fieldtype 1. Make sure that Comments fieldtype (FieldtypeComments) is installed from the Admin > Modules menu. 2. Now go to Admin > Setup > Fields and create a new field. Select "Comments" as the fieldtype and give it whatever name you wish (I usually call it just "comments", and code snippets here assume it's called that). 3. On the next screen, you'll have several options to configure the comments field. Make sure that you enter a Notification email. This is the email address that gets notified when new comments are submitted. Currently it is the only way you will know when new comments are posted (short of checking the admin page yourself), so using this is important. 4. Now edit the template where you want your comments to appear. Enter this: <?php echo $page->comments->render(); 5. Likewise, in your template, enter this where you want the comments entry form to appear: <?php echo $page->comments->renderForm(); 6. Your comments are now ready to use. Note that any templates that use comments for posting should not use Template caching unless you configure the comments to post to another template/page. You'll see an option for this in the renderForm() options shown further down on this post. Adding the Akismet Spam Filter I highly recommend that you use the Akismet spam filter with your comments. To do so, you'll need an Akismet or Wordpress API key (http://en.wordpress.com/api-keys/). Once you have it, click to Admin > Modules > Akismet (CommentFilterAkismet). Enter your API key in the space provided and Save. Then go to Setup > Fields > and edit the comments field you added. Check the box for "Use Akismet". You'll also see a field that says how many days it will keep spam before deleting it. I usually set this at 1 or 2 days, just in case Akismet identifies something as spam that isn't (though it's yet to happen!). Hit Save, and your comments are now hooked into Akismet. Styling the Comments See the file attached to this message (at the bottom). It is a starting point for styling the comments. It's just pulled from the comments styling at processwire.com, so it should be seen as an optional starting point rather than as a ready-to-go stylesheet. Or, you may prefer to start from scratch on styling the comments, depending on your need. OPTIONAL: Customizing the Comments Output You may want to change some of the basics of the comments output. You can do this by passing arguments to the functions you called above to render the comments list and comments form. Included below are examples with all options. You may specify any one or more of the options -- only specify the ones you want to change: <?php // comments list with all options specified (these are the defaults) echo $page->comments->render(array( 'headline' => '<h3>Comments</h3>', 'commentHeader' => 'Posted by {cite} on {created}', 'dateFormat' => 'm/d/y g:ia', 'encoding' => 'UTF-8', 'admin' => false, // shows unapproved comments if true )); // comments form with all options specified (these are the defaults) echo $page->comments->renderForm(array( 'headline' => "<h3>Post Comment</h3>", 'successMessage' => "<p class='success'>Thank you, your submission has been saved.</p>", 'errorMessage' => "<p class='error'>Your submission was not saved due to one or more errors. Please check that you have completed all fields before submitting again.</p>", 'processInput' => true, 'encoding' => 'UTF-8', 'attrs' => array( 'id' => 'CommentForm', 'action' => './', 'method' => 'post', 'class' => '', 'rows' => 5, 'cols' => 50, ), 'labels' => array( 'cite' => 'Your Name', 'email' => 'Your E-Mail', 'text' => 'Comments', 'submit' => 'Submit', ), // the name of a field that must be set (and have any non-blank value), typically set in Javascript to keep out spammers // to use it, YOU must set this with a <input hidden> field from your own javascript, somewhere in the form 'requireSecurityField' => '', // not used by default )); Lets say that you just wanted to change the headlines for the comments list and comments form. You'd do this: <?php echo $page->comments->render(array( 'headline' => '<h2>Read Comments</h2>', )); echo $page->comments->renderForm(array( 'headline' => '<h2>Join The Discussion</h2>', )); OPTIONAL: Generating your own output If you wanted to generate your own output (rather than use the built in render() methods), you can iterate the $page->comments field: <?php foreach($page->comments as $comment) { if($comment->status < 1) continue; // skip unapproved or spam comments $cite = htmlentities($comment->cite); // make sure output is entity encoded $text = htmlentities($comment->text); $date = date('m/d/y g:ia', $comment->created); // format the date echo "<p><strong>Posted by $cite on $date</strong><br />$text</p>"; } You can likewise do the same for the comment form. But I don't want to get too far into this level yet since this is supposed to be a quick guide. Whats on the Comments roadmap? In my mind the biggest missing part is a central place to manage all your comments. Currently you manage them on a page-by-page basis, consistent with where the comment was posted. This is fine for simple uses, but becomes more challenging on larger sites, where you have to rely upon the notification emails to let you know where comments are posted. I would like to expand this so that comments can optionally be managed in a central place. In addition, I would like to make them as easily API accessible as pages. The comments are also not hooked into the user system. Every time you post, you are essentially posting as a guest. While the comments fieldtype will recognize your email address if you have posted an approved comment before, I would like to make it recognize the user system, and also recognize other user systems (like Twitter, Facebook and Gravatar). There is more needed too, like comments pagination and support for basic markup (comments can only contain text at present). If your needs are relatively simple, the Comments fieldtype is a good way to go. If your needs are more advanced, systems like Disqus and Intense Debate are excellent options to consider. The only issue I would have with those options is that they are javascript-based by default, so comments don't become part of your site's indexable content (to search engines like Google). comments.css.zip
    1 point
  6. To interact with the images field. Create a new field (under Setup > Fields) and call it whatever you want, like "images" for example. Set the field type as "image". Add this field to a template (under Setup > Templates). Then edit a page using that template and upload some images. In your template code: ProcessWire will create your images at any size on the fly and then keep a cache of them. For instance, lets say we want to cycle through all the images, create a large image at 500 pixel width with proportional height, and a thumbnail at 100x100, and then have the thumbnail link to the large: <?php foreach($page->images as $image) { $large = $image->width(500); $thumb = $image->size(100, 100); echo "<a href='{$large->url}'><img src='{$thumb->url}' alt='{$thumb->description}' /></a>"; }
    1 point
  7. A new PW site has just been launched: http://www.seifertsystems.com A teamwork with Beat Beer (frontend development) We had no influence on the visual design / layout. We had to maintain the visual look of the old site. But "under the hood", the markup changed a lot (for the better). The main functions / tasks: Transfer from old CMS (MODX Evo) to ProcessWire. Not everything could be exported / imported via script, due to the old site using a very clunky multilingual system (YAMS). Dynamic product catalogue, with main categories, and product type groups. Automated product catalogue import for all four languages (from MS Excel, import to PW via CSV import modulue and various API scripts). Compact products overview and detail product infos. (accessible tabs) Fully responsive - compatible with laptop, smartphone and tablet displays. Dramatical markup clean-up (HTML, CSS): resulting in much faster loading, and overall smaller filesizes (less than 50% of the old code). Usability, accessibility and SEO improvements. Multilingual setup (german, english, US-english, french), partially custom content per region / language. PW 2.3.2 multilang setup, geoIP for certain geographical filters / redirects. Newsletter 3rd-party app integration. = Mailchimp. Frankly, while it's OK, the possibilities for other languages than english are quite limited. Same goes for styling the signup CSS. But hey, it's free for up to 2000 subscribers or so... Faster loading and much more user-friendly for both site-visitors and site-admins. Hint 1: When using CKEditor, there's a setting "render WYSIWYG only on focus". Hint 2: There a setting to keep empty fields collapsed, when the field is empty. Dynamic XML and HTML sitemaps. XML: For all visible and published pages, for all four languages. HTML: One for each language. Image galleries and slideshows. (Shadowbox + jQuery Cycle plugin) Search with coloured keyword highlighting on the result pages. News section with publishing scheduling. i.e. create pages (news-items) in advance, and set publish and unpublish dates - simply by adding two datetime fields and an appropriate selector in the templates, e.g. $t = time(); $latestNews = $pages->find("parent=1108, limit=4, sort=sort, include=hidden, publish_start<'$t', publish_end>'$t'"); Main PW tools used: Batcher XML Sitemap from demo install (with a tweak, to collect all four languages, and sub-pages inside hidden folders too, all in one single XML) MarkupSimpleNavigation module Language Field Tabs FormBuilder Import Pages From CSV module Modules Manager Page Edit Fold Status module + various pieces from PW demo installs / profiles But by far, the biggest godsends were the great API, the terrific multilang PW functions of v. 2.3.2+, the good documentation, and the great community help here. The difficult parts were not really technical issues, but having to wait endlessly for content, getting new change requests almost daily, and putting up with several launch delays. We seriously didn't believe that we could launch it still in 2013. What may lie ahead next year (or not), is Googlemaps integration and dynamic PDF generation for product sheets.
    1 point
  8. Hey Ryan, being a huge fond of the CKEditor module, I just stumbled over a tinyish bug: the icon images of the Codemirror plugin are actually missing. I already filed a pull request, would be great if you could merge that anytime soon: https://github.com/ryancramerdesign/InputfieldCKEditor/pull/11
    1 point
  9. Wow, awesome update Teppo! The diff feature looks fantastic. Can't wait to try this one out.
    1 point
  10. Is this dev branch? None of those line numbers in the errors line up with the line numbers in the file. Also, I don't see any of those warnings and I've pretty much got debug mode on all the time locally. I also tried to duplicate this but couldn't. Here's the code I used: $img = $page->images->first(); $img2 = $img->size($img->width, 0); echo "<img src='$img2->url'>"; Is it possible you've got a different ImageSizer.php somehow? EDIT: Soma never mind–I'm the one that's got a different ImageSizer.php not sure how this has gone uncommitted for so long, committing now...
    1 point
  11. Does the news-pager-index.php file exist in the templates directory?
    1 point
  12. I think you don't need to set it. It will automatically take the template name without .php To set a filename other than its name you need to set the alternative name.
    1 point
  13. 1 point
  14. I'm not sure the date is really recognized as date and that would work with strtotime() but maybe you should put it in as a string: $p->calendar->find("booked=0, checkin_1='16.11.2013'"); This should definately work $date = strtotime("16.11.2013"); $p->calendar->find("booked=0, checkin_1=$date"); Outputformatting has nothing to do with it.
    1 point
  15. So, I built something ugly und unDRY that works for me. http://processwire.com/talk/topic/3761-dropzonejs-and-file-uploads/?p=47209 https://github.com/bytebus/AjaxImageUpload This is just a proof-of-concept and by no means ready to use as a drop-in, so take it with caution.
    1 point
  16. When you want to help your clients to use the fields within a template, your descriptions might get quite extensive. I don't like the descriptions to clutter the whole edit page, it's confusing. So this little module adds buttons to all headers of fields that have descriptions, hides them by default and only shows them, if the questionmark is clicked. GitHub: https://github.com/owzim/PWPageEditDescriptionToggle Shots: Collapsed state: http://d.pr/i/EETH Expanded state, questionmark appears: http://d.pr/i/RBxr Expanded description state: http://d.pr/i/4fKw Let me know what you think. Cheers Christian
    1 point
  17. I created an empty language pack. Go to: Admin > Setup > Languages Create a new language Drag & Drop the attached zip-file in the Language Translation Files Field. Start to edit the files. empty-lang_pack_pw_3.0.41.zip EDIT: Obsolete in latest PW Versions. Create a language pack by your own. Go to: Admin > Setup > Languages > Add New Save Press button: 'Find Files to Translate' Select all files in the box 'Translatable files in /wire/' Select files in the box 'Translatable files in /site/' which you want to add to your custom language pack Press 'Submit' Start translating Download zip or csv file by pressing the related button at the bottom of the page where translatable files are listed. Done
    1 point
  18. Thanks Ryan I ended up using a combination of jquery append (and remove) and the following for loop in PHP. $total = 0; for ( $i=0;$i<count($input->post->invoice_billable);$i++) { ${'rp'.$i} = $page->invoice_line->getNew(); ${'rp'.$i}->invoice_billable_line = $input->post->invoice_billable[$i]; ${'rp'.$i}->invoice_billable_amount = $input->post->line_value[$i]; In case that helps anyone out.
    1 point
  19. I was working over this code from apeisa http://processwire.c...t__20#entry1364 and wanted to share the result with you all. Basically, this allows you to mirror the admin form from a given page to the frontend. To give some flexibility, you can fill an array with the fields to exclude —or else, the fields to include— on the output. EDIT: I forgot to tell... this works well with regular fields (text, textareas, checkboxes, radios, multiple choice, etc), but didn't manage to make it work well with images, for instance. So, here is the code: <?php // Get the page you need to edit $mypage = $pages->get('/some/page/'); // Populate with the names of the fields you want to exclude OR include (see instructions below) // Leave empty to output all the fields $myfields = array('body', 'email'); $form = $modules->get('InputfieldForm'); $fields = $mypage->getInputfields(); // If array is not empty use it to filter the fields if ($myfields){ foreach($fields as $f){ // Output all the fields minus the ones listed in the $myfields array // Instead, to output only the fields that are in the array, remove the (!) from the condition if (!in_array($f->name, $myfields)){ $form->append($f); } } } // Else, include all the fields else { $form->append($fields); } // Add save button $field = $this->modules->get('InputfieldSubmit'); $field->attr('id+name', 'submit_save'); $field->attr('value', 'Save'); $field->label = "submit herei"; $form->append($field); // Process the form // (code replaced by a new one provided by Ryan) if($input->post->submit_save) { $form->processInput($input->post); if(!$form->getErrors()) { $mypage->of(false); // turn off output formatting before setting values foreach($mypage->fields as $f) { $mypage->set($f->name, $form->get($f->name)->value); } } } include("./head.inc"); // Render the form echo $form->render(); include("./foot.inc");
    1 point
×
×
  • Create New...