Leaderboard
Popular Content
Showing content with the highest reputation on 06/05/2013 in all areas
-
I just pushed ProcessWire v2.3.1 to the dev branch. This is a fairly major change in that it switches the DB driver from mysqli to PDO. It meant changes to a large percentage of core files. ProcessWire still supports mysqli, but doesn't attempt to use it unless a module or a template asks for it via the $db API variable. The new API variable (for the PDO driver) is $database. More about PDO at php.net If you are using the dev branch, be careful and test thoroughly with this latest commit to it. Before upgrading, you may want to double check that your PHP supports PDO by looking at your phpinfo (CMD-F or CTRL-F for "PDO"), especially if you are running PHP 5.2.x (where PDO wasn't compiled in by default). Though if you are running PHP 5.2 (vs 5.3.8+) then you may want to just stick with ProcessWire 2.3.0 and upgrade your PHP version when possible. If you are using any modules that use the procedural version of mysqli functions (vs. the $this->db object oriented versions), or type-hint mysqli in methods, then those modules will no longer work. If you come across any modules that don't work with 2.3.1, please let me know here so that I can assist the author in updating them. Note that FormBuilder is one of the modules that does not work with 2.3.1, but I have posted an update in the FormBuilder board that corrects it–so be sure to download that version if you are tracking the dev branch of ProcessWire and using FormBuilder. What this new version adds: 1. New API variable $database that refers to the PDO database. The old $db API variable is still there and refers to mysqli for any modules that continue to use it. 2. New API variable $log that lets you easily log messages or errors to the system logs. Usage: $log->message("This saves this line to messages.txt"); $log->error("This saves this line to to errors.txt"); $log->save("my-log", "This saves this line to my-log.txt"); // Get an array of the last few entries saved to the messages log $entries = $log->get('messages'); // Get an array of the last 50 entries saved to my-log $entries = $log->get('my-log', 50); Note that as always, log files are located in /site/assets/logs/. 3. Conditional autoload modules. In PHP 5.3+, modules may now specify an anonymous function OR a selector string, rather than a boolean for the 'autoload' property returned by getModuleInfo(). PW runs the anonymous function after determining the current $page, so your module can make autoload decisions based on the $page (or any other factor you'd like), if desired. Lets say that we have a module that we only want to autoload when the template is 'admin': public static function getModuleInfo() { return array( 'title' => 'Module Title', 'summary' => 'Summary text...', 'version' => 1, 'autoload' => function() { if(wire('page')->template == 'admin') return true; else return false; }); } And the same example but using a selector for autoload: public static function getModuleInfo() { return array( 'title' => 'Module Title', 'summary' => 'Summary text...', 'version' => 1, 'autoload' => 'template=admin' ); } 4. Addition of $pages->add() method. Actually $pages->add($template, $parent, [string $name], [array $values]); This function adds a new page to the database and returns it. This is for syntax convenience, but using the old method is still perfectly fine too. Here's a few examples of usage: // add a new page using template basic-page under /about/ $newpage = $pages->add('basic-page', '/about/'); // same as above, but named 'contact' $newpage = $pages->add('basic-page', '/about/', 'contact'); // same, but populate the title field too $newpage = $pages->add('basic-page', '/about/', 'contact', array('title' => 'Contact Us')); // you can also do this, specifying the values array as 3rd argument: $newpage = $pages->add('basic-page', '/about/', array('title' => 'Contact Us')); $template and $parent are required, but may be objects, IDs, or string identifiers (like name for template, or path for page). When you add a new page and don't specify a 'name', then PW will make one up, guaranteed to be unique. 5. Module files that end in '.module.php' are now supported. So rather than ClassName.module, you may use ClassName.module.php if you prefer it. The purpose here is to support text editors that determine their syntax highlighting based on the file extension. More updates being made almost daily. Please report any issues you experience. Thanks, Ryan15 points
-
3 points
-
One of the many things I love about PW is that whenever new features are added they always make sense. Not just Ryan's excellent descriptions, but the additions themselves. In this case I especially like the $pages->add method.3 points
-
No there's no way to avoid this, except if you would do $fields = $somepage->fieldgroup; foreach($fields as $f) { $inputfield = $fields->get("$f->name")->getInputfield($somepage); $form->add($inputfield); } This somehow gets around the error when rendering the form. But once submitted you'll end with the same error. Yes you are correct. In PW a page needs to be saved before files can be added or accessed, the PagefileManager requires a page id and since you build it using inputfields in context of a page object it fails. Pagefiles are saved in the filesystem using the page id, and since the page doesn't yet have an id it's simply not possible. For the same reason Ryan's FormTemplateProcessor also only works with text fields. Since you seem to have file fields in your template, you have to save the page to go this route, which I'm sure you don't want. Or remove file fields from the form, which is maybe also not what you want. So you have to build it different and build the form differently, maybe still using the fields from a template, but add your own file field upload. There various threads and example I did a while back. Some are on my gists. Example: https://gist.github.com/somatonic/41509742 points
-
Soma, Much appreciated. The *hash* thing threw me at first—but as usual—it's not that complicated. What you posted was almost it, but it threw some error about using wire $input as an array. I tweaked a little, and ended up with this (which works perfectly) foreach($p->files as $file) { $id = "delete_files_". $file->hash; if(isset($input->post->$id)) { $p->files->delete($file); } } Thanks again.2 points
-
2 points
-
Glad you guys like it, Pete did a phenomenal job and was great to work with. More modules to follow soon, standby!2 points
-
Antti - to answer your questions: This grated on me every time I wrote the word "category" and I should probably just change it to "parent page" as that's more in keeping with ProcessWire's terminology (to newcomers "Category" makes sense, but PW is all about enticing people to learn new things after all ). I'll change this in the next update. It is hardcoded to the images field for now. I realise this is a bit of a gamble that they haven't renamed/deleted this field, so should probably add an extra config option for this. The reason I didn't for now is that it then led me to thinking (as you have) about other file types and then I thought about allowing different fields for different templates and started to get a headache I should at least do the first part and allow the admin to select a different field, plus add more checks for attachment filetypes. As a result of those two points, the next version really needs: Rename "category" to "parent page" throughout Allow admin to select image field Add more checks for filetypes attached to emails Add field for whitelist of email addresses Maybe allow for other attachments (why not? It's simple enough ) Not sure when I might get around to these as there may be other stuff in the pipeline before then2 points
-
This module is now complete: http://processwire.com/talk/topic/3743-processemailtopage/ Thanks to Jason for allowing it to be released to the community2 points
-
Easily insert any complex HTML, Javascript or PHP output in your ProcessWire content by creating your own Hanna code tags. This module is based loosely on the WordPress Hana Code Insert plugin. A Hanna code tag looks like [[hello_world]]. A Hanna code tag with attributes looks like [[hello_world foo=bar" bar="foo]] using HTML style attributes or [[hello_world foo=bar, bar=foo]] using ProcessWire selector style attributes. After installing the module, you define your Hanna codes in Setup > Hanna Code. These Hanna codes that you define can then be entered within your body copy (or other text where you allow) and they will be replaced with the values defined or generated by your Hanna code. A common use case is to embed scripts or other bits of HTML or codes that would usually be stripped out by an editor like TinyMCE. However, Hanna codes can be more than just static snippets--they can be dynamic PHP or Javascript that outputs different things according to the request. PHP-based Hanna codes have access to the entire ProcessWire API. Hanna code accepts named attributes in the tag that can be passed as variables to PHP and Javascript Hanna codes. These attributes can be specified either in HTML attribute format or ProcessWire selector format. In either case, quotes should be used around the attribute value when the value contains whitespace or a comma. How to install Place the module files in /site/modules/TextformatterHannaCode/ In your admin, click Modules > Check for new modules Click install for TextformatterHannaCode Now to go Setup > Fields and locate the Textarea field(s) that you want to use Hanna codes with ("body" for instance). When editing the field, click the details tab, and select "Hanna Code" as the Textformatter. Save. Now go to Setup > Hanna Code and start defining your Hanna Codes! You may want to use one of the examples from this document to get started. Tag format Below is a Hanna code tag named hello_world with no attributes. If you pasted this into your body copy, you would get whatever the replacement value is that you defined. [[hello_world]] Below is a Hanna code tag named hello_world being passed attributes of foo, bar and foobar. If this were a PHP-based Hanna code, it would receive the variables $foo, $bar and $foobar: [[hello_world foo="bar" bar="foo" foobar="foo bar"]] Below is the same Hanna code tag as above, but with attributes more like ProcessWire selectors. You can use whatever format you prefer. Just note that unlike regular ProcessWire selectors, quotes (single or double) are required around any value that has whitespace. [[hello_world, foo=bar, bar=foo, foobar="foo bar"]] How to use Please make sure that you have completed the How to install section first. Then in your admin, go to Setup > Hanna Codes. Each Hanna code that you add has a type of either: Text/HTML, Javascript or PHP. The Text/HTML type is literally self explanatory in that your [[custom-tag]] is replaced with exactly the text you paste in. Anywhere that you type your [[custom-tag]] in your body copy will be replaced with exactly the static text you defined. More power opens up with the Javascript and/or PHP types of codes. These codes execute at runtime and thus can contain specific logic to produce different results. In fact, PHP Hanna codes have access to the entire ProcessWire API and are executed in the same manner as template files. Your PHP-based Hanna code should simply "echo" or "print" the replacement value. PHP example Create a new Hanna code with the name "children". Select "PHP" as the type. Paste in the following for the code: foreach($page->children as $child) { echo "<p><a href='$child->url'>$child->title</a>"; } Now go and edit a page that has children. In the body copy, enter [[children]] in the place where you want the output to appear. View the page, and you should see the rendered list of links to children. PHP example, part 2 Now lets take the above example further... Go back and edit your "children" Hanna code, as we are going to modify it to respond to a "parent" attribute. Change the code to this: if(isset($parent)) { // If $parent is an ID or path, lets convert it to a Page $parent = $pages->get($parent); } else { // otherwise lets assume the current page is the parent $parent = $page; } foreach($parent->children as $child) { echo "<p><a href='$child->url'>$child->title</a>"; } Go back and edit the page where you previously inserted the [[children]] tag, and change it to: [[children, parent=1]] (specifying the homepage) or [[children, parent=/path/to/some/parent/]] if you want to try something else. View the page and you should now see it showing the children of the homepage (or of another parent you specified). Please see the Javascript and PHP usage notes on the Hanna code entry screen. Security There are major security implications with a tool that will let you enter unfiltered text and code from your web browser. As a result, Hanna codes are meant for definition only by superusers and we recommend keeping it that way. Download Download the Hanna Code module from the ProcessWire modules page or from GitHub.1 point
-
This is an exciting announcement for me to make! After having selected ProcessWire as our 2012 Best Free CMS winner in our Critics Choice CMS Awards, we decided it was time to put our money where our mouths are and make the move ourselves. I'll get into more detail soon but for now, I'm excited to present the new CMS Critic (developed by the illustrious Ryan Cramer). Note that it is still propagating so if you don't see a site that looks like the screenshot below, DNS hasn't fully updated. I'm just too pleased to wait the full 24 hours to make the announcement ;P I also did this write up on the experience: http://www.cmscritic.com/cms-critic-is-now-powered-by-processwire/ Check it out: CMS Critic1 point
-
Hello all, I just spent 3 days without internet and I couldn't do much work on my ProcessWire project because I couldn't use the cheatsheet. I realized that there's a need to have PW's documentation in an ebook format including cheatsheet. So I've copy-pasted cheatsheet in a doc file & created a cheatsheet ebook for offline use. I'm posting it here so that others can also use it. Please let me know if doing this is wrong in anyway, I'll delete the files. Also note that there was no intention to make any kind of profit by using cheatsheet to make an ebook out of it. I hope this will help people like me when they're unable to access cheatsheet for any reason. Enjoy. EDIT: Attached file has been updated, as it wasn't readable on Mac and also wasn't very good looking. So I've updated it for better readability but I'm not sure if it still works on Mac, so someone needs to check it for me. Cheatsheet_1.1_v0.2.pdf1 point
-
Another minor addition to happy family of ProcessWire modules: Markup Load Atom. Markup Load Atom was forked from Ryan's Markup Load RSS to provide similar functionality for Atom feeds: given Atom feed URL it loads it and allows you to foreach through it and/or render it with built-in render() method. Get it from GitHub: https://github.com/teppokoivula/MarkupLoadAtom Note: I've been using this on a production site for a while now, but haven't really worked much with Atom feeds specifically. If you're a guru in that matter and feel that something is odd or plain wrong here, please let me know and I'll see what I can do. How to use With your own markup: $atom = $modules->get("MarkupLoadAtom"); $atom->load("https://github.com/ryancramerdesign/ProcessWire/commits/master.atom"); foreach($atom as $item) { echo "<p>"; echo "<a href='{$item->url}'>{$item->title}</a> "; echo $item->date . "<br /> "; echo $item->body; echo "</p>"; } Or with built-in rendering: $atom = $modules->get("MarkupLoadAtom"); echo $atom->render("https://github.com/ryancramerdesign/ProcessWire/commits/master.atom"); Installation Installing is identical to most other modules; just copy MarkupLoadAtom.module or whole MarkupLoadAtom directory to your /site/modules/, hit "Check for new modules" at Admin modules area and install "Markup Load Atom". More examples, detailed instructions etc. can be found from README.1 point
-
Ahhhh...I think this is because I'm using a folder (leftover from MODx) called "/assets" and PW has its own folder called "/site/assets". I renamed it to "/test" and it seemed to work OK. But because other images in the site are already using "/assets/images/blah.jpg" I guess I need to either symlink "/assets" to "/test" or search & replace in the database. OK, I think this might be fixed now. Thanks!1 point
-
I think you need fieldgroup to add fields first and then add fieldgroup to template. Look at apeisa's shop module for examples. Oops or couple posts above nice guy soma has some example.1 point
-
It is as simple as this: <?php /** * Page template * */ include("./head.inc"); echo $page->body; echo $page->your_field_name; echo $page->another_field_name; echo $page->third_field_name; include("./foot.inc"); But do finish to those tutorials. You easily get a grasp of all the possibilities.1 point
-
Welcome tv_855, you might want to checkout some tutorials first. For the fields to work on the frondend you have to include the fields in in your php files. Checkout these: Basic website Another basic planet based tutorial1 point
-
It looks like you have some unnecessary comparison in there (including a == full object comparison), I recommend this instead: if('en' == $user->language->name) setlocale(LC_ALL, 'en_GB'); Generally when comparing one page to another in ProcessWire, you want to compare the IDs: $page1->id == $page2->id; or if you want to compare the objects then use 3 equals so that it's comparing the instance rather than all the properties (per the way PHP works): $page1 === $page2; But in the case above, it wasn't even necessary to compare any objects since all you needed to compare was the name to the string 'en'.1 point
-
Meanwhile I converted the Docs from the website in an ePub file. I know it's not really a book, and I confess that the conversion it's s bit clumsy, bute here it is for those that are interested https://docs.google.com/file/d/0B6RyV62pA8iwckthSTE1XzBOQzA/edit?usp=sharing1 point
-
Why do you want this anyway? The current parents are already marked with a class you can define. Default "parent". I'm not too excited to add another template option, as we will have a new option every other week someone thinks this would be useful. However, for that reason I created a function (getTagsString) you can hook into to change a child's output. There's some example further up this thread, but just to give another example: $nav = $modules->get("MarkupSimpleNavigation"); function hookTagString(HookEvent $event){ $child = $event->arguments('page'); // current child in navigation $parents = wire("page")->parents; // parents of current page if($parents->has($child)){ // is current child an active parent? $event->return = "<span class='parent'>$child->title</span>"; // return something } } $nav->addHookAfter('getTagsString', null, 'hookTagString'); echo $nav->render();1 point
-
1 point
-
Thanks ryan! And thanks again to Jason for letting my run with some ideas. I could just as easily completed this by making the admin enter comma separated values in a textarea field (the easy way to go) but I wanted to make input foolproof and the idea was already in my head. And now some techy stuff: I had some fun working out the ajax behind adding new rows and settling on saving the field data as a JSON string in the end (which is fine because nobody is going to set up dozens of email accounts!) but if there are any suggestions for improvement there then please let me know as it seems to me now that there are endless possibilities for "add another row" type setups in module configuration. Before that I was trying to overcomplicate things and have the new rows save in the background as an array, but if I intercepted the page save, ran the ajax request and then use jQuery to finish submitting the form then it wouldn't save the other form data. I abandoned that idea completely (but left the function in the module file for reference). In the end, keeping it simple worked out better as running ajax upon saving the config page slowed the page save process down as it essentially sent two requests - converting the data to a json string and saving to a hidden field is instantaneous by comparison To those not following all that, my eventual solution was to KISS1 point
-
Pete, this looks fantastic (just watched the video). Few questions popped on my mind while watching: why is parent page called category on module settings page? "Images" field name seems to be hardcoded? Does (or will it) support other attachments than images? Again, brilliant work. Thanks Pete & Jason.1 point
-
1 point
-
Already nominated my favourite. You might be able to guess what it is1 point
-
A quick update. Ran a page speed test on pingdom and it came back with a 588ms load time (faster than 95 percent of websites)1 point
-
Done, moved it Wishlist & Roadmap -- Just a detail, but maybe I would change the order in my second solution: $link = $page->urlfield || $page->pagefield->url;1 point
-
Thanks Fernando for your contribution. A Latin American version is indeed sorely needed. I'll be more than happy to collaborate with you so we can have two (or more) rock-solid Spanish versions. As a matter of fact, I was planning on revising my original work for a new Web project in Spanish that I'll be starting in about a month, and enlist the help of a native speaker from Spain to double-check everything. My translation is for an older version of PW, so I suppose there must new fields to be translated anyway. As regards to your question about how to get started with the translation, if I remember well, I did everything from the control panel. As it's not always easy to determine the context of the original text in English, I think it's best to move back and forth between a live site and the control panel to sort out the intended meaning, which I did not do fully enough in the first place. Jacques1 point
-
Went yesterday to the cinema to see "Drupal & Joomla 6", and was not disappointed. Highly recommended!1 point
-
Hi. I'm native Spanish speaker (from Argentina) and I'd like contribute to Jacmaes's translations or make a new one for Latin America. I like the idea to have a "formal" translation for an admin. When I say "formal", I mean use "usted" instead "vos" or "tu", but I'd want to know what is the opinion Ryan about that. BTW, I would like to take this opportunity to thank to him this fantastic CMS. I've not done any site using PW yet, but I realize its potential, so I want to express my deep adminiration for his great work. Going back to the translation subject, I would need some advices or tell me what I should do to make a new Spanish version. I've started translating what Jacmaes did into Control Panel of PW. Am I in a good path? Thanks in advance. Best regards Fernando1 point
-
Try to use add start=0 to your selector so it looks like this: $positionen = $pages->find("template=tabelle_position, limit=10, start=0");1 point
-
Finally merged some updated from Teppo - thanks! Now includes multisite support: http://modules.processwire.com/modules/markup-sitemap-xml/1 point
-
1 point
-
A newly released CSS library from the folks at Yahoo!: http://purecss.io/ There already are a gazillion out there but this does seem like a pretty neat CSS baseline for some projects.1 point
-
thanks Soma, I have had this already in my BookmarkList from another Post where you have pointed to it! But with this site I want to restrict direct access to images under site/assets/.. to only allow thumbnails (via .htaccess) and therefor I have to write some extra code and I choosed this method because I allready know it. (lazy me) Oh, thats fine to hear. Makes things easy! Hhm, I have read some notices from when I have created the old site with prototype and scriptaculous. There was some weird things with doctype-interpretion by some MS-IE (7 or maybe 8, what was the brand-new one;-) Also if I have had some kind of valid XHTML it wasn't right interpreted by IE and it results in choosing the Quirksmode, what wasn't supported by prototype when trying to get width and height of viewport. That was a lot of headache and I haven't really understood that, only knowing it was some kind of IE-bug because the doctype starts with <?xml <?xml version="1.0" encoding="windows-1252"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de"> And to use crossbrowser check if a resize event is available for window or for document was to support old browsers. So, with my new site I only support IE8 or newer browser and doctype is HTML5 And therefor I can use jQuery syntax: var resizeTimer; function sendViewportDimensions() { // test console.log($(window).width() + ' x ' + $(window).height()); } $(document).ready(function() { sendViewportDimensions(); $(window).resize(function() { window.clearTimeout(resizeTimer); resizeTimer = window.setTimeout('sendViewportDimensions()', 250); }); }); Also have learned something new here: When hooking into window.resize event, it could be better to use a small timeout before sending ajax-request. Without it I have had 10 requests when only do one manual window resize.1 point
-
If you want to translate text, labels and stuff you can do this by wrapping your texts like: <?php echo __("String to be translated."); Read more on this page how to work this out in the backend. Translating files is really easy!1 point
-
Dear Ryan, > Now if the page pointed to by "custom_template_file" is hidden, that doesn't matter, because that's a page you are using to match, > not one of the pages being returned by find(). I think I understand the above. The find command is finding pages that are not hidden: it's just the selector values that are hidden, but I'm not trying to display those hidden selectors; I'm just using them to match non-hidden pages. In any case, the selector values won't be accessible as pages, so that's good. Thanks for your help on this. Peter1 point
-
Works great for me–awesome tool Soma! I have added a note about it to our download page: http://processwire.com/download/ It looks like the domain forwarding service I'm using (Namecheap) won't let me add redirects for anything other than www and @. So I can't add a dev download just yet. But I'll plan to add a dev.grab.pw or grab.pw/dev once I move the DNS.1 point
-
This is the way to create template and fields with API: // new fieldgroup $fg = new Fieldgroup(); $fg->name = 'new-template'; $fg->add($this->fields->get('title')); // needed title field $fg->save(); // new template using the fieldgroup $t = new Template(); $t->name = 'new-template'; $t->fieldgroup = $fg; // add the fieldgroup $t->noChildren = 1; $t->save(); // add one more field, attributes depending on fieldtype $f = new Field(); // create new field object $f->type = $this->modules->get("FieldtypeFloat"); // get a field type $f->name = 'price'; $f->precision = 2; $f->label = 'Price of the product'; $f->save(); // save the field $fg->add($f); // add field to fieldgroup $fg->save(); // save fieldgroup All pretty much standard OO one can figure out looking at core and PW modules. But not someone unexperienced would figure out by themself. I think at some point we need to cover these in a documentation.1 point