Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/13/2012 in all areas

  1. Few things that are "nice to know" when building PW modules: Autoload and non-autoload modules: autoload ones are loaded on every page load. So if you need to hook into core, then you probably need autoload. Non-autoload modules are run only by request: $modules->get("myUberModule")->doSomething() When you need hooks? Well.. common things are "do something when page is saved", "alter the output that is generated", "do something before page is accessed" etc.. Actually there is quite a many hooks and best way to find right hook for you need is to ask for it here. Building modules is pretty similar to working with templates. Nothing "special" there. Few notes though: You cannot directly access the PW API variables like $pages, $session, $input etc.. Those are available at $this->pages or wire('pages'). If you have static method(s) in your modules then you need wire('pages') there - so if you want to play it safe always use that (it works on command line scripts also) Modules can have settings - those are very easy to implement (just look examples from other modules that have settings) Modules are cool. init() is run before page is loaded, so if your autoload module needs to know the current page, that is available at ready() method. Forums is your friend, just ask and someone (probably Soma with his quick editing skills) will surely help.
    5 points
  2. Some recent additions for 2.3 that are now in the dev branch (I could use help testing if anyone has time): Added "required" support to all fields I've enabled required field support for all fields in ProcessWire (no need for advanced mode either). Now you get a "required" checkbox on the "input" tab of any field in Setup > Fields > [field]. If you are dealing with a published page and save it, you'll get an error if any required fields are blank. The page will still be saved. So it's more of something to annoy you into completing the required field. But if you are dealing with an unpublished page, it won't let you publish it (in the page editor) until you complete all required fields. While seemingly a small thing, the scope is more broad than it sounds as it applies to a lot of different Inputfields. I could use help testing this one out to make sure I haven't missed anything or introduced any new side effects or issues anywhere in ProcessWire. Other additions Fieldsets can now take advantage of column widths, enabling you to have multiple fields in a column. Fixed some bugs that occurred with fieldsets in tabs and fields getting brought into fieldsets they weren't supposed to. Add Interrobang's PHPdoc comments. Add ability to disable PW from throwing an exception when you call an unknown method (for porl's Twig module and other future ones like it). Clean up and optimize the /wire/templates-admin/styles/inputfields.css - it had some redundancy before. Also added a style to call out required fields. Other admin themes may want to do something similar (see the InputfieldStateRequired style in that file). Some other small things in the commit log (Apr 07-Apr 12)
    3 points
  3. @apeisa: yeah, well, MediaWiki takes some getting used to.. once you "get it" you'll realize that it's super powerful (but still rather confusing at times.) Wikipedia is actually using a newer, cleaner and much easier text editor these days. It has most of the basic formatting you'll need (such as different headings, lists, refs, tables and blockquotes etc.) implemented in an easy-to-understand way. Might be worth taking a look at, perhaps we could have that one too. Edit: the text editor that Wikipedia currently uses can be found from here: http://www.mediawiki.org/wiki/Extension:WikiEditor.
    2 points
  4. @Gazley, to answer your original question: I don't think that there are too many proper tutorials on module development available. At least I haven't seen any, so please, someone correct me if I'm wrong There has been some talk about proper module development documentation and/or tutorial though, see this topic for an instance. In my humble opinion that's something the community definitely needs at some point, preferably rather soon, because (IMHO) asking the same questions over and over or trying to dig all the tips from dozens, hundreds or even thousands of posts is not very efficient in the long run. Of course many of us like to learn from examples, but I'd still prefer to have common guidelines, frequent questions / problems, basic components and things like that explained in one place -- this would make it much easier for new folks to get into PW module development. Anyway, once you've managed to grasp basics of module development, why don't you share your tips for others too? wiki.processwire.com would be a great place for such content.
    2 points
  5. Hi Gazley, I think you're doing it the right way by looking at other modules. I'm still new to ProcessWire and just built my first module, will continue to improve it. After reading the docs, I started looking at modules in wire/modules and also downloaded some modules already developed by the pro's ;-) What helps me a lot is to look at the extended classes and implemented interfaces. The code there is pretty well commented! So for example, check out extended classes like "WireData" (Data.php in the core directory), "Wire" and the implemented interfaces. A lot of the magic happens there I still have to learn a lot more about Pw, but once you understand how it works... it is really fun coding and building a module, because the architecture of Pw is amazing!
    2 points
  6. We'll use this thread to discuss PW 2.3 features as they are being worked on. I've just added one of the first components. This is the "Page Path History" module. It's now in the PW core as a beta module (uninstalled by default). If you are interested in helping to test, just install the module from Admin > Modules > Page > Page Path History (after doing 'Check for new Modules'). The Page Path History module keeps track of the previous URLs for any pages that have been moved or renamed. It then sets up automatic redirects (301, permanent) to ensure the old URLs redirect to the new ones. This is best demonstrated by a few examples: Lets say you had the page /about/contact/ and you moved it to /contact/. With the Page Path History module installed, anyone accessing /about/contact/ will get redirected to /contact/. You had a page called /our-products/ and you renamed it to be /products/. Any accesses to /our-products/ will now get redirected to /products/. Those are simple examples, but this module can handle more complex situations too: Lets say you had the page /our-products/furniture/whoopie-cushion/ and you did like in the previous example and renamed /our-products/ to be /products/. The /our-products/furniture/whoopie-cushion/ URL will now redirect to /products/furniture/whoopie-cushion/ Later on you decide to rename /products/ to just /inventory/. All the /our-products/ and /products/ URLs will continue to work with redirects. You decide that whoopie-cushion really belongs in /services/ rather than /inventory/, so you drag it to /services/whoopie-cushion/. It's old URL in /inventory/furniture/whoopie-cushion/ redirects to it's new URL. TL;DR (am I doing this right) -- you can move or rename any pages and all the old URLs will redirect to the new, automated behind the scenes, without any thinking on your part.
    1 point
  7. Hi there, Whilst creating a very simple Module, I found myself looking at other Modules and wondering why certain things were done in certain ways. I also, saw comments about methods with triple underlines and being to hook and pre-hook Page methods and after my head stopped spinning, I wondered whether there is a tutorial anywhere about this whole thing If its just a case of doing and asking, that's fair enough. However, there are a fair few tutorials on most areas of the system but I couldn't find anything around Modules. Please let me know if there's something I'm missing. Many thanks!
    1 point
  8. Thanks guys! Funny stuff I just realized that after the last change I did, that I forgot to add something when there's no cookie set (so first time visit), must been distracted. Well I know I should have tested but didn't. So thanks for mention it guys. It's now fixed. Not sure about loading time, but the images (pngs) are already as optimized, and as small as it can get. I'm not sure it really was what you Pete experienced, though as you mention I wanted to implement a preloaded but was holding me back. Think it's time to implement it. You're right the ctrl+1 might causing issues to show the slider (which also depends ont he browser but you'll have an regular textfield and it works. Nothing too serious just having fun as I always do. I might set the combo to alt+ctrl+1 or something? And there's nothing wrong it shows underneath the header, haven't really put much thoughts into it, it was still there from the beginning. The animation was fun to do. I used Cinema4D to build a puppet using body parts (like a billboard) and animated through inverse kinematic, so just rotating the foots around the pedals and the rest will follow. So rendering every frame out as pictures, dada I got the sprite animation, which was really rewarding seeing it work. The parallax background was done by creating layers in photoshop and made them tileable, which took a little time to find the right fotos and bits to make it work and not look too strange. I love this forum! Hehe, have also tried -20000?
    1 point
  9. Okay, it's installed now and makes editing the wiki MUCH easier.
    1 point
  10. Wow, if I'd have known that was around back in 2010 teppo I'd have installed it on the other MediaWiki site I maintain - the mind boggles as to why they don't include things like that in the core distribution as for a wiki that would surely increase participation by a huge amount, or at the very least aid in terms of legibility I'll look at installing that one soon. EDIT: hang on, it is in the core by default, must just not be switched on by default which is slightly odd.
    1 point
  11. I thought I was going mad as I've looked at this site a few times the last few days from a couple of different machines but I don't see a header animation: But then I realised that it just took ages to load for me The problem is that until it loads, the site looks like the above. Is there any way to have a loading graphic or something to prop the page open? My only worry is that until it loads, it looked broken to me and might do to others. Only other issue is that whilst pressing CTRL + 1 opens up the slider in Chrome, it switches to your first open tab in FF and sticks in a nasty input field under the animation on your site, which I don't think is intended either. It's awesome typing 200 into that field though as he rides like a maniac then Increase it to 20000 and he starts cycling so fast the scenery moves backwards 20000000 and he cycles on the spot! Other than that, the animation is awesome - great work! I've not seen something this good before that wasn't Flash-based and it's top quality stuff
    1 point
  12. Didn't understood about the animation you were talking about first. For me there is "close" button visible, clicking close makes the white header a bigger. Clicking "open" makes it smaller. Only after reload the animation is visible. (Chrome / Win7). Happened twice (at work and now at home too). Now that I see it, I agree: animation is super cool!
    1 point
  13. Thanks apeisa, this makes a lot more sense - and will also let me set the display order of projects within each category. I appreciate your help on this, as well as your work on the module!
    1 point
  14. No probs - just wasn't sure you'd seen that page yet and it helps to include the link to explain it for others who might have similar questions. The best way probably is to see if there's a module that does something similar to what you want and take a look at the code. The triple-underscore thing is literally just for hooking - I don't think there is anything else like that that springs to mind - most of the things you might do in your module are going to be a mix of regular PHP and the API. If you explain what you're trying to do we might be able to give more specific help, but your last question is a little broad as it depends on what your module is doing - since a module can do pretty much anything you can think of (within the confines of what it's actually possible to code in PHP) then there's no easy answer to that one
    1 point
  15. I would probably do it other way around: I would choose projects from categories. Usually I would do otherwise, but since your projects is just a "data reporsity" and categories are on different domains that would make more sense for me). But that is just a matter of preference.
    1 point
  16. Not totally sure what you are looking for. Your page structure looks just fine for me. If I follow you correctly you choose categories from project page, and then you want to show those projects in different domains? Something like this should work: Create a new template called "view_project" Add page called "project" under each your sites and give those pages a template "view_project" Allow urlSegments for your view_project template And code that goes into your view_project template should be something like this (written in browser): <?php if ($input->urlSegment1) { $projectName = $sanitizer->pageName($input->urlSegment1); $project = $pages->get("parent=/projects/, name=$projectName"); echo "<h1>$project->title</h1>"; // Or just echo $project->render(); } else { echo "No project found"; } And when linking to your projects you should use urls like these: www.site1.com/project/projectname/
    1 point
  17. I remember seeing this somewhere, should be possible to implement with the GA api. Will be there in the next version I think another module option to define the default date range makes sense. Currently, this is always a month back from "today". I will add a dropdown one can choose the the date range (24 hours, 2 days, 3 days... 1 week, 2 weeks etc.) Thank you for testing, glad it turned out to be this simple! ;-) Will add the check in the next version. One quick fix for you is to visit the site with your mobile phone
    1 point
  18. Hehe, not strange that's what we all do sometimes. Glad you like it, I also watched it for hours I think. PS: Don't tell anybody, I activated my, during developement, present and made an eastern egg. Press ctrl+1 Not sure it works in every browser/system though.
    1 point
  19. The ProcessWire equivalent of the suggested code that I just added to StrategyCore is: <meta name="generator" content="ProcessWire <?php echo $config->version ; ?>" /> <!-- This website is powered by ProcessWire ProcessWire is a free open source Content Management System created by Ryan Cramer and licensed under the GNU/GPL. ProcessWire is copyright <?php echo date('Y', time()); ?> by Ryan Cramer. Modules are copyright of their respective owners. More information can be found at http://www.processwire.com --> There's a bit of PHP in there to always show the latest PW version that's running, as well as the current year in the copyright line. @ryan - would you suggest any changes to that?
    1 point
  20. Not sure what exactly you're doing but you could create a modules that is autoloaded and provides functions to use everywhere in PW. Something like this: class HelpersModule extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Helper Functions', 'version' => 100, 'summary' => '', 'href' => '', 'singular' => true, 'autoload' => true ); } public function init() { $this->setFuel("helpers", $this); } public function getPosts() { return wire("pages")->get("/posts/")->children(); } } Then you can do in your templates: $posts = $helpers->getPosts(); There's variations of this but it should be simple to do. Also you could also make it not autoload and load it on demand. $helpers = $modules->get("HelpersModule"); // load module $posts = $helpers->getPosts(); Edit: wow everytime I edit the post the indentation get lost, that's new to me and pretty annoying...
    1 point
  21. Good idea. I will plan to add this to the default profile too and we can recommend that people include the generator tag in their own sites...perhaps as a prerequisite to being listed in the upcoming PW site directory? This would make sense so that if the generator tag ever changes we know the site is probably not running PW anymore and shouldn't be linked from the directory.
    1 point
  22. 1 point
  23. MacOSX Github App first steps Since ProcessWire modules directory supports and encourages you to use github for publishing modules and third-party content here's a little help getting started with github for mac. Go and install the app for mac here http://mac.github.com/ You'll have to first create a github account to where you can connect. Creating public repos is free, on top you'll see a "Free for open source" and a small button. https://github.com/plans Login in from your newly installed github app. Create new local repository by simply dragging the folder (your module) right into the app. The folder can be anywhere on your computer, maybe you choose to use the github folder automaticly created under ~user folder, or you decide. After you added it to github you'll see added a ".git" folder in your local repositiory. Now you'll see your files added in the app. Maybe you'll see the annoying ".DS_Store" file in there too. To ignore files simply right click on them and select "ignore". It will get added to the .gitignore file which now also appears in the files. Do the same and ignore it too. Now push the newly created repo to github using the button top right "Push to github". You'll be asked to enter a title and description then you can push it. It now will appear on github, but still empty. Now make your first initial commit, add a description i.e. "inital commit" and press "Commit" button. You'll see it add's a "Unsynced Commits" panel underneath. Press the button on top right "Publish branch" button and it will push it to the remote repository. You should now be able to see the files commited on your github page. On the repository page you'll see a "ZIP" download button. You can use that url to enter in the download field for the module when you add it to http://modules.processwire.com. Once you update the module, you have to enter a new version both in the module getModuleInfo() and on the module page. This makes sure people, also some apps using the webservice, know it is new and can update it. Screencats The following is a short screencats (no audio) showing me adding a new repositiory to github and update it using the mac github app. Screencast using MacGithubApp
    1 point
  24. That's the ticket. Thanks Ryan. You've probably written the equivalent of a Steven King novel by now just answering the questions of people like me. I hope you never get tired of it. It's appreciated.
    1 point
  25. Something along those lines would be fantastic. Regards Marty
    1 point
  26. Unpublished are excluded by default. Just add "include=all" to have hidden and unpublished to show up also. http://processwire.com/api/cheatsheet/ (advanced mode). EDIT: remember though that selectors doesn't check access after that. Even the pages where user doesn't have view access are included.
    1 point
×
×
  • Create New...