Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 10/18/2013 in all areas

  1. 7 points
    Hi i would like to share with you guys, a website i made thx to Processwire. Im super happy with processwire and this community. Ty for help everyone. here is the site: chemik-police.com
  2. 4 points
    Pagetree Add New Child Reverse New Pages in Descending Sortorder (newest first) while sortmode can be "Manual Drag-n-Drop" When a site display an overview of the latest posts, news, image-albums, etc. the newest entries should be on top of the list. We can achieve that by using an automated setting for the sortfield e.g. when the page was created = "-created". But this way we are not able to manually move a single page in the tree. This module enables us to do exactly that. It works with manually created pages, with pages created via the API, also when bootstrapped by importer scripts. Pagetree "Newsitems" with 3 newsitems sorted in descending order. New created item 4 is added to the top. To change the order click item 3 and drag it to the top and drop it. How to use it Download the module into your site/modules/ directory and install it. In the config page you find a single textarea field. Here you can enter the templatename or page-ID of the page which children should get reverse added, - optionally followed by a comma and the child-templatename if you need a more precise selector. You can add as many parents as you like, but only one on each line and in this format: TEMPLATE-NAME or PAGE-ID[,CHILDTEMPLATE-NAME]. A few examples: newsitems posts,post 1042 1033,album You want set your template(s) sortfield(s) to 'Manual drag-n-drop' if not have done already. ATTENTION You need to setup the TreeParent and the module config when there are no children in it! Otherwise it will not work! Also disabling the module once you have added children and then add one new page to it will mess up all! (You may think about to install the module as permanent in critical situations.?! see below ->) If you need to install it in a site for an already existing branch, you can do it this way: move / rename your existing branch create a new (empty) branch with the original name move your childpages into the new branch remove the renamed (and now empty) old branch DOWNLOAD - Version 1.0.2 get it from the Modules Directory Want to make it bulletproof? If you are concerned that the module settings could be dropped by other users or that the module itself could be uninstalled by accident, you may edit the module file directly: add the settings to the class constant permanentValue uncomment setting for permanent in the ModuleInfo This way the permanent settings couldn't be dropped by accident. To change it you first need to edit the modules file again. Example: You have two settings in the inputfield of the modules config, without permanent setting: parenttemplate1,childtemplate1 parenttemplate2,childtemplate2 Now you want to have the the first setting become bulletproof permanent: a) you enable the setting in the getModuleInfo, (uncomment setting for permanent) b) you write your permanent settings under the constant permanentValue const permanentValue = "parenttemplate1,childtemplate1"; After both steps, the module cannot get uninstalled anymore (Step a), and the first setting cannot get deleted anymore (Step b), as it is recreated with every call of the configscreen. (See first code line of method getModuleConfigInputfields) If you want to keep both definitions permanent, write them separated with a newline character "\n" : const permanentValue = "parenttemplate1,childtemplate1\nparenttemplate2,childtemplate2"; History of origins create pages via API, how add to the top of tree? Create new child as top sibling rather than bottom? New page on top? Pin Page to Top of Page Tree? move and sort pages with the API
  3. 4 points
    Hey guys! Another tiny little PW site we have built in the last few weeks. Really really reaaaaaally small budget, so nothing is really perfect on this website. But the client (a friend of mine, he is a teacher and a hobby author) is happy to now have more control about his content, speaking of his short stories and novels. See for yourself - feedback welcome: http://www.peterhohmann.net
  4. 3 points
    I created a Modul which extends Language Translator (Core) Modul, with a select-field to choose translatable files not translated yet. But it doesn't work perfectly, because the language to be translated isn't set by default. Even if I use the Standard Language Translator, no translated files will be listed. Even then, if I have set translation files for all my languages. If I go to setup -> language, choose a language and start to edit a translation file, the language-to-translate will be set in the system. Now I can go to the Language Translator and it looks like I had expected: Just to be clear I am not talking about the user language. I think it would be useful either to have a Language Selector in the Module Language Translator to select the language before the files are (not) displayed, or to set a default language-to-translate, which will be displayed in the Head of Language Translator to be clear which language is in processing. I will have a deeper look to find a solution. 1 hour later: looks like it would work now. I initialized the modul with the users language by default, if nothing else is set (GET or SESSION) I made an update on github. Maybe its a better idea to make the Language-Translator a Child Page of the specific Language Page. ... or to go sleeping Good Night ... 17.10.13 Updated the Module today with a Language Switcher and a clear headline which let you know in which language you are. Working fine on my System now. Looks like: @experts: please check Get the Module here: https://github.com/kixe/ProcessLanguageTranslatorPlus or here: http://modules.processwire.com/modules/process-language-translator/
  5. 3 points
    This is good discussion in my opinion. I agree with both, Felix and slkwrm. It is very important to keep things up to date and use best practices. As Ryan has many times stated, he is more "in home" with PHP than front end stack. But in the other hand using too many "cutting edge" methods/libraries/etc is dangerous too: it always makes steeper curve to learn and start using. Anyways: I am really enjoying this discussion and the constructive tone that Felix is leading here!
  6. 3 points
    I'd love to hear the methodology you would have chosen! I also not a big fan of jQueryUI for the same reasons you've already mentioned. Removing it would mean to rewrite most of the core JS though. That'd be a pretty substanical decision to make. -- How would using modular patterns change this? As stated before: the only thing "new" would be require.js. Apart from this BEM would even make it easier to change things (and you don't have to use it yourself if you are developing a module). You're right. Processwire is blazing fast. I'm only drawing a picture of a "better" (from my point of view) architecture. Well if you count in the various module developers which also tend to inject customisations into the backend (new fields, admin pages...) you actually HAVE a huge amount of people working on the backend and NEED some sort of standardization. Just look at all this !importants in every module. Once again: I never mentioned replacing jQuery with something else (especially not ExtJS which is a nightmare). I'm fine with using it although the way it is used could be more modular and less dependant on certain dom structures (proper event delegation, micro-templating or even directives like in angular would be fine). Yes and no. The "cleanest" way would to wrap all (core) modules into a define(...); closure. You could go and "shim them" all instead. But that's a nasty thing to do. This - for some people - is quite a subjective one. But from a "professional" point of view there are quite a lot of things that could be done better (in terms of UI/UX). PLUS: If you want to sell/market something it better looks "sexy" Accessability is more like a way of thinking about and architecturing things. Many of the core modules which either produce DOM-Elements or modify them (js) would need some tweaking. This only covers the PHP Part. No JS-Testing until now (there are again some requirements for this - scripts need to be written a certain way to make testing efficient and reasonable). Maybe you're right. I'll explain this a bit further in an upcoming post as i don't have time to write down all my thoughts on this now. This has a lot to do with how different personalitys and the way they handle changes to things they are already used to. Maybe it's the best way to start off with a theme, get some feedback and then as development continues some ideas and code might find their way back into pw. I don't like the idea of starting a fork of PWs backend as i think this would be pointless and do more harm to PW than it would help. Nevertheless it'd be great to keep this conversation up and going.
  7. 2 points
    Updated for compatibility with current dev version 2.3.5
  8. 1 point
    This tiny module is intended as a helper for Ryan's Hanna Code module by providing a way to select existing Hanna Code tags within the editor. This is something I felt our clients needed in order to start properly using Hanna Code tags. See attached screenshot for details -- there's really not that much to it at the moment. Each editor requires it's own plugin and currently I've only cooked one up for CKEditor, where the plugin presents itself as a context menu item (visible on right click). I'm planning to expand the feature set of that one slightly and then probably convert the CKEditor plugin to TinyMCE, but that's just about it. Ideas are welcome, though. Some of the code is pretty much duplicated from Ryan's original module. I hope he doesn't mind -- though for the record I've also tried to make it very clear in the source what part that is and where it's from.. GitHub: https://github.com/teppokoivula/HannaCodeHelper Modules directory: http://modules.processwire.com/modules/hanna-code-helper/
  9. 1 point
    This tutorial will outline how to create a membership system that requires account activation via email. If you have a decent understanding of ProcessWire it isn't difficult at all! Create additional fields By default ProcessWire has a name, email, and password field for the user template. To allow for account activation we will have to add a couple more fields. Create the following fields and add them to the systems default user template. You can make ProcessWire show the system templates by going to setup -> templates -> toggle the filter tab -> show system templates -> yes. user_real_name user_activation Okay great, now that you have added the two additional fields to the user template we can start to code the registration form. I am not going to spend a lot of time on this part, because there is a tutorial that describes creating forms via the API. Create the registration form Once you have followed the tutorial on creating forms, you will have to add a couple of sections to your new form! <?php include("./functions.php"); require("/phpmailer/class.phpmailer.php"); $out = ""; $errors = ""; //create form //full name field //email field //username field //password field //submit button //form submitted if($input->post->submit) { $form->processInput($input->post); //instantiate variables taking in the form data $full_name = $form->get("full-name")->value; .... /* * Create the activation code * You can add a random string onto the * the username variable to keep people * from cracking the hash * ex $activation = md5($username."processwire"); */ $activation = md5($username); $activation_code = $config->httpHost."/activation/?user=".$username."&hash=".$activation; //check for errors if($form->getErrors() || username_validation($username) == 0) { $out .= $form->render(); //process errors /* * this checks to makesure that no one has the username * I have a functions file that I import to the pages I * need it on */ if(strlen($username) != 0){ if(username_validation($username) == 0) { $username->error = " "; $errors .= "Sorry that username is already taken!"; } } } //the registration was successful else { $out = "Thank you for registering!<br><br>"; $out .= "An email has just been sent to " . $email . " with the url to activate your account"; /* * In this example I am using phpmailer to send the email * I prefer this, but you can also use the mail() function */ $mail = new PHPMailer(); $mail->IsHTML(true); $mail->From = "email@domain.com"; $mail->FromName = "Register @ Your Site"; $mail->AddAddress($email); $mail->AddReplyTo("email@domain.com","Register @ Your Site"); $mail->Subject = "Registration"; $mail->Body = " Hi " . $full_name. ", <br>" . "Thanks for registering at Your Site. To activate your email address click the link below! <br><br>" . "Activation Link: <a href='http://".$activation_code."'>".$activation_code."</a>"; $mail->send(); //create the new user $new_user = new User(); $new_user->of(false); $new_user->name = $username; $new_user->email = $email; $new_user->pass = $password; $new_user->addRole("guest"); $new_user->user_full_name = $full_name; $new_user->user_activation = $activation; $new_user->save(); $new_user->of(true); } } //form not submitted else { $out .= $form->render(); } ?> <h2>REGISTER</h2> <div class="errors"><?php echo $errors; ?></div> <?php echo $out; ?> Okay so that outlines the entire form. Let me get into the important parts. Checking for a unique username /* * check if username exists * return 1 username is valid * return 0 username is taken */ function username_validation($username) { $valid = 1; $check = wire("users")->get($username); if ($check->id) { $valid = 0; } return $valid; } We don't want to try and add a username if the username is already taken, so we need to make sure to validate it. If this returns 0 you should output that the username is already taken, and the user needs to choose a different one. Generating an activation code /* * Create the activation code */ $activation = md5($username); $activation_code = $config->httpHost."/activation/?user=".$username."&hash=".$activation; This generates an activation code. It does so by encrypting the username variable and then combines the username and activation code into a url for a user to visit. Now we have to process the activation code. As the teppo recommended, it is a good idea to add an extra string onto the $username when encrypting it with md5. If you don't do this, people may crack it and allow for mass signups. $activation = md5($username."Cech4tHe"); Activate the user <?php include("./head.inc"); include("./functions.php"); /* * this will pull the username and * activation code from the url * it is extremely important to * clean the string */ $activate_username = $sanitizer->text($_GET['user']); $activate_hash = $sanitizer->text($_GET['hash']); if(wire("users")->get($activate_username)->id) { if(strcmp(wire("users")->get($activate_username)->user_activation, $activate_hash) == 0 || wire("users")->get($activate_username)->user_activation == 0) { echo "Your account has been activated!<br><br>"; $activate_user = wire("users")->get($activate_username); $activate_user->of(false); $activate_user->user_activation = "0"; $activate_user->save(); } else { echo "There was an error activating your account! Please contact us!<br><br>"; } } else { echo "Sorry, but that we couldn't find your account in our database!<br><br>"; } include("./foot.inc"); This pulls the username and activation hash from the url. It then goes into the database and looks for the user. Once it finds the user, it get's the user_activation hash and compares it to the one in the URL. If it matches, it activates the user by setting user_activation to zero. Clean the url You can user the built in $sanitizer->text() method to clean the url. This will keep people from inserting special characters that can break the page. Keeping unactivated users out You aren't done yet! Now you will have to choose which areas you want to restrict to activated users only. An activated user's user_activation field will now equal zero. So if you want to restrict a section check to make sure it is zero...... if($user->user_activation != 0) { echo "Sorry, but you need to activate your account!"; } else { // activated users }
  10. 1 point
    Hey there! We're creating a great new website for a large non-profit. Our sharp and enthusiastic front end web developer has created a set of responsive templates, and we want you to whip up a processwire cms to manage it. You'll also get to apply your advanced UI knowledge to planning and implementing features like advanced google maps integration, social media feed integrations, and some advanced UI implementations (JS, jQuery, AJAX, etc). You are fast and talented, and enjoy collaborating. We're on a tight timeline, so hopefully you'll be able to jump right in to the fun as we get this baby live! Contact David at processwire@gladcraft.com
  11. 1 point
    You can code the redirect yourself instead setting it in the templates access settings: if (!$user->isLoggedIn()) { $session->redirect($pages->get('/login/')->url . '?message=' . (int)$input->get->message); } Or store the message ID in a session variable and read it out on your login page. (Code not tested... )
  12. 1 point
    Here are a couple of related posts that might be worth a read: http://processwire.com/talk/topic/2989-module-that-outputs-a-static-site/ http://processwire.com/talk/topic/4327-dental-practice-web-site/
  13. 1 point
    Yes, ProCache caches the pages in a folder and adds a redirect rule to your .htaccess, but I don't think it's possible to store these files on another folder. And the cache files are only created on the first request. This mean you have to visit each page once to have a static Version of your whole site. If you just want a static version of your site I recommand using a sitegrabber or wget and upload these files to your server. I think the licence is valid forever, but you only get updates in the first year. Once installed you can keep ProCache running forever on the site. At least this is how I understood the licence, better ask Ryan if you want to know for sure.
  14. 1 point
    Hi NikNak, You should be able to change the title of the modules by changing the title value of the page. For example for Google Analytics, the page is (default) located under Admin. You can open the page and set another title for german. I think this should work? For translating strings inside the page, you'll have to translate the file "/site/modules/ProcessGoogleAnalytics/ProcessGoogleAnalytics.module", as Manfred suggested. Cheers
  15. 1 point
    I can't say anything about HTTP Response Header tweaking, but if you don't need sessions on your pages it sounds like a perfect candidate for Ryan's excellent ProCache Module. It creates static versions of your pages und you won't have any headers set by php, as no php will be involved when delivering the pages from the cache. I use ProCache on most of my pages, and the performance is really great, especially when combined with some of the best practices from HTML5-Boilerplates .htaccess file.
  16. 1 point
    I usually dont't exclude any folders and only clear the cache before uploading, but I think its save to exclude the contents of these folders: /site/assets/cache/ /site/assets/logs/ /site/assets/sessions/ But the folders themselves should exist and be writeable on the server too.
  17. 1 point
    not sure, but do you have a translation file for e.g. Google Analytics? If not, you should create one in the admin language translation section. Path is relative. Example: '/site/modules/ProcessGoogleAnalytics/ProcessGoogleAnalytics.module' Maybe then you see it in the menu.
  18. 1 point
    It doesn't work with negative numbers. They get corrected to 0 (zero) at some other points in PW, not only at Pages::setupNew()
  19. 1 point
    This does look great horst. I think it is something I am going to have to be aware of though as my page tree migrator module gets closer to release. I can see it being an issue if migrating pages from a site that has this installed, or to one that has it installed if the other doesn't. Not sure how to handle that, but we'll see Just curious - did you test the idea of negative number indexing? Might be opening another can of worms though!
  20. 1 point
    Well, client wanted it that right from the start. Maybe because his former website was really "fantasy" styled, with a nice "Adobe Flash" burning mouse cursor, spooky background music and dark dark wallpaper background with bats and all that stuff. .
  21. 1 point
    Wow, I can't wrap my mind around this. How is this possible without heavy overhead. Great work Horst, thank You ! Sneakpeeked at the code... clever
  22. 1 point
    If you're wanting to share data between sites, check out the web services module: http://modules.processwire.com/modules/service-pages/
  23. 1 point
    Joe, I don't know if there's a way to kill the session in Processwire - it could be one of the assumptions the framework is based upon, and therefore not optional. Someone more familiar with internals can speak to this, but yes, many websites can run fine without cookies. You could try to "unset" set-cookie, cache-control, expires, and pragma using mod_headers to get the response session-free and client-cacheable. I've never unset a header, and then set it to something else so I don't know how apache will handle resetting cache-control. Another option, albeit extreme, is to generate a static site from PW using wget. This will only work if the site rarely changes, but will ultimately be the most optimized way to deliver the site. FWIW - the reason I recommended not caching html to the client is that once it is out there, it's impossible to invalidate. Where a server-side cache can invalidate the cached page when updated through the admin, a client side cache will not check for updates and it can lead to trouble. The html itself is generally a very small file (relative to the download of images, css, js), so the performance gains are minimal. Looking at your headers, you could also get a nice performance bump using mod_deflate to gzip the transfer of text (html, css, js). Hopefully this helps.
  24. 1 point
    If think you could be ok but if you ever want to move from location A, which is on root, to location B in a subdir or something, i'm guessing all links in the cached files will be off. Also, ftp isn't that fast, and there can potentially be a lot cache files. I wouldn't include them in your copy routine, the will be regenerated fast enough. For me however, it's also a matter of being not quite sure, so maybe others can share their routines.
  25. 1 point
    @joshuag: Just happened to read this thread. Thanks for HTML KickStart ! Very nice! That might be helpful in the future - bookmarked it. (...lazy man always happy to have tools that save work )
  26. 1 point
    Since $users are basicly the same as $pages you can follow soma's instructions or look into this thread. You are not the first Also you might want to use Google to search the forum with the query: site:processwire.com/talk.
  27. 1 point
    Kahn made a FrontendUserProfiles module.
  28. 1 point
    i am back... omg,its working i dont changed something,just do as you say : add "$item->id" then i found its work correctly its a big joke,i think if the cache caused? my work space in localhost (appserv + win7 x64) @adrian thank you very much!
  29. 1 point
    Ok, well this will hopefully get you started. I haven't seen much on the forum or the docs about doing this. This code is an adaption from what I have just put together to support repeaters in the page tree migrator module. Because the migrator needs to take the IDs from existing repeaters, convert them to names, and then back to IDs, I think what I ended up having to do was probably more complicated than what should be needed in your situation. It worked perfectly for my needs and from some quick testing I think version should work for your needs, but there might be a much simpler way to do it. You will need to adjust the first three lines, and then the lines under both the //Add fields to.. comments. This code creates the repeater field, the necessary fieldgroup and template, but you would still need to add the actual repeater field to the required template, but I get the feeling you have that sorted already with the code you posted. $titlefield = wire("fields")->get("title"); $bodyfield = wire("fields")->get("body"); $repeater_name = "newrepeater"; $f = new Field(); $f->type = $this->modules->get("FieldtypeRepeater"); $f->name = $repeater_name; $repeater_fg = new Fieldgroup(); $repeater_fg->name = "repeater_$repeater_name"; //Add fields to fieldgroup - add others as necessary $repeater_fg->append($titlefield); $repeater_fg->append($bodyfield); $repeater_fg->save(); $repeater_template = new Template(); $repeater_template->name = "repeater_$repeater_name"; $repeater_template->flags = 8; $repeater_template->noChildren = 1; $repeater_template->noParents = 1; $repeater_template->noGlobal = 1; $repeater_template->slashUrls = 1; $repeater_template->fieldgroup = $repeater_fg; $repeater_template->save(); $repeater_page = "for-field-{$f->id}"; $f->parent_id = $this->pages->get("name=$repeater_page")->id; $f->template_id = $repeater_template->id; $f->repeaterReadyItems = 3; //Add fields to the repeater - add others as necessary $f->repeaterFields = $titlefield; $f->repeaterFields = $bodyfield; $f->save();
  30. 1 point
    Thanks Diogo! That did the trick. I've posted the latest update to the admin theme on dev and this includes the bundled Arimo fonts. I'm curious if this makes it look better for you guys on Windows? This update also includes several other tweaks and minor fixes.
  31. 1 point
    Didn't test this one: hope it works. $home = $pages->get("/"); // all menu item exept home $page_array = $home->children(); // count all items in $p_array $count = count($page_array); // all items divided by 2 + rounding down to integer $position = floor($count/2); $insert_after_page = $page_array->eq($position); $page_array->insertAfter($home, $insert_after_page); then: foreach($page_array as $p) { do your funky stuff }
  32. 1 point
    Thanks for posing this Kyle! A few things to mention: For even more security with the activation code, you might want to use something completely random that isn't influenced by the username. We have something built-in that will do the trick: $p = new Password(); $hash = $p->randomBase64String(100); // 100=length of string See here how it works: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Password.php#L154 (code is originally from Anthony Finta's password_compat library). Make sure that you are using $sanitizer->pageName("username"); for your username sanitization. Using $sanitizer->text(); is not adequate for sanitizing usernames or any selector values. In your function that checks for duplicate usernames, check for duplicate emails as well. When you check for users or emails do $users->get("name=$username") rather than $users->get($username); as this will ensure it's checking for only the username, and not potentially confusing a numeric username with a user ID. I recommend using $input->get->var rather than $_GET['var'] because the $input->get version makes it so that you never have to worry about PHP's magic_quotes setting. Last thing to mention is that it might be good to include what type of fields the user_real_name and user_activation are. I believe these are supposed to be text fields, but wasn't sure (especially for user_activation) until later.
  33. 1 point
    LanguageLocalizedURL module Localized URL generator and parser You can find the last version here: http://modules.proce...-localized-url/ Or from the repository on github: https://github.com/m...e-localized-URL This module is useful to generate localized url using the language code as first 'folder', and then the localized titles of the nested pages: (removed previous instructions to prevent double maintaining.) See more infos in readme of the module with instruction and informations. https://github.com/m...aster/README.md
  34. 1 point
    Thanks, I think I've got this fixed. Try out the latest dev commit. Your best bet is to use no language segment for your default language. So when you edit your homepage, on the "settings" tab, make sure the default language field is blank rather than "en".
  35. 1 point
    This just means that everything worked as expected; Redirects module doesn't do redirect if PW page with that URL exists (it only does redirect when 404 is encountered), so when using it you shouldn't create matching page.. try removing it and redirect should work There's a slight problem in your code; it would seem that you're using (probably undefined) variable called $redirect instead of $page->redirect (redirect property of $page object, ie. the value of redirect field.) If your intention was to use value from field called "redirect", try this instead: <?php $session->redirect($page->redirect);
  36. 1 point
    Thanks for the feedback adamkiss.
  37. 1 point
    Attached is an entire Fieldtype and Inputfield that show an example of 3 inputs for each image (title, tags and description). I've also set it up so that you can just change the schema in the getDatabaseSchema() function and it should automatically work with whatever varchar or text fields that you add. Though note that you'll want to make those changes before you create any fields with it. This works because the only place these custom fields are defined is in that schema, and everything else in the Fieldtype and Inputfield just picks it up from that schema. In the future, I will probably use this as a foundation for a more advanced image/file fieldtype where you can specify the schema from the field's configuration in the admin, rather than modifying the code. But figured this would be a good example for what you asked for. Ryan FieldtypeImageExtra.zip
×
×
  • Create New...