Leaderboard
Popular Content
Showing content with the highest reputation on 08/14/2012 in all areas
-
Here's a start on creating modules documentation. I still need to write a whole section on hooks, but it's fairly complete in other areas. Please feel free to edit/add to this. http://wiki.processwire.com/index.php/Module_Creation6 points
-
Hello there! I'm on day #2 of a Ruby/Ruby on Rails course. I've been sent on it by my employer who has decided to adopt Rails going forward. I quite like Ruby, but Rails, well I'm not sure about it at all. The whole experience has left me feeling very happy with PHP and amazed at what you can do with ProcessWire by comparison to some of the nonsense I've been working with in Rails. There are many really good MVC frameworks available in PHP so Rails's MVC has no particular advantage in 2012. PHP has some tremendous OOP capabilities in 5.3/5.4 so I don't see Ruby having any particular advantage over PHP either, unless of course, you are a Ruby developer who doesn't know PHP! So, no big deal but I thought I'd share this with you. Cheers!3 points
-
Just commited version 1.1.1 Fixed PHP notices when debug mode is enabled (thanks Sevarf2!) If no results are returned from GA, display "no results found" Added module config option for a default date range: last 24 hours, last 2 days, last 3 days etc. If you want to look back more than 2 months by default, tell me... i'll add more values Traffic Sources: Added Referral Sources by URL. Provides also a link to visit the referral page, but as Ryan mentioned earlier, sometimes uri-variables are stripped resulting in invalid links! When you set a custom date range in the options section, you are "overwriting" the default date range. This can still be handy, for example if you want to look quickly at statistics from the past. Reset the custom date range to display stats again from the default one.3 points
-
I figured as much. I just thought you guys we're using an easier technique because most sources I've seen around are perfectly indented. Thanks! I'm new to processwire, barely 3weeks, and yet I've already used it for two websites. The only thing I love more than how powerful this CMS is, is how helpful and friendly the community is. I'll be sticking around for sure, and try to help whenever I can!2 points
-
How about Atlanta at Piedmont Park: ProcessWire BeerBQ 2012… 8) on second thought, I think I'm the only one in all of Georgia using ProcessWire. I need to change that, but something called "Word Press" (?) is the buzzword around here.2 points
-
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.2 points
-
I found (after 2-3 Projects using PW) that it's a good technique to use templates in a way I think hasn't been thought of yet really by some. (Although the CMS we use at work for year, works this way.) I'm sure I'm maybe wrong and someone else is already doing something similar. But I wanted to share this for everybody, just to show alternative way of using the brillant system that PW is. Delegate Template approach I tend to do a setup like this: - I create a main.php with the main html markup, no includes. So the whole html structure is there. - I then create page templates in PW without a file associated. I just name them let's say: basic-page, blog-entry, news-entry... but there's no basic-page.php actually. - Then after creating the template I make it use the "main" as alternative under "Advanced" settings tab. So it's using the main.php as the template file. - This allows to use all templates having the same php master template "main.php" - Then I create a folder and call it something like "/site/templates/view/", in which I create the inc files for the different template types. So there would be a basic-page.inc, blog-entry.inc ... - Then in the main.php template file I use following code to delegate what .inc should be included depending on the name of the template the page requested has. Using the TemplateFile functions you can use the render method, and assign variables to give to the inc explicitly, or you could also use just regular php include() technic. <?php /* * template views depending on template name * using TemplateFile method of PW */ // delegate render view template file // all page templates use "main.php" as alternative template file if( $page->template ) { $t = new TemplateFile($config->paths->templates . "view/{$page->template}.inc"); //$t->set("arr1", $somevar); echo $t->render(); } <?php /* * template views depending on template name * using regular php include */ if( $page->template ) { include($config->paths->templates . "view/{$page->template}.inc"); } I chosen this approach mainly because I hate splitting up the "main" template with head.inc and foot.inc etc. although I was also using this quite a lot, I like the delegate approach better. Having only one main.php which contains the complete html structure makes it easier for me to see/control whats going on. Hope this will be useful to someone. Cheers1 point
-
Your client might transmit a false mime-type. Can this yield trouble? And he may lie to you - unconscious. Maybe he tries to upload a link rather than the actual image. Just an example. Another idea. The real images are really big - to big. And his mail client is nice enough to scale them down if he he send them to you.1 point
-
SiNNut - you are quite right, it's a totally bogus "Apple and Oranges" comparison. I guess the real comparison is down to this; I've heard about how magical RoR is, I've been using it on the course and you know what - I'm totally underwhelmed, despite the all the hype and all of the resource and community around its development over the past 6-8 years or so. By accident, I stumbled on ProcessWire that has been, from what I understand, largely the results of one person combined with the help of an enthusiastic, yet relatively small community by comparison to that belonging to RoR. When I started to look at PW, I was amazed at how well thought out it is, how well architected it is, how easy to use it is, and how powerful it is. I immediately got that "giddy" feeling when you know you've stumbled onto something amazing. I just didn't get that buzz or excitement about RoR despite having heard for years about how good it is and how it's better since V3.1 point
-
RoR was really big a few years back with a lot of hosting companies scrambling to support it on their servers - presumably to cash in on the craze. I've just not seen much done with it though. If someone asks you to code in it and you're trying to get back to the safety and comfort of PHP, it's always handy to be able to say things like "Google and Facebook both use PHP and look what they can do". Obviously it you're talking to a client who's part of a large organisation, half their staff may be on Facebook most of the time so probably best not to mention that one and stick with Google as the example1 point
-
I think it might just be a matter of how it's described in the field setup. It originally started out as just a toggle: "single image" or "multiple images". But it was such a small stretch to make it also behave as a max files quantity, that it went there instead. And I think that may have been the mistake, because the max files quantity is serving two purposes rather than one. But the solution is pretty simple. It would be relatively easy for me to just add another Inputfield to the configuration that says: "Do you want this field to behave as a • single image or • multiple images?" And it would just be a symbolic front to the max-images setting, that hides the multi-purpose nature of it. While there might be some benefits to having it split out into two separate fieldtypes, there are also great benefits to having it as one. It always behaves as a multi-file field when output formatting is off, so any modules written for files/images automatically support both single and multi-file versions (with no effort). If these were split up as different fieldtypes, it would be more to maintain and people would have to potentially get a lot more code involved when writing anything to do with files/images.1 point
-
Thanks for your efforts Ryan! I'm so amazed with this community, your good self and ProcessWire1 point
-
Why not always returning an array? Don't know how it actually looks like but I think like this: imageField[0]['url'] = 'path/to/image1.jpg' imageField[0]['description'] = 'description1' imageField[1]['url'] = 'path/to/image2.jpg' imageField[1]['description'] = 'description2' and in case of a single image: imageField['url'] = 'path/to/image1.jpg' imageField['description'] = 'description1' right so far? Why not turn this field into an array like: imageField['url'] = 'path/to/image1.jpg' imageField['description'] = 'description1' imageField[0]['url'] = 'path/to/image1.jpg' imageField[0]['description'] = 'description1' imageField[1]['url'] = 'path/to/image2.jpg' imageField[1]['description'] = 'description2' or if only one image: imageField['url'] = 'path/to/image1.jpg' imageField['description'] = 'description1' imageField[0]['url'] = 'path/to/image1.jpg' imageField[0]['description'] = 'description1' so both, imageField->url and imageField->eq(0)->url will work and backwards compatibility will remain? Am I overseeing something in my lack of PHP? :-1 point
-
Well, you're right, I don't get it. I'm learning though. Thanks for pointing that out. You have to admit, your post above was a bit on the cryptic side for someone who's not fluent like me. I get it now though. Thanks for everyone's efforts. It was another learning experience at least.1 point
-
1 point
-
1 point
-
Well, if a conference doesn't happen, for whatever reason, a get together is still a nice idea even on a smaller scale. Pick a park, get some potato salad, I'll bring the hot dogs and beer.1 point
-
Hi there, I'm starting to see groups of fields that might be optional in a template but may well make sense being included in other templates. So, re-usable field groups, if you like. After having made great use of repeaters so far, I know that as a concept, I could achieve this reusability with a repeater. However, semantically, this is wrong because the data doesn't repeat in a single template. Is there a recommended way to achieve this? Many thanks!1 point
-
Perhaps a more simple solution is modifying the repeater code to make the 'repeating' functionality switchable. By this I mean it would become a more general 'field group' module with the option that the fields can be repeatable (even if this is set by default). It would also be nice to have a way to hide the fields inside from the general field list to keep things tidy.1 point
-
I like the idea of field groups, but perhaps in another approach: Grouping them in the fields overview. On more complex sites I have 30-40 fields which I group by adding prefixes to them like contact_address, contact_person and so on. But it would be nice to define a field group "contact" and sort the field there (collapsible and tabbable perhaps?). Then the possibility to clone whole groups would be ... wait for it ... legendary ;-)1 point
-
Depends on how you define the "maximum files allowed" in the "input" tab of the image field. If you allow more than 1 image, PW returns an array of images, regardless of the effective quantity. So in your code you should have: foreach($page->get("product") as $item) { if (count ($item->product_shot) > 1) { echo "<div class='productcontainer'><div class='prodpic'><a class='nowandthen'><img src='{$item->product_shot->first()->url}' alt='{$item->product_shot->first()->description}'> <img src='{$item->product_shot->first()->url}' alt='{$item->product_shot->first()->description}'></a></div>\n<div class='prodtext'><h2>{$item->product_name}</h2>\n{$item->product_description}</div></div>"; } else { echo "<div class='productcontainer'><div class='prodpic'><img src='{$item->product_shot->first()->url}' alt='{$item->product_shot->first()->description}'></div> \n<div class='prodtext'><h2>{$item->product_name}</h2>\n{$item->product_description}</div></div>\n"; } } If you only want to have one image per (repeater-) field it is better to determine "1" as maximum in the field input settings. Because as a nice side effect, the existing image will be overwritten when you drag a new one into that field, no need to trash it manually by clicking the trash icon. And then there is no array returned and your code should work without changes.1 point
-
1 point
-
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!1 point
-
I like to share a few code snippets to accelerate the delivery of fancybox content. Newer versions of fancybox might use css-sprites like ryan does for the images in the searchbox. For the sake of simplicity I use url-data to put all images in the css-file. (/wire/modules/Jquery/JqueryFancybox/JqueryFancybox.css) Despite the greater total size (base64 encoding) this is already a gain. With gzip compression the size will not even increase significant. Then a .htaccess should be used: <Files "*.css.gz"> ForceType text/css </Files> <Files "*.js.gz"> ForceType text/javascript </Files> <Files "*.gz"> AddEncoding gzip .gz </Files> Since IE less than IE8 don't support url-data I have a conditional comment in my template for them: <!--[if lt IE 8]> <style> #nav { height:38px; } </style> <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/urldata.css" /> <![endif]--> Of course I also changed the reference to the css-file: <link type="text/css" href="<?php echo $config->urls->modules?>Jquery/JqueryFancybox/JqueryFancybox.css.gz" rel="stylesheet" /> A change in the init-function of ModuleJs.php let's even the PW backend benefit of the compression. But that is optional. public function init() { $class = $this->className(); $info = $this->getModuleInfo(); $version = (int) $info['version']; if (is_file($this->config->paths->$class . "$class.css")) $this->config->styles->add($this->config->urls->$class . "$class.css" . ((is_file($this->config->paths->$class . "$class.css.gz"))? ".gz" : "") . "?v=$version"); if (is_file($this->config->paths->$class . "$class.js")) $this->config->scripts->add($this->config->urls->$class . "$class.js" . ((is_file($this->config->paths->$class . "$class.js.gz"))? ".gz" : "") . "?v=$version"); } urldata.css JqueryFancybox.css.gz1 point
-
Here's the next version of the Blog Profile. This one incorporates the simpler structure I mentioned earlier, exactly as outlined. Please let me know how it works for you. To install, download a fresh copy of ProcessWire and replace the /site-default/ directory it comes with, with the one in the attached zip: blog-site2.zip Thanks, Ryan1 point