Jump to content

Raymond Geerts

Members
  • Posts

    362
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Raymond Geerts

  1. Thanks kongondo for the link to github. Now i remember where i read it and why i couldnt find it on the forum Great news though that this will be in the core soon
  2. Is this something that is build in the core at this moment or in the future? Or is there a module that handles this? I vaguely recall somebody mentioning this, but since i can not find the discussion anymore i doubt if i'm right about that.
  3. Perhaps this will do the job (I havent tested it) $results = $pages->find("field01=X"); $amountField02A = count($results->find("field02=A")); $amountField02B = count($results->find("field02=B")); $amountField03Y = count($results->find("field03=Y")); $amountField03Z = count($results->find("field03=Z"));
  4. I'm not sure if you already are using setlocale somewhere, But you could try setting it like this: setlocale(LC_ALL, "de_DE.UTF-8"); instead of: setlocale(LC_ALL, "de_DE");
  5. You already have the code i see. Looks like a good solution. So method A is the right way to do so in this case. When you want to retreive a subset of data for example 4 pages out of 1000 records in the database i recommend sorting on database level (like you did in your code). This will be faster since the database fields all are indexed. And it saves you from loading the 1000 records in to memory and sorting it afterwards and then limiting. Because if you would limit it before sorting you never will get the right results.
  6. You can sort any WireArray with $a->sort("property") as shown in the API cheatsheet $a = your WireArray (or PageArray) property you can set to sort the array But you already have a $pages->find as far i understood, why not modify the selector of that and extend it with the get variable. This way you can sort on database level which is faster then getting the data from the database first and then sorting it afterwards.
  7. Previously Sublime Text 3, but i recently switched to Atom too A few years ago when still using windows i used to code with phpDesigner
  8. Wow looks very good and complete from what i can see in the screenshots. I'm not a blogger myself but i think many other people are, so this module can be very interesting to get some new people atrackted to ProcessWire.
  9. @soma, thanks for clearing that up. I'll stick with __("Phrase") way of setting the language strings and moved it from init() to ready(). Looks like everything works fine now. Since the module is intended to be a Frontend User Profile system users will be able to select a language that will be saved to the user profile (user template). As for a language switch for the guest user (at login and signup) i still need to figure out how i will set that up, but might just be possible with language switch, cookies or session and setting it for the guest user like this: if ($this->session->lang && $this->session->lang != 'default') { $this->user->language = $this->languages->get($this->session->lang); }
  10. @Martijn: Thanks that solved it! Altough its a bit confising to me because the file with the translation strings is directly included in the init() method of the module class. That made me think that it is inside the module scope. @Wanze: Just before martijn posted his solution i tried that (with $this->_('Save', $textdomain)), but i got a warning message saying "That file has no translatable phrases". Perhaps it will do fine with __('Save', $textdomain) I tried this (which gave the warning) $textdomain = ltrim ($this->config->urls->siteModules . 'MyModule/MyModule.module', '/'); /** * Gender */ $this->lang['Male'] = $this->_('Male', $textdomain); // Gender $this->lang['Female'] = $this->_('Female', $textdomain); // Gender Thanks guys for your help
  11. @horst thanks for the suggestion but it didnt make any difference. edit: It somehow looks like the translation strings are bound to the file and not accessable from somewhere else. Since when i move the statement to the main module file itself it works as expected. I might need to look in to Textdomains as described in the documentation
  12. Im building a module with many (25+) include files. Now i came up with the idea to have a central include file which contains all the language values so that i have one file that can be added for translation (instead of 25+). I have added (besides the default language) the following nl=Nederlands and de=Detusch languages. For testing i modified the guest user and set its language to de. The problem is when i look at the page that should have translated values it renders the default language only. Probably its the way i have set it up, but i can't think of another way to do it. I want to keep having only 1 central language file that i include once. The set up is somewhat like this: MyModule.module class MyModule extends WireData implements Module, ConfigurableModule { /** * Returns language array * * @return array */ private $lang = array(); /** * Returns gender type * * @static * @return array */ private static $gender = array(); /** * * Initialize the module */ public function init() { // Include all language variables @include_once (dirname(__FILE__) . '/language.inc'); self::$gender = array( 1 => $this->lang['Male'], // Gender 2 => $this->lang['Female'], // Gender ); } /** * Render Male * * @return string */ public function ___renderMale() { return $this->lang['Male']; } } language.inc /** * Gender */ $this->lang['Male'] = $this->_('Male'); // Gender $this->lang['Female'] = $this->_('Female'); // Gender And in my template file: $mymod = $modules->get('MyModule'); echo $user->name; echo "<br>"; echo $user->language->name; echo "<br>"; echo $mymod->renderMale(); This renders guest de Male While i would expect guest de Mann See the strange part is the current user is guest with de as selected language but it does not echo the german value of Male. The module consist of the following files:
  13. I dont see any reference to $user in here $p = new Page(); // delete this? or how to change? $p->of(false); // sets output formatting to false in order to change field values. $p->parent = $pages->get("/members"); $p->template = "member"; $p->profiel = $sanitizer->text($input->post->profiel); $p->contactnaam = $sanitizer->text($input->post->contactnaam); $p->contactemail = $sanitizer->email($input->post->contactemail); $p->save(); // save the page $p->of(true); How do you know which user is posting these values? If you are not already doing this, its better to keep a reference to the $user by all times to prevent somebody to post and modify somebody else his profile.
  14. Thanks Ryan, just placed an order too for personal usage
  15. Haha thanks, i could have known that it would be this easy, and it works like a charm. Automagicly redirects to https
  16. We have installed an SSL certificate on our server for the domain its running on. There are several pages in the website that have user input like a form. How can i force that those pages only be accessable on https:// So that direct access to those URLs or links to the URL automaticly be redirected to https:// instead of http://
  17. You could hook into page render and based on $page->name or $page->url or alike handle your post data public function init() { $this->addHookBefore('Page::render', $this, 'myRenderPage'); } public function myRenderPage($event) { $page = $event->arguments[0]; if ($page->url == '/') { // handle post for home page } elseif ($page->url == '/contact/') { // handle post for contact page } }
  18. $input has all the GET POST and COOKIE variables. So for post values you can access it with $input->post See: https://processwire.com/api/variables/input/ Inside a module it would be $this->input->post or wire('input')->post
  19. Macromedia Adobe Flash can also export to animated gif
  20. Mailchimp has also some good information about this topic. http://templates.mailchimp.com/development/responsive-email/ One thing to keep in mind is always to have a good fallback template for ancient mail clients. For example Outlook 2013 and previous versions are using MS Words as render engine, instead of what you would expect Internet Explorer. https://litmus.com/blog/outlook-2013-still-powered-by-word-now-available-for-email-testing Besides that, to support some (older) mail clients you have to use inline styling as if you where making a layout design for web 1.0 browsers. This is always been a problem with templating for mailings when you want it to be compatible with older mail clients. Some good information about creating email templates can be found here: http://help.hubspot.com/articles/Best_Practice/email-templates-design-code So responsive email templates are certainly possible for mail clients (or browser based mail clients) which support media queries. Altough to over rule all the inline styling from inside the <style> tag you might need to set !important to all the styles in there.
×
×
  • Create New...