Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/21/2012 in all areas

  1. Have you seen this? http://modules.processwire.com/modules/data-table/
    3 points
  2. I just pushed a new module to Github. I really liked Soma's idea (and execution!) to learn new frontend stuff while building useful modules to PW. While Soma is learning Knockout, I actually find AngularJS more interesting. So here is my first "AngularJS-powered" module: FieldtypePoll. This is simple polling fieldtype for (not so serious) votings like: Q: How is the weather today? a) Fine b) Rainy c) I don't know, been coding all day This should be all usable already, so if you are adventurous and want to help me debug, this is how to get started: 1. Grab the code -> https://github.com/a...a/FieldtypePoll (actual fieldtype and inputfield) -> https://github.com/apeisa/AngularJS (AngularJS and AngularUI for PW) 2. Install the FieldtypePoll module 3. Create new field, choose "Poll" as a new fieldtype 4. Add field to a template 5. Edit your template file, output the field: echo $page->whatEverNameYouGaveInStep3 6. Add some css: .PollApe .percentage { background: black; font-size: 10px; min-width: 5px; border-radius: 4px; padding: 4px 8px; text-align: right; color: white; margin-bottom: 0.6em; } .PollApe .PollApeTotalVotes { border-top: 1px solid #ccc; }
    2 points
  3. Methinks this... 'url' => "./$event[id]", // event ID is the url segment ); return json_encode($json); // <<<< wrong data? } ...should be this... 'url' => "./$event[id]", // event ID is the url segment ); return json_encode($items); // <<<< right data? }
    1 point
  4. Hi onjegolders, Oh, I don't think the poor horse needs to be put down. Underneath, he's still a horse. I should have mentioned that he goes by the name "PHP." However, he might do better if his trainers stopped making him wear layers and layers of wool blankets whenever he raced, and if they stopped putting weights on his feet, and it would also help if his jockey was not a Sumo Wrestler. Thanks, Matthew
    1 point
  5. I notice in .htaccess there is code to redirect to the www version of the site (if you uncomment it), what about vice versa? Because currently you can access the site from either www or no www. Could this be made a selection during install?
    1 point
  6. This is how html5boilerplate does it. the nice thing is it works without specifying your domainname and could easily included in your own default htaccess: # Rewrite "www.example.com -> example.com" <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] </IfModule> https://github.com/h5bp/html5-boilerplate/blob/master/.htaccess#L344
    1 point
  7. We force a non-www on processwire.com, but it seems that not many sites do that for whatever reason. If you want to do that, here's the code you can use in your htaccess (replacing processwire.com with your domain): RewriteCond %{HTTP_HOST} ^www\. RewriteRule ^(.*)$ http://processwire.com/$1 [R=301,L] This isn't technically part of ProcessWire's runtime configuration because the rules in the htaccess file are what ultimately gives control to ProcessWire (they are executed before ProcessWire is).
    1 point
  8. I've posted new version, it's mobile compatible (smartphones & tablets), it works on IE6-8 but without shadows and caption opacity (I think that those browser days are numbered anyway). EDIT: In IE8 everything works fine... (shadows etc.) Don't forget to put meta tag in the head of your document to make it show correctly: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> Preview link - same as in the first post.
    1 point
  9. In your php.ini, you should also set the values for "max_execution_time" and "max_input_time" to more than 30 seconds (30 = default value I guess). But I also suggest to upload huge files via FTP.
    1 point
  10. Regardless of whether handling this with processwire you should change your server variables to handle such a request. Your php.ini should be adjusted for it (at least): upload_max_filesize = 350M post_max_size = 350M And your apache should be configured too: memory_limit = 400M Update (thx Wanze) You should also adjust settings like max_execution_time max_input_time in your php.ini... I don't know if your clients host has such capabilities (-> memory limitations for such one vhost) but you should consider to convince your client to upload such files with ftp (not with http) and it is less error-prone for you and him with ftp...
    1 point
  11. soma....I owe you some beer, coffee what ever
    1 point
  12. I searched through my stuff and found 2 sites I saved as favs from old research. Wordpress has a plugin for IDX. I think I read the activation for the plugin is with a user code given to the realtor for their own site. http://www.diversesolutions.com/ http://wordpressreal...-idx-theme.html And your right Pete, everyone shares the same live data feeds. For example, five realtors can show and sell the same target listings for a given location area, regardless of what company and realtor has it listed or for sale. I also read somewhere that after 3 impressions on a single property triggers a event (a popup box)offering the viewer to get more info on properties(by email, I think) in the same area of like-kind. Thereby placing them into the database as a client to work with through the system with target specific information streamed automatically, as a feed. I think they can request more info, a call back, chat message, etc. immediately. Just a little more to chew on...I am going to contact some realtors I know and see what info I can get to aid this. Cheers, Grant
    1 point
  13. It's working now ... I wasn't aware $event->return holds what the name implies Thanks!
    1 point
  14. Greetings, onjegolders: I totally understand where you're coming from! I've spent the past three years using Joomla, and I am now moving away from it entirely in favor of ProcessWire. I still get clients that specifically ask for Joomla, and I have a couple of development partners that still want to use it. I'm convinced that it is my job to move away from Joomla. Maybe I can offer some general ways to approach this... I've got several opinions on this matter. But let me focus on one particular area that you mentioned... THE "CLICK TO INSTALL" ILLUSION When I first started using Joomla, I thought it was great to have all those extensions ready to install with a few clicks. But as time went on, I found that my clients wanted more specific styling and actions. Since every module and extension for Joomla is nearly a separate application, each one re-doing models and coding that often were already done by something else in the Joomla ecosystem (more on the Joomla ecosystem in another post), each one comes with its own (sometimes very extensive) styling and coding assumptions. These very often (let me emphasize very often) conflict with styling definitions you're using elsewhere in the site. If you just want to insert stuff into a pre-fab template and use it exactly as is, you can get along pretty well. But I have found it is inevitable that clients need something more customized down the line. At that point, all the time you "saved" with point-and-click is lost when you have to figure out what that extension developer did in there, or when you have to stop using an extension altogether and find another one that does something better and have to figure out how to transfer the arcane material from one extension's database structure into another one (for example). By contrast, in a community like ProcessWire, you can get the snippets of code necessary to do the same thing as the point-and-click operations. The difference is, the styling is up to you. Even more importantly, you are very clear about how the thing was coded and can re-code pretty quickly. The key here is having a strong community, because if there are people to help you out with the code it hardly takes any longer to do it that way than to install a "point and click" extension. Also, it's a real problem that in Joomla so many developers abandon their projects. Then you are left with a strange extension, and you are on your own anyway to decipher the code! I do agree that it's a difficult thing to convince people of this. But I'm becoming more confident in just stating that I can build the system they want, with more flexibility beyond the first stage. I've found that most clients do want to be able to add more features in the future. Another thing I have found: most people who say they want Joomla are only saying that because it's the first or second system that turned up in a Google search. But if you sit down with them and explain that you can go further with a system like ProcessWire, most clients will trust you. After all, the reason they are hiring you is because they want a professional to advise and direct them! If that were not the case, they would just build it themselves. I use a metaphor when sitting down with people who bring up the Joomla vs ____ comments.... It's like a horse race. At the starting gate, the Joomla horse jumps out to a fast lead. ProcessWire and CodeIgniter (for example) start off slower. By mid-race, it seems all but certain that Joomla will win. But more open systems build speed throughout the race. Coming around that last turn, you can see Joomla slowing down. By the end of the race, the Joomla horse is tired and confused, and often doesn't cross the finish line at all. Thanks, Matthew
    1 point
  15. Yes, method should be post. Since you will be submitting to the same page, all the code will go on the same template. You might want to do this as the action: <form id="orderForm" action="<?php echo $page->url ?>"> Now we have to test for the submission of the form. This test can be used also inside the form to output errors. I will use the radio button for this, since it will have a value for sure if ($input->post->premium) { // form was submited. Here is where we will collect all the information }else{ // you don't have to use the else, but here is the place to output something for when the form wasn't submited } // form should go outside the if statement To collect the information we will have to know where to send it to. I don't know if you decided on those things but, are you going to create a page for each transaction? Or a page for each client? Here I will assume you will want to save a page for each transaction. For this you will have already prepared, a template "transactions" with all those fields (customer_name, email, quantity, addons, premium), and I will assume that you will have all the transaction as children of the page "/order/". if ($input->post->premium) { // create a new transaction page $tr = new Page(); $tr->template = $templates->get("transaction"); $tr->parent = $pages->get("/order/"); // fill the fields with the collected and sanitized info. See here about sanitation in pw [url="http://processwire.com/api/variables/sanitizer/"]http://processwire.com/api/variables/sanitizer/[/url] $name = $sanitizer->text($input->post->customer_name); $email = $sanitizer->email($input->post->email); $quantity = (int) $input->post->quantity; // (int) makes sure that the input is a number $add_ons = $sanitizer->text($input->post->addons); $premium = $sanitizer->text($input->post->premium); $tr>of(false); // this was wrong on my fist post. must be false $tr->customer_name = $name; $tr->customer_email = $email; $tr->quantity = $quantity; $tr->add_ons = $add_ons; $tr->premium = $premium; //save the page $tr->save(); // send the email to you $subject = "new buy"; $message = "{$name} bought {$quantity}. His email is {$email}"; mail('youremail@example.com', $subject, $message); // here you can redirect to a confirmation page, or to the same page for another buy } // code for the form This was only the basic. You should also perform some validation in the php code, and check if everything is ok before creating the page. The most common way is to use a errors array.
    1 point
  16. 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...