Jump to content

Doc

Members
  • Posts

    108
  • Joined

  • Last visited

Everything posted by Doc

  1. Hi, I have a menu at the top of my homepage (~15 links). I'd like to translate it. Example : <a href="#" class="menu-item">collection</a> <a href="#" class="menu-item">products</a> <a href="#" class="menu-item">support</a> [...] What's your prefered method to translate that ? I already have my configuration ready for different languages according to the url : /en -> display english, /fr -> french, ... Do you add one more field per link on the homepage or do you add a single "menu" field ? With one field / link you add content by filling your textlanguage with : "collection" for example and then display it on the homepage through $page->link1 With one field / menu you add the whole html stuff I guess, with the CKEditor for example on a textarealanguage field : <a href="#" class="menu-item">collection</a> <a href="#" class="menu-item">products</a> <a href="#" class="menu-item">support</a> and then display it on the homepage the same way than with one field / link. Which method would you use ? Let's vote Thanks
  2. Thanks for your feedback @LostKobrakai, I won't dig further for the first visit settings. I'll keep french by default at the moment, and implement the dynamic language preference if I get some extra time before the launch. I use sessions to store the language once I know the user's preference.
  3. Thanks @harmen You brought to me part of the answer. I'll use $url = $page->localUrl($language); ... more convenient than the url I was building myself before. I'll update my language selector with that. Actually I was looking for a way to dynamically load on the first access to my homepage, and without any manual intervention, the right language according to the browser's settings. I think I'll use this : (from http://processwire.com/api/multi-language-support/multi-language-fields/) $page->of(false); // turn off outputFormatting (if it's not already) $dutch = $languages->get('dutch'); // get the language we want $body = $page->body->getLanguageValue($dutch); // get the unformatted value in Dutch So I can dynamically load the content I'm looking for whatever the url which is loaded on the first access (http://www.myurl.com/ in my case). "/" is normally dedicated to french, "/en" to english. That way, on first try, for an unauthenticated user, my website will land on http://www.myurl.com/ url, in english if I detect english preferences in the browser, or in french if I detect a french browser. Perhaps there is an easier way ? I think that solution is better than redirect with a 301/302 on that url : $url = $page->localUrl($language);
  4. hi guys, My homepage is built on a home.php file which calls/(includes) a _home_inc.php file. In the home.php file, if the user is not logged (I don't know anything about him), I take the browser's default language, let's say english ('en'). How can I load the english version of my website ? My default language is french. I'd like to say to Processwire to go to http://www.myurl.com/en and not http://www.myurl.com/ (which is french based). (the english version exists, I've setup the multi-language options in the admin and I can go to http://www.myurl.com/en and see the english version). Thanks
  5. Thanks for the confirmation @fbg13 !
  6. Hi guys, I've just created a new user : $u = new User(); $u->name = $nickname; $u->pass = $pwd; $u->addRole("guest"); $u->save(); I've added some new informations on that user, here : $u->points = 3; $u->language = 'fr'; Now I'm doing my session->login stuff, and my session->redirect stuff. On the destination page, I thought I would retrieve the $u->points and $u->language values, but it's not set. I thought I was saving the values in my news user's session area but I'm apparently wrong. I guess I have to use that syntax in the first page : $session->points = 3; $session->language = 'fr'; ... and then it will be still there on the destination page ? Is it the good way to do it ? Do my values will stick with the right user I'm dealing with ? Thanks
  7. hi, Old thread but I've just tested with MySQL 5.7.14 on PW 3.0.42 and did not encounter any problem so far.
  8. Thanks @Mindfull. Actually I sanitize everything before creating the user, on the fly as you said. That wasn't obvious for me to have to create the user before the session login returns OK. I won't add any extra hashing but I keep only the minimum info (username/password/email) on the PW DB and have another table to store everything I need for my players. Also it's easier to have all the player's information in one table for me, export is easier too.
  9. I'm answering to myself to a part of the question : I've just discovered by dumping all the DB that a user is stored like a page, in the "pages" table, which is not too convenient if I want to dump my users table I guess.
  10. Hello, Newbie question here. I'm rebuilding my existing website with PW, it's a game where people can guess the winners of races. I used to have a "players" table. Those are registered players, I used to identify them through their login/password, and when it matches, I give them access to the website. No rocket science. So now with PW, I'm building my sign-up form and I'm trying to create a new session when a new user sign up. I'm retrieving user/pass from the sign-up form which has been posted before but : if($session->login($user, $pass)) { // login successful $session->redirect(elsewhere); } else echo "failed"; ... fails everytime. Do I have to use something like : $u = new User(); $u->name = "bill"; $u->pass = "billpwd"; $u->addRole("guest"); $u->save(); ... before doing a session->login('bill', 'billpwd') ?? (I've just checked, it works, so I guess this is the good way to do it ?) I already have my players table so perhaps I can have the minimum in the PW's table and keep my players info in my historical table ? ... Or I can add all information I need into PW but I'd like to understand where it is stored. Last question, if there is a PW matching between "user" and "session", I need to give to the session->login function the password not hashed. I'm using the password_hash php function, any problem with that ? Thanks
  11. Hi guys, I'm trying to setup my first login form. Once connected the user will able to access the other part of the website. I've read many topics about session from which I've learned a lot but I still can't figure if sessions are files based, database based or cookie based ? I've read somewhere Ryan said he will add a database option, is it live ? Perhaps a cookie is only set if a user is logged in ? In the doc http://processwire.com/blog/posts/multi-instance-pw3/#more-session-control, it says : "Session variables are currently stored with PHP's session functions with files in /site/assets/sessions/." In that same doc, someone asks in the comments section how to get rid of sessions, he don't use them and don't want any cookies (perhaps regarding EU cookie law...). (I've also read many threads where people had too much files in their sessions directories, apparently ubuntu related or Php garbage collector setting). So does PW sessions set a cookie or not ? Does someone here know what's the default lifetime of a PW session ? Thanks !
  12. Ok I get it now, thanks to both of you. I don't use PW forms and I understand now that the tutorial I've pasted here was a way to implement CSRF protection without PW forms, I've missed that. The session linked helped too !
  13. Hi @fbg13, Yes I get that, it's set to true in my config.php Actually it doesn't appear in my config.php, which means it's ON by default, I can turn it to false by specifying it in the config.php. What I'd like to know is what does it mean functionaly speaking : do I have to implement the line of codes I spoke about earlier or does PW protect me against CSRF attacks by default (I'm not sure about that).
  14. Hi, I'd like to add some CSRF protection on my sign -up form. I've successfully applied that method : https://processwire.com/talk/topic/3779-use-csrf-in-your-own-forms/ (generate the tokens and once the form is posted, check the tokens with $session->CSRF->validate(); ) I've read stuff about $config->protectCSRF; but I don't understand : - it's ON by default but what does it mean ? Are my forms protected by default or do I have to add the above stuff ? - (bonus question) how do you hack your own form to simulate an "attack" ? I've tried chrome debug console but did not succeed to edit the token I've generated in the sign-up form Thanks !
  15. I'm using the PW builtin translation capabilities I'm a beginner with PW but here I'm speaking about my translated fields, the ones I've setup in the admin section. I've installed the core plugin dedicated to translation, and I can switch easily between fr/uk for example just by modifying the url, and that works great ! I'm a MySQL DBA actually and was thinking : what will going on if I have 50 concurrent users here -> 3000 concurrent queries ?
  16. Sure @LostKobrakai, let me reformulate : On my homepage, I have about 60 custom fields, which have been built to store some sentences or words I have to translate. I suppose that PW will have to make 60 queries in the MySQL DB to retrieve those fields. Perhaps I'm wrong here and PW will ask run only one query with 60 columns... I didn't check on the log. Although I don't have any performance issue (it's only running on my laptop yet), I was wondering myself, from a theorical point of view / best practice, if I'd better go with markup cache for example to avoid too many queries due to the translation part of the homepage. My fear is that all my custom fields : $page->home_field1, $page->home_field2, ... match the same corresponding number of queries in the db (60x). And it that case, perhaps I'd better go with specific cached queries for each custom field I use ? Another approach I was speaking about : detect the language used and load the corresponding text file (uk.inc.php, it.inc.php, ...). Is it more clear now ? Or perhaps I'm digging too much and I would better go as is, and see later if I encounter performance problem ? Thanks
  17. Hi, I'm building my homepage, it contains ~60 custom fields (lines or words I define & translate in the admin in different languages). The homepage is dynamic and my users are logged. I'm trying to avoid many MySQL queries to retrieve the fields I've setup in the admin, I think I can do better than 60 different queries to display that content on the home. Regarding performance, will markup cache a good approach here ? I understand it makes sense when you have a scrolldown menu which is built within a loop for example but is it still good if I cache 60x a word or a group of words in my code ? Another idea I had was to dynamically determine which language is used by the user and load a language file which contains the translated text (uk.inc.php) and so on... (less elegant I think, but I'll use that anyway for dynamic expressions such as "you have %nb items in your cart"). Thanks
  18. ok, ok, then thanks ! I know where I'm going now.
  19. Thanks Kongondo. Well, within your link it says 'Temporary wrapper to mysqli Database class for mysqli => PDO transition'. So it seems it's not very reasonable to use mysqli I'm starting a new project on 3.x.
  20. Hi, I was looking for fresh news about PW and mysqli support. The freshest I could find is https://www.cmscritic.com/processwire-2.4-released/ (april 2014). In this article Ryan said : "The mysqli driver will continue to be supported for backwards compatibility" Is it still true today ? (2 years and a half after that article) I mean I'm more used to mysqli than to PDO, so can I write some custom queries with mysqli rather than with PDO without taking too much risk ? I'd like not to rewrite everything with PDO if within a few months PW drops mysqli support, perhaps I've missed a news (I'm a newcomer with PW). Thanks
  21. I think I get it, I've just read : https://processwire.com/talk/topic/3644-translate-static-strings-in-the-templates-folder/ @Soma made me understand the process (I think). I probably going to use something like that with a single translation file/language (I have the same sentences multiple times on different templates). So to sum up : - I'll use multi-language textarea field in my backend to manage description which doesn't change often. - I'll use a single translation file / language, loaded dynamically according to the language used by the template. Sounds good to the pro ? Thanks
  22. Hi guys, I've been playing with PW for a few days now, having fun so far. I'm testing the multi-language capability features. I've read https://processwire.com/api/multi-language-support/code-i18n/ and https://processwire.com/api/multi-language-support/multi-language-urls/. I succeeded to display a page in my default language, then by adding "/en", display the "en" version and so on. So I understand how to manage the description part of the website which won't be modify very often, great. But I don't get it for text such as : sprintf(__('Your city is %1$s, and your zip code is %2$s.'), $city, $zipcode); I mean I get it about the sprintf stuff, I used to have such a system on my old website, with countries include files en.inc, it.inc. What I don't understand is how PW will load the english text, the italian text ? Do I have to build myself the matching countries files according to the language set on the page ? Something like if 'en' then include ('en.inc'); ? Thanks
×
×
  • Create New...