Leaderboard
Popular Content
Showing content with the highest reputation on 08/31/2013 in all areas
-
Phone Number Fieldtype A new fieldtype to enter phone numbers with 4 integer values for country, area code, number and extension and format the output based on predefined or custom options. StyledOutput The most common usage option will be: echo $page->fieldname //eg. +1 (123) 456-7890 x123 This provides a fully formatted phone number, based on the output format chosen from module's configuration page, or with the format override option (if enabled), when entering a phone number on a page. This is a shortcut that produces the same output as: echo $page->fieldname->formattedNumber //eg. +1 (123) 456-7890 x123 Alternate styled options are: echo $page->fieldname->formattedNumberNoExt: //eg. +1 (123) 456-7890 echo $page->fieldname->formattedNumberNoCtry: //eg. (123) 456-7890 x123 echo $page->fieldname->formattedNumberNoCtryNoExt: //eg. (123) 456-7890 echo $page->fieldname->unformattedNumber: //eg. 11234567890123 echo $page->fieldname->unformattedNumberNoExt: //eg. 11234567890 echo $page->fieldname->unformattedNumberNoCtry: //eg. 1234567890123 echo $page->fieldname->unformattedNumberNoCtryNoExt: //eg. 1234567890 Of course the actual output is determined by the selected format output Raw Output You can output the values for the component parts of the phone number like this: echo $page->fieldname->country; echo $page->fieldname->area_code; echo $page->fieldname->number; echo $page->fieldname->extension; Output for mobile compatibility To get iOS and other mobile platforms to recognize numbers and be able to automatically dial them, use something like this: echo '<a href="tel:+'.$page->fieldname->unformattedNumberNoExt.'">'.$page->fieldname->formattedNumber.'</a>'; Selectors for searching The component parts can be used in selectors like this: $pages->find("phone.area_code=123"); Field Settings There is a field settings for the width of the inputs in pixels. There is a field settings for the width of the inputs in pixels. You can also choose whether to display the country and extension fields for input. Off by default. There is an additional checkbox that determines whether there is an option to override the default format option on a per entry basis, which will be useful when styling phone numbers from different countries on the one website. Off by default. Custom formatting options On the module's configuration page you can choose from predefined formats, or create custom formats using syntax like this: {+[phoneCountry] }{([phoneAreaCode]) }{[phoneNumber,0,3]-}{[phoneNumber,3,4]}{ x[phoneExtension]} which generates: +1 (123) 456-7890 x123 Each component is surrounded by { } The names of the component parts are surrounded by [ ] Two comma separated numbers after the component name are used to get certain parts of the number using php's substr function, allowing for complete flexibility. Anything outside the [ ] is used directly: +,-,(,),x, spaces, etc - whatever every you want to use. There are lots of complicated rules around numbers changing when dialed from different locations. A simple example is for Australia. When dialing from within Australia, area codes start with a 0, but when dialing from another country, the 0 must be omitted. You can write a simple format to handle this. The following truncates the first number from an Australian two digit area code: {+[phoneCountry] }{([phoneAreaCode,1,1]) }{[phoneNumber,0,4] }{ [phoneNumber,4,4]}{ x[phoneExtension]} which generates: +1 (7) 1234 5678 x123 even though the full "07" is stored in the area code field. Where to get Available from github: https://github.com/adrianbj/FieldtypePhone And the modules directory: http://modules.processwire.com/modules/fieldtype-phone/ To Do Need to increase the number of pre-defined formats. There seem to be so many options and no real standards, so I thought rather than create a huge list of options that no-one will use, I thought I'd wait and get you guys to contribute them as you need them. Either post your formats here, or send me a PR on github and I'll add them. How to install Download and place the module folder named "FieldtypePhone" in: /site/modules/ In the admin control panel, go to Modules. At the bottom of the screen, click the "Check for New Modules" button. Now scroll to the FieldtypePhone module and click "Install". The required InputfieldPhone will get installed automatically. Create a new Field with the new "Phone" Fieldtype. Choose a Phone Output Format from the details tab. Acknowledgments This module uses code from Soma's DimensionFieldtype and the core FieldtypeDatetime module - thanks guys for making it so easy.7 points
-
Just checked: 119 870 is the magic number today4 points
-
I've gone ahead and committed the Inputfield dependencies to the dev branch, for anyone that would like to help test. I've also posted a documentation page that explains how and where to use them, current limitations and examples. There are a near infinite number of potential scenarios on how these things could be used, so it's not possible for me to test everything locally. As a result, expect bugs and please report them when you find them. Thanks in advance for your help in testing. For non-default admin themes, some updates have to be made in order to support field dependencies. As a result, unless you are an admin theme developer, it's best to stick to the default admin theme when using field dependencies, temporarily. Field dependencies can also be used in FormBuilder. Though I've not done a lot of testing in FormBuilder yet, so don't recommend using field dependencies in front-end production forms just yet. Though in my initial testing, they seem to work just fine. Thanks again to Antti/Avoine for sponsoring field dependencies!2 points
-
Dear Antti, I tried your suggestion, and it worked. So, I settled on this code: if ( $page->rootParent->url == "/members/" && ! $config->https ) { $httpsUrl = str_replace("http", "https", $page->httpUrl); $session->redirect($httpsUrl); } elseif ( $page->rootParent->url != "/members/" && $config->https ) { $httpUrl = str_replace("https", "http", $page->httpUrl); $session->redirect($httpUrl); } else { # do nothing } It seems to do exactly what .htaccess mod_rewrite would do, if I'm not mistaken. And because, after the first redirect, the SSL status is active, there aren't redirects on every page load, since the links are relative. It would be academically interesting to see how this would be done in .htaccess, but for now... problem solved! Thank you once again! Brilliant, brilliant. Peter1 point
-
Ok, apparently I wasn't looking in the right area. (Obviously, I don't know much about mod_security.) I ended up contacting Liquidweb and they helped me solve it. It was a matter of whitelisting some mod_security rules. Thanks for your input, fellas!1 point
-
Dear SiNNut, > There's certainly nothing wrong with it but why do you use this form for internet forum postings? Seems a bit redundant and overly polite to be honest. That's a question I've never been asked! (Of course, I'm well aware that my method of salutation is now "old-fashioned.") So, let's see. I'll be 59 in two weeks, and have been a writer for a long, long time. I still remember when people wrote letters on *gasp* -- *paper*... Pop Quiz: what is "whiteout"? From "Dear Sir", "Dear Friend" and "Dear Billy Bob", to "Hi", and then not even "Hi", there has been a rapid Net-driven descent into what I feel is a far more impersonal method of communication. I don't want to become an anachronism in the Internet age, but I feel that with the massive change in communication that has even reached the point of using shorthand for words, such as 'u' for 'you', the beauty of language and the importance of courtesy are in danger of being discarded. You see it on TV all the time. Someone will be talking on the phone and then hang up without saying, "Bye." I always think, "Those lazy script writers are destroying etiquette." Digging deeper, it's not just courtesy and etiquette that are important, but the underlying qualities of personal care, respect, kindness and compassion that are communicated between people. Thus, I'm holding out as long as I can, treating email and forum posts the way I would a letter, working hard to put my finger in a dike that will probably give way anyway. I do agree that one liners might not need the whole "Dear" and "Yours" thing, but for notes of any length, I still like them. I hope being overly polite is not rude. Yours, Peter1 point
-
1 point
-
THen there's this $a->setTotal() $a->setLimit() $a->setStart() on page arrays we can use to configure built in MarkupPagerNav to work with merged page array in memory. Kind same as my above example but much simpler. /** * here is a example with using the built in pager * we can use $a->setTotal($n) to configure page array to work with pager */ // create new page array for storing pages $pa = new PageArray(); $res1 = $pages->find("template=mytemplate"); $res2 = $pages->find("template=house"); // import the found pages $pa->import($res1); $pa->import($res2); // configuration for pagination needed $limit = 10; $total = $pa->count(); $start = ($input->pageNum-1)*$limit; // example output with limited list we filter from the complete page array foreach($pa->filter("sort=-created, limit=$limit, start=$start") as $p){ echo "<p>$p->title</p>"; } // page array let's you set the parameters for pagination manually $pa->setLimit($limit); $pa->setTotal($total); $pa->setStart($start); // now the renderPager() on the page array works as usual echo $pa->renderPager(); Added this to the previous gist snippet here https://gist.github.com/somatonic/5420536#file-paginator_manual-php1 point
-
Unfortunately there is no easy answer on how to give something back for such a brilliant piece of open source software. To be honest, though I don't know the context in which Ryan that this about donations, I can understand his position. Receiving donations is something completely different compared to getting paid for your hard work ... I'm benefiting commercially from PW and my clients do as well (I always point this out by the way when it comes to price discussions - most clients don't waste thoughts on where the software is coming from and why it is free for them. They think it's "just there".). So, if it comes to forms I make form builder module mandatory and currently I'm thinking about making cache module mandatory with every new project too. But this will hardly be enough for Ryan to make a living from. Hmm, could we make a foundation, that lives from donations and that acts as sponsor for new modules which are developed by Ryan? Say, everybody who uses PW commercially contributes with a certain percentage of the project budget to the foundation and the foundation in return pays Ryan a good price for new modules. Would this work? As I said, I have no final solution. But I can say that I would be willing to contribute with money. Whether it's by paying for modules or by becoming a contributor to the PW foundation.1 point
-
1 point
-
1 point
-
A customer wanted to disable save ( $config->demo ) for users with a specific role. I created a module for that. If you need it, it's over here. To select the role(s), go to the modules config settings. download at github1 point
-
in file or image properties, isn't there now a $file->httpUrl or $image->httpUrl1 point
-
Hi Henning, I think you have the wrong param for opacity. PHP.net says: function imagecolorallocatealpha param alpha: A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent. Please try with child->image2->pimLoad('wh', true)->canvas(195, 193, array(0, 0, 0, 127), "centered", 0)->pimSave()->url; EDIT: @Henning: I have noticed that the common way to define a rgba color is 0-255 for R, G and B and a float value between 0 and 1 for the alpha channel (opacity). 0 is transparent and 1 is opaque. I think it is better to use the common way with float 0-1 as param and convert it internally to suite the need of the GD-lib. The change will go into the module version 0.0.8 and I will release it later this weekend.1 point
-
You can provide a javascript variable to the javascript file by setting it in a <script> tag before including it. Like this: <style> var myXmlPage ='<?php echo $xmlPage->url; ?>'; <style> <script type="text/javascript" src="<?php echo $config->urls->templates?>scripts/main.js"></script> If you plan to provide more variables, you can create an object, so you don't overpopulate your global scope. <script> var myVariables = { xmlPage: '<?php echo $xmlPage->url; ?>', xmlPageTitle: '<?php echo $xmlPage->title; ?>' }; </script>1 point
-
1 point
-
Good idea. One way to go would be to post those code snippets to Gist (https://gist.github.com/) and build the snippet repo on top of that. They would be tied to github account, so it would nicely show all the modules and snippets build be same author.1 point