Jump to content

Raymond Geerts

Members
  • Posts

    365
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by Raymond Geerts

  1. Yes __("Male") too gives a 500 error. Would you recommend removing the static? This would mean i have to modify the code from self:: to $this->
  2. ___uninstall is hookable. You could write a before hook that will replace the uninstall This example is for $this->pages but you can change that to your needs public function init() { $this->pages->addHookBefore('uninstall', $this, 'myUninstall'); } public function myUninstall(HookEvent $event) { // replace original method $event->replace = true; }
  3. https://processwire.com/api/multi-language-support/code-i18n/ In the documentation about Code Internationalization the following is mentioned: Translatable strings In order to make a string translatable in your template or module code, you just have to wrap the original string in a $this->_() or __() function call: $out = $this->_("Live long and prosper"); // syntax within a class $out = __("Live long and prosper!"); // syntax outside of a class Inside my methods the first example of syntax in a class seems to work fine. Somehow the following code seems to throw a 500 Internal Server Error which states: Parse Error: syntax error, unexpected '$this' (T_VARIABLE) Example: class SomeModuleName extends WireData implements Module, ConfigurableModule { /** * Returns gender type * * @static * @return string */ private static $gender = array( 1 => $this->_("Male"), 2 => $this->_("Female"), ); } I can image since the module is not initialized or constructed yet that $this is not available at that spot. Any tips on how to be able to make those values multilanguage?
  4. Optimizing on this level would have minor benefits that it would hardly be noticable. I would recommend limiting the amount of assets you load, the lesser the request to your server the faster the page will load. Secondly to have a lot of speed aprovement i can recommend the ProCache module that Ryan wrote. Altough i found a couple of things that you could change in your code: echo "<li><a href='{$pages->get(1026)->url}'>{$pages->get(1026)->name}</a></li>"; // I would recommend changing it so you only have one request for $page->get() $item = $pages->get(1026); echo "<li><a href='{$item->url}'>{$item->name}</a></li>"; $menu = $pages->find("template=browse, parent=1, sort=title"); foreach ($menu as $item) { ?> <li><a href="<?php echo $item->url ;?>"><?php echo $item->title;?></a></li> // I would recommend changing it, not switch php html, and sort by name its significant faster that sorting by title $menu = $pages->find("template=browse, parent=1, sort=name"); foreach ($menu as $item) { echo "<li><a href='{$item->url}'>{$item->title}</a></li>"; Regarding the amount of javascript files you load, you might want to compile those to one file and server that (possible minified and gzip compressed). There are scripts or modules that can do that on the fly (sorry, i dont have an URL at this moment).
  5. Very nice work these two pro fields can't wait to see what magic is inside the other pro fields. And the narration is quite amusing haha yarrr!
  6. I'm missing some information to be able to help you further. Can you show all the code of the entire template from section, container, row, column, sub column. I have used a similar setup for a website once, so i might be able to help you a little further when i have some better idea of the complete code. I'm guesing that you are using somekind of page structure like this, am i right?
  7. I hear with ravensburger you can have beautiful paintings on your wall too, some people will be satisfied with that. Other people prefer a Dali, da Vinci or van Gogh. I prefer a framework where i can decide how to do the things i want to build, not the other way around. ProcessWire gives me that freedom. Like Craig mentions i wouldnt knwo any project i build in the past two year or so where i would use Wordpress over ProcessWire
  8. I'm not sure what you are trying to acomplish. Anyway the folowing code prints all the roles and name of the role for the current user foreach($user->roles as $role) { echo "Role: {$role} = {$role->name} <br>"; } Or if you need the role for a specific user $u = $users->get('admin'); foreach($u->roles as $role) { echo "Role: {$role} = {$role->name} <br>"; } All anonymous visitors, loggedin users, admins etc... by default have the guest role
  9. Just dropping this here since i found it very handy for testing websites in (old) IE on different Windows OS. Here you can download different Windows OS VM images for different VM software that run on WIN, MAC and LINUX. http://www.modern.ie/en-us/virtualization-tools#downloads I'm running Virtual Box on OSX which is free.
  10. http://modules.processwire.com/modules/process-dashboard/ Thanks, that is awsome and probably what i need for a project im currently working on. I need to serve a small list of pages and the ability to add new pages to a fixed parent without showing the page tree.
  11. This is something i was thinking about a couple of days ago. I was wondering if it would be possible to serve somekind of dashboard page instead of the page tree. Looks like this is the base for that to build it upon.
  12. Ha, nicely described that. this is what i love about processwire, and that 'everything' is a page and can be used for anything
  13. OK it seems to work now. I have done the following (from a already installed ProcessWire): - Export database - Modified the lines in the exported file that have ENGINE=MyISAM DEFAULT CHARSET=utf8; to be ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - Imported file in to the database - Created a MySQL config file (in my case /etc/my.cfg) and added the following lines [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci - Restarted MySQL - Modified the following ProcessWire files: /wire/config.php line 47: $config->dbCharset = 'utf8mb4'; /wire/core/Database.php line 72: else if($config->dbSetNamesUTF8) $this->query("SET NAMES 'utf8mb4'"); /wire/core/Fieldtype.php line 421: 'xtra' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8mb4', /wire/core/WireDatabasePDO.php line 82: PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4'", This seems to be working, i didnt get the MySQL PDO error anymore about the \xF0\x9F\x92\x93\xF0\x9F character Altough i'm not so happy to have modified the files in the wire folder, since these are core files and will be overwritten as soon as i update the wire folder by replacing the files inside. Would be nice to be able to set this value somewhere in a config file. Update: a recent update in the PW DEV branche includes the ability to set the charset in the configuration file. The issue is discussed here: https://github.com/ryancramerdesign/ProcessWire/issues/452
  14. I found some helpful information on utf8mb4 http://mathiasbynens.be/notes/mysql-utf8mb4
  15. I'm importing data from the freebase.com database and having some troubles with 4 byte characters. SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\x9F\x92\x93\xF0\x9F...' for column 'data' at row 1 Doing some research i found out the database fields that use now utf8_general_ci collation all need to be utf8mb4_unicode_ci. But also the connection needs utf8mb4 and SET NAMES need to be utf8mb4. mysql_query("SET CHARACTER SET utf8mb4"); mysql_query("SET NAMES utf8mb4"); 1) Would ProcessWire (PDO) be able to make connection with these settings? There is a setting for this in the config but there its mentioned its depricated. Seems the PDO by default SET NAMES utf8 From the config file: /** * Optional 'set names utf8' for sites that need it (this option is deprecated) * * This may be used instead of the $config->dbCharset = 'utf8' option, and exists here only for * backwards compatibility with existing installations. Otherwise, this option is deprecated. * * $config->dbSetNamesUTF8 = true; * */ $config->dbSetNamesUTF8 = true; /** * Optional DB socket config for sites that need it (for most you should exclude this) * * $config->dbSocket = ''; * */ 2) I have ProcessWire installed, would it be possible to convert it from utf8_general_ci to utf8mb4_unicode_ci I found this in the config file that is located in the wire folder: /** * Database character set. utf8 recommended. * * Note that you should probably not add/change this on an existing site. i.e. don't add this to * an existing ProcessWire installation without asking how in the ProcessWire forums. * */ $config->dbCharset = 'utf8'; Probably need to change this to utf8mb4 then but as it mentions i should ask here, does anybody have some more information what to do to make this work? Edit: At the moment i converted the database and fields by modifying the mysql export and re-importing it again. Now it has: CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
  16. Caching images has not much to do with processwire in that way, images are cached by the clients web browser. And once it processed by processwire to make a thumbnail the direct URL to the image is used. Possibly when your images are generated with PHP you could set some headers to control caching. But this post on stackoverflow you might find interesting, it covers a way to embed images as base64 data in your HTML or CSS directly. http://stackoverflow.com/questions/1124149/is-embedding-background-image-data-into-css-as-base64-good-or-bad-practice
  17. Do you guys know the site "Clients from hell" ? It has similar stories from (web)-developers and designers all over the world, funny and recognisable stories and situations at times http://clientsfromhell.net/ @martijn: Yes i remember that one
  18. Perhaps it will help to add these headers (just after the opening <?php call) to the top of your template file that is delivering the data to ajax if($config->ajax) { header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); }
  19. Sorry Martijn, this one also outputs false while they are idential $wa3 = $pages->find('template=foo|bar,sort=name'); $wa4 = $pages->find('template=foo|bar,sort=-name'); sort($wa3); sort($wa4); echo ($wa3 == $wa4) ? "true" : "false"; Altough the fly-thingies images are identical indeed
  20. There is one ) too much, but it also gives a 500 Internal server error edit: echo "identical" was missing ; that caused the 500 Internal error. It seems to work find when you remove on ) and add a ; // could be this. if(count(array_diff($array_1, $array_2)) === 0) { echo "identical"; } This one is not that short but will do the job $wa1 = $pages->find('template=foo'); $wa2 = $pages->find('template=bar'); $wa3 = $pages->find('template=foo|bar,sort=name'); $wa4 = $pages->find('template=foo|bar,sort=-name'); $wa5 = $pages->find('template=foo|bar|foobar'); echo "compair: wa1 and wa2 = "; echo count($wa1) >= count($wa2) ? count($wa1->not("id=$wa2")) : count($wa2->not("id=$wa1")); echo "<br>"; echo "compair: wa3 and wa4 = "; echo count($wa3) >= count($wa4) ? count($wa3->not("id=$wa4")) : count($wa4->not("id=$wa3")); echo "<br>"; echo "compair: wa3 and wa5 = "; echo count($wa3) >= count($wa5) ? count($wa3->not("id=$wa5")) : count($wa5->not("id=$wa3")); echo "<br>"; Output (where 0 means identical) compair: wa1 and wa2 = 3 compair: wa3 and wa4 = 0 compair: wa3 and wa5 = 9 (I have 3 pages with template foo, 3 with template bar and 3 with template foobar)
  21. Currently working on a big project where there will be a lot of user content (photo's). As soon as i finished the modifcation of the Frontend User Profiles module with build-in friends system, that is something i too have to figure out. Instead of Amazone S3 i was looking in to Google Cloud Storage. One reason is they just lowered their prices and i personly like their API. Been playing around with their YouTube v2 API before and since a while with the YouTube v3 API. But also their FreeBase API. MODx Revolution has a nice solution for this where you can setup data providers. Like the default "localhost" there is one for S3 storage too. I'm hoping ProcessWire will have such a solution someday too where you can install data providers (S3, Google Cloud, other CDN) and choose where certain data is going to be stored. Specialy with huge sites having the choice for something else then localhost to store the data. CDN or Cloud Storage have nicer pricing then regular hosting providers when it comes to storage huge amounts of data. One of our other big website (which still runs on MODx) has abot 40 GB of image data. The plan is to migrate this website some day to ProcessWire too. So for this a 'special' fieldtype might solve it for storing images, instead having the ability at core level would be a dream come true
  22. After doing some more testing it seems that it does not work the way i thought it would work. ->modified would hold the value of the modified field of the page being added, and not the modified timestamp of when the page was added. @martijn zz-top in disguise?
  23. This topic might have the answer to your question https://processwire.com/talk/topic/1674-sorting-repeater/
  24. php.net All functions have example code and other code for different aproach for the functions. http://nl1.php.net/manual/en/function.echo.php
  25. Update, i noticed to get this working all it needs is an extra column to the FieldtypePage with the folowing settings. Now i did it manualy to the database. To have it work automaticly for each FieldtypePage field that is added it needs to be added here. $schema['modified'] = 'timestamp NOT NULL default CURRENT_TIMESTAMP'; Then it works and you can request the modified (added) date timestamp this way. foreach($pages->find("template=templateWithInputfieldPage") as $somePage) { echo date("d-m-Y H:i:s", $somePage->modified)."<br>"; } This will spit out the date that page B was added to page A InputfieldPage field. For me this would be a very useful feature for the FieldtypePage. But i'm aware there is a good chance this addition is not that interesting to Ryan or others. So i hope this will make it to the core, but if not does anybody know how to turn this in to a module? One that just adds the extra modified field to each FieldtypePage (InputfieldPage) automaticly?
×
×
  • Create New...