Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/01/2015 in all areas

  1. Hi All, I am gladly posting my first site profile. Blue-VR Site Profile for ProcessWire Summary A site profile for corporate or personal website. Profile can be used with ProcessWire open source CMS/CMF version 2.3+. The front-end uses the Bootstrap 3.1 css framework for to get the responsiveness and mobile friendliness. Front-end Demo - bluevr.webcreate.lk Back-end Demo mode - bluevr-webcreate.lk/processwire (The username 'admin' and password 'bluevr2') Overall features * HTML5 & CSS3 + ({less}) * Build with bootstrap 3.1 * SEO Friendly * Clean & modern design * Responsive markup * Contact form and google map locations with multiple google markers * Testimonials using bxSlider * AIOM supports (Just install the module no need to touch the code) How to install Please take a copy of the latest ProcessWire (Replace the install, modules and templates directories with those in this profile, as shown below: - /site-default/install/ - /site-default/modules/ - /site-default/templates/ Make sure you do following steps as well 1. Add `tinymce` directory into /site-defaut. 2. Add the following two lines to your `/site/config.php` file: $config->prependTemplateFile = '_init.php'; $config->appendTemplateFile = '_main.php'; Download Github: https://github.com/gayanvirajith/BlueVrSiteProfile/ Credits I would like to thanks Ryan for giving us great CMS/CMF and modules. Hani AbuGhazaleh for a great module of Fieldtype: Select (AKA Drop Down) David Karich for providing such a nice module AIOM+. *** Please note that the site profile is still on testing stage. Thanks ------------------------------------------------------------------------ Edit: install instructions. Edit: Add credits Edit: Update live demo url Edit: Update back-end demo mode details
    2 points
  2. Jumplinks for ProcessWire Latest Release: 1.5.63 Composer: rockett/jumplinks ⚠️ NEW MAINTAINER NEEDED: Jumplinks is in need of a new maintainer, as I’m simply unable to commit to continued development. Jumplinks is an enhanced version of the original ProcessRedirects by Antti Peisa. The Process module manages your permanent and temporary redirects (we'll call these "jumplinks" from now on, unless in reference to redirects from another module), useful for when you're migrating over to ProcessWire from another system/platform. Each jumplink supports wildcards, shortening the time needed to create them. Unlike similar modules for other platforms, wildcards in Jumplinks are much easier to work with, as Regular Expressions are not fully exposed. Instead, parameters wrapped in curly braces are used - these are described in the documentation. As of version 1.5.0, Jumplinks requires at least ProcessWire 2.6.1 to run. Documentation View on GitLab Download via the Modules Directory Read the docs Features The most prominent features include: Basic jumplinks (from one fixed route to another) Parameter-based wildcards with "Smart" equivalents Mapping Collections (for converting ID-based routes to their named-equivalents without the need to create multiple jumplinks) Destination Selectors (for finding and redirecting to pages containing legacy location information) Timed Activation (activate and/or deactivate jumplinks at specific times) 404-Monitor (for creating jumplinks based on 404 hits) Additionally, the following features may come in handy: Stale jumplink management Legacy domain support for slow migrations An importer (from CSV or ProcessRedirects) Open Source Jumplinks is an open-source project, and is free to use. In fact, Jumplinks will always be open-source, and will always remain free to use. Forever. If you would like to support the development of Jumplinks, please consider making a small donation via PayPal.
    1 point
  3. Here is very simple abstract class that I hope would get ideas and contribution from community, so that different PW projects could use same payments methods in generic way: https://github.com/apeisa/Payment Currently Payment modules just assume it's found from /site/modules/Payment/Payment.php, but I would love to get it autoloaded somehow (I went with PW module dependencies and transformed the base class into PW module also). Also I have tried to keep this as minimum as possible - hopefully I have not left anything too important out. I have also created one two payment modules, that use this base class: https://github.com/apeisa/PaymentStripe/ https://github.com/apeisa/PaymentPaypal/ Please visit their repos for examples.
    1 point
  4. FieldtypeFontIconPicker Supported Icon Libraries FontAwesome 4.7.0 Uikit 3.0.34 IonicIcons 2.0.1 Cahangelog NOTE: Module store data without prefix, you need to add "prefix" when you want to show your icon on front-end, because some of front-end frameworks using font-awesome with different "prefix". Module will search site/modules/**/configs/IconPicker.*.php and site/templates/IconPicker.*.php paths for FieldtypeFontIconPicker config files. All config files need to return a PHP ARRAY like examples. Example config file : create your own icon set. File location is site/configs/IconPicker.example.php <?php namespace ProcessWire; /** * IconPicker : Custom Icons */ return [ "name" => "my-custom-icons", "title" => "My Custom Icon Set", "version" => "1.0.0", "styles" => array( wire("config")->urls->templates . "dist/css/my-custom-icons.css" ), "scripts" => array( wire("config")->urls->templates . "dist/js/my-custom-icons.js" ), "categorized" => true, "attributes" => array(), "icons" => array( "brand-icons" => array( "title" => "Brand Icons", "icons" => array( "google", "facebook", "twitter", "instagram" ) ), "flag-icons" => array( "title" => "Flag Icons", "icons" => array( "tr", "gb", "us", "it", "de", "nl", "fr" ) ) ) ]; Example config file : use existing and extend it. File location is site/configs/IconPicker.altivebir.php <?php namespace ProcessWire; /** * IconPicker : Existing & Extend */ $resource = include wire("config")->paths->siteModules . "FieldtypeFontIconPicker/configs/IconPicker.uikit.php"; $url = wire("config")->urls->templates . "dist"; $resource["scripts"] = array_merge($resource["scripts"], ["{$url}/js/Altivebir.Icon.min.js"]); $resource["icons"]["flag-icons"] = [ "title" => "Flag Icons", "icons" => array("tr", "en", "fr", "us", "it", "de") ]; $resource["icons"]["brand-icons"]["icons"] = array_merge($resource["icons"]["brand-icons"]["icons"], array( "altivebir" )); return $resource; After you add your custom config file, you will see your config file on library select box. Library Title (Location Folder Name). If your library categorized and if you have categorized icons set like uikit and fontawesome libraries, you will have category limitation options per icon field or leave it empty for allow all categories (default). Example : output if ($icon = $page->get("iconField")) { echo "<i class='prefix-{$icon}' />"; } MarkupFontIconPicker Usage // MarkupFontIconPicker::render(YourIconField=string, Options=array) echo MarkupFontIconPicker::render($page->YourIconField, [ 'prefix' => 'uk-icon-', // Icon class prefix, if you have different prefix, default is : "fa fa-" 'tag' => 'span', // Icon tag default is : "i" 'class' => 'fa-lg', // If you have extra cutom classes, for example : icons sizes, Array or Sting value 'style' => 'your custom styles if you have' // Array or String Value ]); Theme support Search support Category support
    1 point
  5. A quick tutorial how to create file downloads using pages You will be able to create a new page using template "PDF" (or any you setup), upload a pdf file. You then can select this page using page fields, or links in Wysiwyg. The url will be to the page and NOT the file itself. This will allow to keep a readable permanent unique url (as you define it), unlike /site/assets/files/1239/download-1.pdf, and you'll be able to update/replace the uploaded file without worring about its filename. Further more the file will also have an id, the one of the page where it lives. Clicking those links will download or open the file (when target="_blank") like it would be a real file on server with a path like /downloads/project/yourfile.pdf. You'll be also able to use the "view" action directly in the page list tree to view the file. Further more you'll be able to esaily track downloads simply by adding a counter integer field to the template and increase it every time the page is viewed. Since the file is basicly a page. This all works very well and requires only minimal setup, no modules and best of it it works in the same way for multi-language fields: Just create the language alternative fields like "pdf, pdf_de, pdf_es" and it will work without modifying any code! Still with me? ok PW setup Download folder: Create a template "folder" or "download-folder" with only a title needed. Create pages in the root like /downloads/project/ using this template. Setup the template for the pdf files 1. Create a new template in PW. Name it pdf 2. Goto template -> URLs tab and set the URL end with slash to no. (So we can have /path/myfile.pdf as the URL) 3. Create a new custom file field, name it pdf. Set its maximal count to 1 under -> Details tab. 4. Add the pdf field created to the pdf template. Easy. 5. Create a new "pdf" page using the pdf template under a download folder you created earlier. 6. Give it the title and in the name field add ".pdf" to the end (could also leave as is) Template PHP file for the pdf files 1. Create the template file pdf.php in your /site/templates folder 2. add the following code: <?php // pdf.php if($page->pdf){ wireSendFile($page->pdf->filename); } Done. To see the options you have with PW's wireSendFile() you can also overwrite defaults <?php // pdf.php if($page->pdf){ $options = array( // boolean: halt program execution after file send 'exit' => true, // boolean|null: whether file should force download (null=let content-type header decide) 'forceDownload' => false, // string: filename you want the download to show on the user's computer, or blank to use existing. 'downloadFilename' => '', ); wireSendFile($page->pdf->filename, $options); } Simple and powerful isn't it? Try it out. Some thoughts advanced Create as many file types as you like. It might also be possible to use one "filedownload" template that isn't restricted to one field type but evaluate it when being output using $page->file->ext, or save the file extension to the page name after uploading using a hook. One last thing. You can add other meta fields or preview images to the template and use those to create lists or detail pages. It's all open to goodness. Again all without "coding" and third-party modules. Further more you can use the excellent TemplateDecorator to add icons per template and have a nice pdf icon for those pages. This as a base one could also easily create a simple admin page for mass uploading files in a simple manner, and create the pages for the files automaticly. ImagesManager work in the same way. Cheers
    1 point
  6. A few weeks back, I had a little inspiration to design a new admin theme. The idea was to take several different themes, and merge them into one. Specifically, this little unfinished concept is a mix between the default admin theme (only in terms of layout), Reno, and a little bit of the theme that OroCRM/OroPlatform uses (called OroUi), where one would have a pin-bar at the top for frequently accessed pages. It's only an idea - no plans to create the theme at this point, considering I have no idea where to even begin (I'm sure it's not that difficult, though). What do you think?
    1 point
  7. @netcarver Today I could try your site on a fresh C1 ubuntu install; it was a bit jerky, but after I allowed hardware acceleration in Chromium, it was just like on my regular PC - I would say perfect - but judge yourself (see PM).
    1 point
  8. Looks lovely Gayan. You could create a demo for this over on lightning.pw - the guys over there do a free deal for free modules and I think that probably includes site profiles too! You might have to install this manually though, I don't think it lets you upload a site profile as part of the site creation process - but I may be wrong. Regardless, thank you for this profile!
    1 point
  9. Or just use a ProcessWire URL field rather than a text field...it will automatically add the http:// for you... ...and you can edit it if it is https:// you want..
    1 point
  10. Glad you found some solutions that are close. I haven't looked into the search module lately, but if you can hook into it, then you can probably have it skip results for pages with the user template that don't have the same name or parent as the current user. I'm on mobile now, or I'd check. Don't worry, the search issue can be solved.
    1 point
  11. Hi, finally I had some time to test @renobird modified version of PageEditPerUser and also @adrian HideOtherUserPages modules for my problem. I like to describe my process here for others that deal with the same problem. First “solution”: Modules used: PageEditPerUser 0.0.3 HiddenAdminPages 1.0.0. All users got the same two roles (thanks @renobird for the tip) Roles: editor (edit, add, (but not) delete) editor_sub (edit, add, delete) Because of the installed HiddenAdminPages I can restrict pages for each user. Disadvantage: The more pages/user the site has, the more work it is to restrict pages for a new user. Second “solution”: Modules used: PageEditPerUser 0.0.3 HideOtherUserPages 0.0.1 (Same roles as first solution) As long as the page the user needs to edit got the same name (Page = user-1 , User = user-1) he or she can just edit his own pages, regardless where they are located Pro: Unlike the first solution, you do not need to add pages to a restriction list. This works better if you deal with a lot of pages. Disadvantage: A Parent page needs to named after the user. For me this solution is okay. Third “solution”: As I mentioned in one of my earlier posts, a solution without any modules would be to have a template for each user and a role for editing just this template. No modules used Pro: Well, it works. ;-) Disadvantage: When you deal with, let say, 50 users, you also need 50 roles and 50 templates. A little bit confusing in the template/roles area. I guess you probably also have 50 files in the site folder on the server? You have to optimize/prepare your templates before you add them to processwire to be aware of future changes inside the template files. Big problem: So far all three solutions would work somehow, and I would prefer solution 2 for my problem but I discovered a new “problem” with solution 1+2. I had a test what happens when user 1 enters the name of user 2 in the search field of the backend. Processwire finds the Parent page and shows an “edit” in the search results. The same happens when user 1 enters a name of a child page that is only visible to user 2. Example user 1 enters "Blau" in the search field. user "Max Muster" also have a page named "Blau". So, in the search results both pages are visible and can edited by user 1. As a result when user 1 knows how the pages of user 2( or any other user) are called, it’s easy to find them and edit them. I got tears in my eyes. ;-) As solution 1+2 works for me somehow both are not usable from the view of security. Maybe I did something wrong here, not sure. The easiest way would be to restrict the search in the backend to just the pages the user can edit (as part of the modules of solution 1 or 2). Any thoughts on that? Thomas
    1 point
  12. I don't think you'll be able to do that in a PW selector, but you can sort it after you have the page array. I asked this question a long time ago - that thread should help you: https://processwire.com/talk/topic/3392-emulate-natsort/ I am not sure if natsort works with comma decimals, but maybe there is an alternative php function you can use if needed? I am sure one of the european PW devs will have some input if this is an issue. PS Welcome to the forums!
    1 point
  13. Hey guys, not specifically with HHVM, but i have wordpress running fine on HHVM, so i guess processwire should be ok, nice link Teppo!
    1 point
  14. @ivanr I had the same idea. Energy consumption of the Odroid-c1 is very attractive as measured here (http://frank-mankel.de/?p=392). So I guess, based on the measurements of Frank, It draws on average about three Watts an hour. That means 72 Watts for a whole day (24h). So 26280 a year, devided by 1000= 26,28 kW a year. 1kW costs 20 eurocent here, so that means 26,28 * 0,20 = 5,25 euro for a whol year 24h/day! It can draw at maximum 5V * 2A = 10 W (that's the power supply). Even at maximum power full time (which is not realistic at all!) it only costs 17,5 euro. But it will in reality probably be under 10 euros (about the same as Raspberry). Combined with the faster speed (mucht faster then the Raspberry Pi B+) it is very interesting to use as a webserver (certainly when you also use the faster Emmc module with it). So I ordered it (with the Ubuntu preinstalled emmc module) also because the Gigabit ethernet port attracted me (I have glassfibre 500Mb up- and down). I just received it yesterday and got it working with a normal monitor (you have to change the monitor settings in the Boot.ini for this from HDMI to DVI and choose the right monitor resolution). However the ethernet speed is a major disappointment. It does not seem to work at the proper speed they promised. I installed flashplayer with Chromium and ran a speedtest (needs flash) and it did not even reach 100 MB, while my PC and laptop reach 500MB. I found some posts about it, but it is not clear to me which offers the right solution and how to do that. I also discovered that the keyboard language settings won't work. You can adjust them, but the Odroid simply does not react to it. I use Dvorak and can't get it to work. I also would like a minimal Debian Wheezy install on the Emmc so I can install a Lamp-stack on it. That would make optimal use of the speed. It is not clear to me how I have to format the Emmc and put an image on it, without damaging or spoiling things. Again there are some posts about it, but still too fragmented information. I need a clear step-by-step guide. Anyone? So I have three questions: 1. Clear instruction how to get the gigabit speed of the ethernet port 2. How to adjust the keyboard language to Dvorak 3. Clear instruction how to install a fresh Debian Wheezy (minimal) on the Emmc module
    1 point
  15. Hello Adrian, thanks for your hints. I hope I fixed the possible errors with writeaccess. The filename is now the name of the dg_download page. It was something, that bothered me too! The uninstall method is currently removed, so no dataloss will happen on uninstall.
    1 point
  16. Multiple spaces shouldn't be a problem, but no spaces will be.
    1 point
  17. I think both can be achieved: free-form language names and using language specific language packs for modules. There are certain benefits in not forcing only natural languages - I have used language support for client specific modifications for otherwise shared documentation for example. I think the flow should be something along these lines: When creating new language, UI recommends choosing real language from list (BCP47) or adding custom language name Modules could ship their translations in /lang/xx-xx/ format and if there is match with xx-xx and any languages already found, those languages would be automatically applied for module. There we would have both: convention (using standard languages) and flexibility (using languages for different use cases).
    1 point
  18. The templating system even gives you the ability to do this yourself. If I understand this correctly it's just a plain php function which sends the output which is already generated at this time. You can freely choose when to use it in your template. But this won't work very well with the delayed output approach, as the most computation takes place before even the header is seen.
    1 point
  19. I personally use Horst module wireMailSMTP configured with Amazon SES and a simple code + cronjob. <?php // some config variables //these two variables should match the cronjob setting. $hour_interval = 9; // interval time in hours the cronjob is working, ex.: from 14:00 to 23:00 $cron_minute = 5; // cronjob execution every tot minute. $daily_sends = ($hour_interval * 60) / $cron_minute; $max_days = 5; // for how long I want to send the newsletter in a week ? max 7 days // this variable tells me how many times I have to send the newsletter based on the previous variables. $total_sends = $daily_sends * $max_days; $total_users = $users->find("privacy_newsletter=1,roles!=1016,limit=2")->getTotal(); // this limit tells me how many users I have to select per send to complete all the newsletter in the interval I configured previously ($max_days + cronjob settings) $limit = round( $total_users / $total_sends ); /******** INIT THE MAIL **********/ $mail = wireMail(); /******** IF ALL CICLES ARE COMPLETED RESET THE MAIL SENT LOG **********/ // 'cicles' field is an integer incremented every newsletter send if($page->cicles >= $total_sends){ $mail->sentLogReset(); // reset cicles variables $page->of(false); $page->cicles = 0; $page->save(); $page->of(true); } /******** SET THE START FOR USER SELECTION **********/ $start = $page->cicles * $limit; /******** USER SELECTION **********/ $members = $users->find("privacy_newsletter=1,roles!=1016,sort=created,start=$start,limit=$limit"); $to = $members->explode('email'); $mail->to($to); /******** SET THE NEWSLETTER CONTENT **********/ $mail->subject("LATEST NEWS"); $mail->bodyHTML($page->newsletter->last()->bodyhtml); // 'newsletter' field is s repeater with just a textarea field, the current newsletter is the latest item of the page. /******** SEND NEWSLETTER **********/ $numSent = $mail->sendBulk(true)->useSentLog(true)->send(); $page->of(false); $page->cicles++; $page->save(); $page->of(true); I just created a page with this template and call the url from cronjob. I'm still optimizing some steps but right now it's working well . Next step is create the cronjob directly from php using some libraries i'm studying so I don't have to check my variables and the cronjob. I send 2-3k mails per day and using Amazon is really cheap compared to other systems.
    1 point
  20. Ok, I see - I manually deleted those and reinstalled and it works now. I still don't really like the downloads.ext filename, but maybe that's a personal thing. Also, the dg_download template still has URL Segments enabled, but they aren't needed. Doesn't really matter since that template throws a 404 anyway, but would be cleaner to not enable it. Thanks again for putting this together! PS Not everyone has their templates folder writeable by PHP, so you might want to add a note and also handle any permission errors if those template files can't be added/removed.
    1 point
  21. @LostKobrakai Ever heard of Aesthetic Usability Effect, Scanning, or Visual Hierarchy? 'Look and feel' is central to usability. They cannot be separated in practice (although people do it in theory all the time). @Joss when you put it like that, I bow to your superior laziness.
    1 point
  22. I have enjoyed using this site profile. I have learned a lot about processwire by using it. Thank you. When I turn on error reporting I get the following error on multiple installations. Code $browserTitle = ($homepage->seo_title)? $homepage->seo_title : $page->title; if ($page->seo_title) $browserTitle = $page->get('seo_title'); $seoMetaDescription = ($homepage->seo_meta_description)? $siteSetting->seo_meta_description : ""; if ($page->seo_meta_description) $seoMetaDescription = $page->seo_meta_description; I'm inclined to just ignore it but thought I would still ask.
    1 point
  23. I think I stoped reading on when it said it's using Bootstrap 3. Nonetheless, I tried the tryout and it's not something I would use for building anything other than your typical Bootstrap layout page without knowing anything. Don't like the UI at all and it crashed after 2 min.
    1 point
  24. @netcarver I use Odroid-C1 with 5V/2A power supply (2.5mm plug), a Samsung EVO 16GB microSD card (class 10, UHS-I) and last Ubuntu image for C1 (from Hardkernel site). Ethernet is limited to 100Mb and a little tweak is needed for this setup to run properly, but I asume it's not interesting at this stage. If you wish I could run a php benchmark on the Odroid (e.g. like this one) so you could compare it with whatever you wish.
    1 point
  25. In my book, web design is part and parcel of development ...frontend development...
    1 point
  26. @Pierre-Luc you're now a contributor. To my knowledge, Guillaume and achabany were the first to work on it, and then me a while after. @Christophe Interesting link, thank's.
    1 point
  27. Hi Nico, Thanks for this module! Love it much I think I may have found a conflicting issue when this module is installed along side with ProcessBackup (DB Backup module). There is an error when you try to view the Database Backup detail and I believe it may be caused by the following line: $editedPage = wire('pages')->get($this->config->input->get->id); The SEO module kicks in when trying to view the database backup page because there is a querystring id in the url. setup/db-backups/info/?id=0:dev.cc26012015-01.sql The fix is pretty simple: public function ready() { // backend hooks if(@$this->page->process == 'ProcessPageEdit') { $editedPage = wire('pages')->get($this->config->input->get->id); if(in_array($editedPage->template->name, $this->includeTemplates)) { $this->addHookAfter("ProcessPageEdit::buildFormContent", $this, 'hookCustomizeSeoTab'); } } // frontend hooks if($this->page->template != 'admin' && in_array($this->page->template->name, $this->includeTemplates)) { $this->addHookProperty("Page::seo", $this, 'hookFrontendPage'); $this->addHookProperty("Config::seo", $this, 'hookFrontendConfig'); } } Check the ProcessEditPage first before look for the edited page object. But anyway, I thought I let you know Thanks much again!
    1 point
  28. Stripe seems like an interesting alternative to PayPal. Pete worked on a module some time ago: https://processwire.com/talk/topic/4363-stripe-arrives-to-continental-europe/
    1 point
  29. Hi! Look for Custom Editor JS Styles Set in the field configuration and enter a path for .js file. In this file you can define your custom styles like this: CKEDITOR.stylesSet.add('mystyles', [ // Block-level styles { name: 'Heading 1', element: 'h1'}, { name: 'Heading 2', element: 'h2'}, { name: 'Heading 3', element: 'h3'}, { name: 'Introduction', element: 'p', attributes: { 'class': 'introduction'} }, // Inline styles { name: 'Link button', element: 'a', attributes: { 'class': 'button' } }, { name: 'Highlight', element: 'span', attributes: { 'class': 'highlight' } }, // Object styles { name: 'Stretch', element: 'img', attributes: { 'class': 'stretch' } }, ]); Also make sure you have Styles toolbar item enabled.
    1 point
  30. Yes, it does. I have it run with nginx, so I don't care about the .htaccess Read the instructions on how to get hhvm running here: http://hhvm.com/blog/1817/fastercgi-with-hhvm You might need some tweaking and run into a lot of issues - hhvm has not been tested with ProcessWire. I also chose to let it run at port 8999 to be easily able to switch between hhvm and php5 for reasons of comparison. Your mileage may vary, but with a modern system your chances of getting it to work are better. Some stats using a fresh installation of Processwire with the site-beginner scheme ab -c10 -n500 http://pwtest.gurkendoktor.de/ php5-fpm: Concurrency Level: 10 Time taken for tests: 23.425 seconds Complete requests: 500 Failed requests: 253 (Connect: 0, Receive: 0, Length: 253, Exceptions: 0) Total transferred: 1902241 bytes HTML transferred: 1700241 bytes Requests per second: 21.34 [#/sec] (mean) hhvm: Concurrency Level: 10 Time taken for tests: 8.702 seconds Complete requests: 500 Failed requests: 232 (Connect: 0, Receive: 0, Length: 232, Exceptions: 0) Total transferred: 1900304 bytes HTML transferred: 1700304 bytes Requests per second: 57.46 [#/sec] (mean) This is in no way scientific. PHP does not use an opcode cache, which speeds up things a lot. on the other hand, hhvm gets better the "warmer" it gets (ie. the more load it gets). The nice thing is, that it still works with fcgi_cache: Concurrency Level: 10 Time taken for tests: 5.110 seconds Complete requests: 500 Failed requests: 491 (Connect: 0, Receive: 0, Length: 491, Exceptions: 0) Total transferred: 1912527 bytes HTML transferred: 1699527 bytes Requests per second: 97.85 [#/sec] (mean) Yes, there are some more "failed requests" - I blame this on ab Anyway, this is just plain ol' PHP Code. What would be interesting is to actually write a module in hack (the hhvm language) and see if this actually works. Because then you'll be able to harness hhvm's full power and experience an incredible performance boost. I'll figure this out later when there's time. More interesting it would be to fork the ProcessWire core and move it to hack. This would incredibly boost the performance, but brings other issues. But I guess this is too much of an effort, I myself wouldn't be able to do it
    1 point
  31. That's what I assume he wants... If you want to know which is in the page array use filter. $found = $pageArray->filter("id=1001|1003|1005"); echo $found; // 1001|1003
    1 point
  32. 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
  33. Sure--what I would suggest is adding a text or textarea field and calling it "tags". Then people can type whatever tags in there that they want. When you want to find all pages matching a given tag, you'd do this: $matches = $pages->find("tag*=something"); // where 'something' is a tag If you want predefined tags, then I would use a page reference fieldtype to associate a group of pages as tags. Populate the pages with their name or title field as your tag. Then use a multiple selection field like asmSelect to allow selection of the tags/categories. To find pages matching a given tag, you'd do this: $tag = $pages->get("/tags/something/"); $matches = $pages->find("title=$tag");
    1 point
×
×
  • Create New...