Jump to content

horst

PW-Moderators
  • Posts

    4,090
  • Joined

  • Last visited

  • Days Won

    88

Everything posted by horst

  1. You need a bootstrap script that should be located besides the PWs index.php. I have a template for that: After you have setup all your products, I would write a hook into the site/ready.php. Hook into before pages save, check if it is a productpage, if so, calculate the incl. vat price and populate it to the field, Ready!
  2. Hi! Very good initiative! I have skimread through the code and my opinion is: The first and second ones looks good. But to be honest, this hotswap user thing is a big security issue. Sorry! Also only for demonstration / tutorial purposes, it is better not to use hot user swapping as a thema. The audience for beginner tutorials often will be, yes, the name says it: beginners. And assumed they simply do not know about such security issues and best practices in regard of how to validate user-inputs, you should not show code like this to them. At least you would need to embedd all security relevant stuff too. But then it fastly will become to complex for a beginner tutorial. A good one would be to only pick up how to validate user inputs and how PW provides good tools for that. (type and format validation, whitelist matching, ...) With your code, everyone can login with each existing account (also Superuser) just by knowing / trying (multiple til endless!) user name(s). In regard to this, you may have a look into ALIF or TracyDebugger, how the security for this is tackled there. I hope you do not mind me my frankness. ------------- Looking to the code of the users redirect module, you can shorten it a bit. When found a matching user / role, you don't need to store true in a temporary var, break the loop and then check the temporary vars value / state, if you should redirect the current user. You simply can redirect the current user if a role matches: /* * ___renderPageRedirect * * redirect user to page if current user role found in config */ public function ___renderPageRedirect($event) { // check to see if current page = admin template page // otherwise: early return! if($this->page->template != "admin") { return; } // find roles set in module configuration and create array $roles = explode(',', $this->userRoles); // for each user in module config check to see if current user foreach ($roles as $key => $val) { $roles[$key] = trim($roles[$key]); // if current user found then redirect = true if($this->user->hasRole($roles[$key])) { // this will leave the page and code immediately! $this->session->redirect($this->redirectPage); // stop user search break; // this can stay in here, just as fallback, // if something went wrong with calling the redirect, // but normally this line will not get executed. } } }
  3. Have made some updates to ALIF: 1.1.0 fixed a bug in method sanitizeColor() 1.1.1 added detection and a toggle button for TracyDebugger (enable/disable) 1.1.2 more security for User-Switcher, (stays in for cases, where TracyDebugger isn't available) http://modules.processwire.com/modules/admin-links-in-frontend/
  4. Why Aligator with one "L"? Maybe it is first name, last name? First Name: Ali Last Name: Gator
  5. @rickm this is answered discussed already, but can not find it yet. BUt the good news is, you can use PW 3 right now with PW 2.7 modules or earlier ones. To get more informations you should google in blog posts with the term: FileCompiler https://processwire.com/blog/posts/processwire-3.0.14-updates-file-compiler-fields-and-more/
  6. I would exclude *.min.* per default. I think no one uses this for his work and adding ToDo comments.
  7. Once more but last one too: I strongly suggest to read the php docs on how to upload files: http://php.net/manual/en/features.file-upload.php
  8. Yes you get random names because you assigned them to your variables. If you don't like them, don't assign them. $photo=$filetemp = $_FILES["photo"]["tmp_name"]; This has nothing to do with my module nor with PW. I suggest to follow up with the php docs on how to upload files, followed by how to use it with PWs WireUpload class. There you also have validation options for filetypes. IMO this is essential knowledge in regard of security to your website. Open it for uploads must be done in a secure way. Therefore you must understand, at least to a small extend, what you are doing.
  9. From where do you get the file(s)? Can you please show this exact code snippet? (and only this, please) The module is working fine. It just uses what you passes to it. So, you probably do something wrong in regard of your filenames / files passing to the module.
  10. Hi, first thing, if you have a question regarding a module, please use its support board thread! One solution to determine / validate filetypes would be to check the magic bytes. Imagetypes that are supported by the native php function getimagesize can be detected by that function.
  11. These are two different things: subcriber system and newsletter sending. I suggest to first read / post in the NewsletterSubscriptionModules forum support thread to get this working. In regard to newsletter sending, I suggest to use a service and / or use a module like: http://modules.processwire.com/modules/wire-mail-mandrill/ http://modules.processwire.com/modules/wire-mail-mailgun/ http://modules.processwire.com/modules/altivebirit
  12. Thats what I was talking (thinking) about when agreed to @tpr and @szabesz : the use of the UA-Switcher. Honestly I think, when already using (installed) TracyDebugger, there is no need to have an additional UA-Switcher elsewhere. But I'm using ALIF everytime. In my local (not yet released) version, ALIF even has a toggle button to switch on/off the TracyDebugger And I use it in production sites for frontend edit- and logout- buttons for editors. That was the initial reason why I have written it.
  13. @Robin S 's solutions are perfect. My personal favourite would be the first one: just working with the basic page tree and hidden / unhidden or published / unpublished states. If you want go with another pagefield solution (checkbox), but want to have a good visual sign rendered in the page tree, there are some code examples in the forums here how to use a hook for that. Other than in the linked example, with recent PW versions, you don't need a module for that. You just can add a code snippet for that hook into your sites init.php. If you need any further help, just ask.
  14. That's correct! This is one more example on how things grow in our community: we work together to make it as good as we can. Someone come up with a good solution for a partial thing. This a) directly help others, it b) inspires other users to new / other solutions, and this, in the end, makes working with our beloved PW a little more better again. And, in this case, (ALIF and Tracy): from now on, everytime when I will use Tracy, I will have the feeling that a little part of my work is into it.
  15. What I cannot understand is how the file sites.php in the root folder could stored, the index.php gets an injected line, because those are not under sites/assets/. I assume that you haven't had set 777 for the webroot. So, how can this be possible?
  16. I think you need explicitly set: Options Indexes to allow it, and not to disable it. But it also can be that on this (shared?) host, you have no rights to change this. Just try if it work or contact the hosting support if they can enable it.
  17. I think that you: a) have only used short syntax for echo(ing) strings: <?= what is not the same as the short php opener. Please check and confirm. b) now, it is parsed and tells you that you have a parse error. A parse error at the last line of a file occures when you somewhere have an unclosed level of, e.g. foreach, if statement or something else. You have to go through your code and check if you have closed each opened one. In tis regard, I want to say that the code you use is not the best solution. I personally find it really hard to read, and it also is hard to maintain. There are many ways to keep the logic aways from the markup. Big and small solutions. But everything seems to be better than that. For example, you can do the php logic in the top of the file, and than merge it together with the markup. <?php // open the file in PHP mode, /** add comments to the file if needed. * This is a good place here. :) **/ // define a markup template with placeholders $myMarkupTemplate = " <a href='#'> <div class='port'> <img class='pic' src='[_URL_]'/> <div class='portbgrdtext'> <h5>[__GENRE__]</h5> <p>[__TEXT__]</p> <button class='portbtn'>Read More</button> </div> </div> </a> "; // now get your page and loop through your selections $portfolio = $pages->get("name=portfolio"); foreach($portfolio->portfoliopreviews as $portfoliopreview) { $search = array('[_URL_]', '[__GENRE__]', '[__TEXT__]'); $replace = array($portfoliopreview->portimg->url, $portfoliopreview->portgenre, $portfoliopreview->porttext); echo str_replace($search, $replace, $myMarkupTemplate); } Another approach could be <?php // get your page and loop through your selections $portfolio = $pages->get("name=portfolio"); foreach($portfolio->portfoliopreviews as $portfoliopreview) { $url = $portfoliopreview->portimg->url; $genre = $portfoliopreview->portgenre; $text = $portfoliopreview->porttext; echo " <a href='#'> <div class='port'> <img class='pic' src='{$url}'/> <div class='portbgrdtext'> <h5>{$genre}</h5> <p>{$text}</p> <button class='portbtn'>Read More</button> </div> </div> </a>\n"; } or you ommit the temporary variables and put out the field values directly: <?php // get your page and loop through your selections $portfolio = $pages->get("name=portfolio"); foreach($portfolio->portfoliopreviews as $portfoliopreview) { echo " <a href='#'> <div class='port'> <img class='pic' src='{$portfoliopreview->portimg->url}'/> <div class='portbgrdtext'> <h5>{$portfoliopreview->portgenre}</h5> <p>{$portfoliopreview->porttext}</p> <button class='portbtn'>Read More</button> </div> </div> </a>\n"; } There are many ways one can go.
  18. The php server environment where you use this code, has short php syntax disabled. To be save and transportable with your code, you never should use this. Always use <?php to enter into php mode. Better don't use <?
  19. any restrictions in the network or server your work computer is located?
  20. Haven't used it now, but already like it! (have had a look to the readme!) Below an example of a root parent and a first level child:
  21. Regarding a cropped version: Is it right that we easily can create a new cropped-out image (variation) with the individual cropping tool of the core imagefield, and then, in a second step, select this new one an define the focus point? If this would be possible, I think then there is nothing left out.
  22. It is an interesting option. Only thing that I may think of what is not good, is that it ever takes full width or full height of the original image. There are use cases where one want crop out a part. But for many other cases this seems a good solution. If I understand the concept right, there would be less hassle with lots of variations. Right?
  23. Yes, please only use the second one. Best is to uninstall the first one. The first one is obsolete, as it only supports the older image variations naming convention, and not the new one, introduced in PW 2.5.11.
  24. simply go to the modules directory, you find it directly on the first page under "User Favorites", the second item. Or here. Your other questions I don't understand. ?? In the modules package are a module pim1 and a module pim2. If you use a PW version greater than 2.5.11, please do not install pim1, install pim2! That's all. Hope this helps?
×
×
  • Create New...