Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/03/2017 in all areas

  1. Hi Fred, here's some code that might be helpful. Also, make sure page numbers are enabled on the page's template (URLs tab in Setup > Templates > any-template). $limit = 10; $items = $pages->find("template=something, sort=name, limit=$limit"); $total = $items->getTotal(); if($total) { // there are results present $numPaginations = ceil($total / $limit); $pageNum = $input->pageNum(); if($pageNum == $numPaginations) { // you are on the last page of results } else if($pageNum == 1) { // you are on the first page of results } else if($pageNum > $numPaginations) { // beyond the last page, do a redirect or a 404 } else { // somewhere in the middle of the paginations } } else { // there were no results on any pagination } Also see the PaginatedArray type (PageArray is a PaginatedArray): http://processwire.com/api/ref/paginated-array/
    6 points
  2. Ok, so I've completed the first module and a detailed step by step write-up. https://abdus.co/blog/creating-a-simple-and-configurable-module-for-processwire/ It's a markup module that adds tracking code for analytics. It has hooks, hookable methods, and it's translatable and configurable. https://github.com/abdusco/pw-ga-lite Once I make sure it's ready to go, and write a good intro, I'll create a separate post for it.
    6 points
  3. Thank you all for your feedback. @rick The translations will follow over the next days. Thank you, I have corrected this. @Robin S You both are right. I drilled it down a bit and removed the largest variation for desktops. @szabesz I have forgotten to run the logo through SVGO. Now it is smaller. @tpr I know it is really subtle, for now I want to leave it in there, because it adds a nice touch. But I get your point.
    3 points
  4. Check if you have installed the ProcessPageClone (/processwire/module/edit?name=ProcessPageClone) module. This installs a few permissions: You could check if these are stored on the role of your user. If you want to monitor changes by users on pages be sure to look at ProcessChangeLog or MarkupActivityLog.
    2 points
  5. You absolutely can, but that's not why EC2 is so powerful and it's by no means suddenly more scaleable than a VPS elsewhere. That's what people are often missing. The scaleablity praise for amazon comes from things like autoscaling, which dynamically adds new EC2 instances or destroys unused ones, which has the same problems and hurdles you've had on heroku as well (except on aws you have to do the setup on your own as well). And for the complexity of amazons security management and other things involved in AWS it's probably better for unexperienced people to just go with digitalocean/linode for single instance VPS, because the savings in money on AWS are probably counteracted by the time saved not setting up EC2, but simple clicking a few buttons somewhere else.
    2 points
  6. A write-up/tutorial would be much appreciated when you're ready!
    2 points
  7. Hello, I have a custom member user template with quite a lot of fields and would like to organize the fields of the profile edit page in tabs. I created tabs and they work just fine in the page edit screen. I enabled all the tab fields for the profile edit page in the ProcessProfile module Admin > Modules > User Profile. But on the profile edit page they do not appear as tabs. I found that wire/modules/Jquery/JqueryWireTabs/JqueryWireTabs.js and JqueryWireTabs.css do not get loaded on the profile edit screen. EDIT: even if I manually load in JqueryWireTabs.js and JqueryWireTabs.css, the tabs are not displayed. Is this intended behaviour or a bug?
    1 point
  8. Hey guys, I've recently started a blog on web development and ProcessWire, and I'm slowly building content to make it a habit and not let it become a failed experiment. I also believe that a good way to keep producing new content is to build an audience that cares about what you write and what you offer. So, I've started writing a series on module development, from basic to complex, where I explore core modules and unearth the valuable documentation inside PW core and put them into practice. I'll be stripping core modules to their essentials like blueprints that people can build upon, and construct various modules that replicate popular ones on other platforms, or ones that bring some of their eye-caching features. I haven't implemented a commenting system on my blog, because I want to share and collect feedback and recommendations here, in this forum. Is there an etiquette on promoting my own content? Is it welcome, or how much is OK, or how much is too much? Thanks in advance, Abdus.
    1 point
  9. usually what i do in these cases is add a page field to the template of the pagetable page, and set that field to the page that it is being edited from. I used a save hook on the main page to look at the items in the page table and for any where that page field is not set, it assigns that field to the page being edited (so setting the page field on the pagetable item to PageA). that field is also hidden using CSS.
    1 point
  10. The most important CMS-updates in April by t3n: http://t3n.de/news/joomla-drupal-mehr-wichtigsten-819564/
    1 point
  11. I like to use the Connect Page Fields module but there is also another approach using an SQL query on the table of the Page field. An example... ...based on a suggestion from Ryan.
    1 point
  12. There's a module for exactly these kind of situations. https://modules.processwire.com/modules/connect-page-fields/
    1 point
  13. All your articles are stored in the database. You won't be able to find them in anywhere inside site directory, with or without FTP. You have to login to MySQL through cPanel or by other means to see your articles. How is it broken, are you getting any errors? Can you copy paste / post a screenshot of the error?
    1 point
  14. For a slider UI check out the new Jquery Ion Rangeslider module: http://modules.processwire.com/modules/jquery-ion-range-slider/ Or the earlier Range Slider module: https://modules.processwire.com/modules/range-slider/
    1 point
  15. Try this $fieldList = $fields->find('type%=PageTable'); foreach($fieldList as $f) { if($page->template->hasField($f)) { // page has the field } } Or simply: if($page->fields->find('type%=PageTable')->count)) { // page has a PageTable field } // check for a specific field if($myField = $page->fields->get('type%=PageTable')) { // $myField of PageTable type exists on this page. } Here I used find() method with a selector for matching type. You can be more specific, or use any other WireArray methods of course. https://processwire.com/api/ref/wire-array/
    1 point
  16. No, there is no such feature I'm aware of But you can use custom css to make it hidden. If it's not suitable ti you, I'll consider adding something like $config->disableAosFilter.
    1 point
  17. 1 point
  18. I plan to I am not there yet, but I have PW working and am just hunting down a bug, if that proves trivial and other tests work OK then I will certainly write it up. Thanks @LostKobrakai for your comments, you are clearly way ahead of me in this department—it's very helpful to hear from someone with your knowledge. Re: I did look at both of these a little, but it seemed they were principally aimed at people who routinely take bare Linux and get LAMP running, I may be wrong. But based on that assumption and guessing the docs on Amazon were perhaps going to encompass me (someone who'd heard of `yum` but hardly ever used it) I returned to Amazon. I tried Amazon Lightsail but fell off the process when it looked like I had to use the bitnami LAMP bundle (see below), or use Amazon tuts written for EC2, not Lightsail, and using those with Lightsail did not work and I was on too thin knowledge-ice to keep going. So I simply decided to try EC2 + the Amazon tuts written for getting EC2 LAMP, and so far, so good. Re: Thanks for noting this, I did understand that I was almost 'misusing' EC2 by looking to simply make a tiny VPS in the cloud and almost certainly not using any of the amazing features AWS offers, but I am not coming to AWS for the reasons most would and it's helpful to note that as I don't want to mislead . I'm coming to AWS from a weird angle, where I want to make a solid, modest cloud VPS equivalent, where I can host 10 sites or so, needing no elastic redundancy or power-up capabilities BUT wanting to take advantage of paying for use (low) rather than a flat monthly fee that I pay a traditional hoster, where my low consumption of resources is not reflected in my fixed monthly bill. I should have stated that earlier Aside I was put off when looking at Amazon + bitnami by reviews of the bitnami LAMP bundle. Conversely I have so far been left confident about the Amazon Linux distro and the tutorial for getting LAMP up. It's not been quite as simple as following a tutorial, but I've not had to search too far to keep proceeding and I feel less intimidated logging into AWS than I used to, so that's one take away at least One of the review that made me stop looking at Amazon + bitnami: I was also concerned that I may end up paying bitnami for LAMP (per month?) plus Amazon and yet one of my motivations for this exercise was trying to lower my VPS costs (which due to currency changes is about 50% up on what I used to pay).
    1 point
  19. I agree with all that you are saying, however I also think that people want more choices. It may be complex setting things up, but what does it hurt to find out how to make it work? I know I am interested in learning how to make the different AWS services work with ProcessWIre.
    1 point
  20. Hi @Steven Veerbeek and welcome to the PW forums I'm not clear on whether you are talking about the config page for a 'normal' module or the page created by a Process module. But I don't think either of these will achieve what you're aiming for. A module config cannot use an actual fieldtype such as a PageTable or a Repeater - with the module config you are only dealing with inputfields and that's not sufficient for a working PageTable. And while you might get a bit further with a Process module you would kind of be going against the grain of how a Process module normally works. Normally the page created by a Process module uses the 'admin' template and you don't want to be adding a PageTable field to that. So you would need to create and assign a custom template. But then you also need to be opening this page in ProcessPageEdit in order to use the PageTable field and that's not typical for Process modules. So I think you probably need to work within the 'install' method of your module to: Create a new template Create a new PageTable field (along with the template for the pages used in the field) Assign the PageTable field to the fieldgroup of the template Create a new page using the template This page would then serve as a kind of config page for your module. But then again there might be another totally different solution to the issue of how to define your image sizes without using a PageTable field. If I understand right you want a way to define a variable number of image size settings for your module. The simplest way to do that would be using a textarea field that follows some predefined formatting, e.g. one line per image size setting with width and height separated by some character such as a pipe. Then your module uses explode() to parse the settings. I also wanted a repeatable format for module config settings and thought the textarea approach was a bit limiting and error prone. You might like to take a look at the system I have used for repeatable settings in several of my modules. Not saying it's best practice or anything but it gets the job done: https://github.com/Toutouwai/ConnectPageFields/blob/ef9a03d08f0e724724f13ebdb8dfb35a4662ec26/ConnectPageFields.module#L191-L340 If you come up with a better approach to repeatable module config settings be sure to share it!
    1 point
  21. You can revoke the "page-move" permission for a template per role:
    1 point
  22. The site looks good. I only see a few issues with the English version. Partner section on front page is not translated. Under Software>Control, Utliising is misspelled. Weblounge page is not translated. Images under Solutions initially take a long time to load. I like what you did with the site. It is clean and easy to follow. Nice work!
    1 point
  23. It's Win 8.1, Chrome 57, full hd, 2gb vga ram, i5 8gb ram. It's also present here in Firefox, if I scroll over the parallax section the scrolling gets better. CPU also goes up to 30-40% if I scroll up and down a few times. Unfortunately we can't know the specs of the end users so I usually go with the lightest solution possible
    1 point
  24. I've assumed that I can use Amazon in place of a traditional VPS, such as Servint (who I like), for a significant saving. Maybe I'm wrong in that assumption..? To test that assumption and learn I've been working with Amazon EC2 to see if I can teach myself how to host multiple sites. So far so good.
    1 point
  25. You shouldn't use the actual token value you get from the session, you must use the value from the guest. The whole premise of CSRF (cross site request forgery) protection is to detect requests with invalid/missing tokens, so you know they're originated from a form on your site. If you don't use the posted value (a field starting with TOKEN in $input->post and its value that is sent with the request) you're practically removing CSRF protection altogether.
    1 point
  26. Second edit: hooking after Page::render works <?php wire()->addHookAfter('Page::render', function (HookEvent $e) { header('x: test'); // works });
    1 point
  27. New version now supports running actions via the API. Here's an example of copying content of a field from one page to another. Simply load the module, and call the action class name as a method while passing the required options as an array: $options = array( 'field' => 99, 'sourcePage' => 1131, 'destinationPage' => 1132 ); $modules->get("ProcessAdminActions")->CopyFieldContentToOtherPage($options); Hopefully you'll find a use for this in your hooks or template files.
    1 point
  28. Hi everyone, To celebrate @teppo featuring this module in PW Weekly, I have added a new action: Create Users Batcher It lets you quickly create many users by entering: "username, email address" on separate lines in a textarea. This action requires the EmailNewUser module and it must be configured to automatically generate a user password. The action checks for this module and that setting before it will let you proceed. I also recommend that you install the PasswordForceChange module to reduce the risks of having emailed a password to a user. You can set multiple roles to be added to each new user. Be aware that at least one of these roles must have the "profile-edit" permission so that the user has the ability to change their password when they first login. Note that EmailNewUser will report each successful user creation and email sent success. I hope that the next time you need to create several users for a new client that you'll give this a try. And of course, don't forget to send me your own actions for inclusion with the module
    1 point
  29. Hmm. Wordpress uses a script/styles wp_enqueue_scripts hook and a wp_enqueue_script/style function that is quite intelligent. It allows you to enqueue a script and any dependencies. WP then makes sure the dependency is loaded before the script that depends on it. Even if the dependency is not itself queued to be loaded on that page, the dependency argument will force it to be loaded. https://codex.wordpress.org/Function_Reference/wp_enqueue_script For instance, if your script depended on jquery but jquery was not loaded by default (or you wanted to ensure it was), doing this... function my_scripts_loader(){ wp_enqueue_script('my_script_handle', 'my_script_url', array( 'jquery' )); } add_action( 'wp_enqueue_scripts', 'my_scripts_loader' ); ...would load the script previously enqueued with the handle jquery. And then if your script was itself needed for another dependent script, you could: function next_script_loader(){ wp_enqueue_script('next_script_handle', 'next_script_url', array( 'my_script_handle' )); } add_action( 'wp_enqueue_scripts', 'next_script_loader' ); So the script load order would be: jquery my_script_handle next_script_handle Scripts/styles enqueued this way are spat out in the wp_head or wp_footer template function. There's an in_footer argument for putting a script in the footer. Probably wouldn't be hard to use that system in PW core, or roll your own. It's all about queueing the enqueued scripts and loading any given dependencies in the right order.
    1 point
  30. I recently had to setup front-end system to handle logins, password resets and changing passwords, so here's about how it was done. This should be functional code, but consider it pseudocode as you may need to make minor adjustments here and there. Please let me know if anything that doesn't compile and I'll correct it here. The template approach used here is the one I most often use, which is that the templates may generate output, but not echo it. Instead, they stuff any generated output into a variable ($page->body in this case). Then the main.php template is included at the end, and it handles sending the output. This 'main' template approach is preferable to separate head/foot includes when dealing with login stuff, because we can start sessions and do redirects before any output is actually sent. For a simple example of a main template, see the end of this post. 1. In Admin > Setup > Fields, create a new text field called 'tmp_pass' and add it to the 'user' template. This will enable us to keep track of a temporary, randomly generated password for the user, when they request a password reset. 2a. Create a new template file called reset-pass.php that has the following: /site/templates/reset-pass.php $showForm = true; $email = $sanitizer->email($input->post->email); if($email) { $u = $users->get("email=$email"); if($u->id) { // generate a random, temporary password $pass = ''; $chars = 'abcdefghjkmnopqrstuvwxyz23456789'; // add more as you see fit $length = mt_rand(9,12); // password between 9 and 12 characters for($n = 0; $n < $length; $n++) $pass .= $chars[mt_rand(0, strlen($chars)-1)]; $u->of(false); $u->tmp_pass = $pass; // populate a temporary pass to their profile $u->save(); $u->of(true); $message = "Your temporary password on our web site is: $pass\n"; $message .= "Please change it after you login."; mail($u->email, "Password reset", $message, "From: noreply@{$config->httpHost}"); $page->body = "<p>An email has been dispatched to you with further instructions.</p>"; $showForm = false; } else { $page->body = "<p>Sorry, account doesn't exist or doesn't have an email.</p>"; } } if($showForm) $page->body .= " <h2>Reset your password</h2> <form action='./' method='post'> <label>E-Mail <input type='email' name='email'></label> <input type='submit'> </form> "; // include the main HTML/markup template that outputs at least $page->body in an HTML document include('./main.php'); 2b. Create a page called /reset-pass/ that uses the above template. 3a. Create a login.php template. This is identical to other examples you may have seen, but with one major difference: it supports our password reset capability, where the user may login with a temporary password, when present. When successfully logging in with tmp_pass, the real password is changed to tmp_pass. Upon any successful authentication tmp_pass is cleared out for security. /site/templates/login.php if($user->isLoggedin()) $session->redirect('/profile/'); if($input->post->username && $input->post->pass) { $username = $sanitizer->username($input->post->username); $pass = $input->post->pass; $u = $users->get($username); if($u->id && $u->tmp_pass && $u->tmp_pass === $pass) { // user logging in with tmp_pass, so change it to be their real pass $u->of(false); $u->pass = $u->tmp_pass; $u->save(); $u->of(true); } $u = $session->login($username, $pass); if($u) { // user is logged in, get rid of tmp_pass $u->of(false); $u->tmp_pass = ''; $u->save(); // now redirect to the profile edit page $session->redirect('/profile/'); } } // present the login form $headline = $input->post->username ? "Login failed" : "Please login"; $page->body = " <h2>$headline</h2> <form action='./' method='post'> <p> <label>Username <input type='text' name='username'></label> <label>Password <input type='password' name='pass'></label> </p> <input type='submit'> </form> <p><a href='/reset-pass/'>Forgot your password?</a></p> "; include("./main.php"); // main markup template 3b. Create a /login/ page that uses the above template. 4a. Build a profile editing template that at least lets them change their password (but take it further if you want): /site/templates/profile.php // if user isn't logged in, then we pretend this page doesn't exist if(!$user->isLoggedin()) throw new Wire404Exception(); // check if they submitted a password change $pass = $input->post->pass; if($pass) { if(strlen($pass) < 6) { $page->body .= "<p>New password must be 6+ characters</p>"; } else if($pass !== $input->post->pass_confirm) { $page->body .= "<p>Passwords do not match</p>"; } else { $user->of(false); $user->pass = $pass; $user->save(); $user->of(true); $page->body .= "<p>Your password has been changed.</p>"; } } // display a password change form $page->body .= " <h2>Change password</h2> <form action='./' method='post'> <p> <label>New Password <input type='password' name='pass'></label><br> <label>New Password (confirm) <input type='password' name='pass_confirm'></label> </p> <input type='submit'> </form> <p><a href='/logout/'>Logout</a></p> "; include("./main.php"); 4b. Create a page called /profile/ that uses the template above. 5. Just to be complete, make a logout.php template and create a page called /logout/ that uses it. /site/templates/logout.php if($user->isLoggedin()) $session->logout(); $session->redirect('/'); 6. The above templates include main.php at the end. This should just be an HTML document that outputs your site's markup, like a separate head.inc or foot.inc would do, except that it's all in one file and called after the output is generated, and we leave the job of sending the output to main.php. An example of the simplest possible main.php would be: /site/templates/main.php <html> <head> <title><?=$page->title?></title> </head> <body> <?=$page->body?> </body> </html>
    1 point
×
×
  • Create New...