Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/04/2016 in all areas

  1. I'll take the opportunity right now – after handling 1600 live users this morning creating 2000 registrations in just 15 minutes – to make some advertising for a website/api testing SaaS I've used in the past one and a half weeks. They provide you with a javascript driven custom domain language to build up custom scenarios (even multiple ones), which allowed me to test not only raw web server performance, but also the performance for user triggered queue workers or other cpu intensive tasks, which might not directly be handled by a request. But that's not the thing, which was so special to me, but rather the quick help they offered mostly through their in app chat. Half the time it was even initiated by them, because they reviewed shortly what I was doing, not leaving their customers alone. So yeah. I'd really like if some of you guys would take a look and maybe try it out (it's free to try). https://stormforger.com/
    6 points
  2. I would look at using the WireCache functionality. You can find more about that here: https://processwire.com/blog/posts/processwire-core-updates-2.5.28/
    4 points
  3. Hi johnnydoe, welcome to the forum! I think the easiest approach is to use the Processwire API. Give a look at the Skyscrapper profile template files. Specifically, the search.php template file. Take a look at how the Processwire API is used to check for HTTP variables and sanitize the data received. In the end of the search.php file you will find: $content .= renderSkyscraperList(findSkyscrapers($selector)); ..Which you can take a look here in the functions.php file, and it is the function that actually renders the markup from the PageArray retrieved by the selector queries. It is saved into $content, and rendered in _out.php. You might also take a look at this page of the documentation explaining the $input variable. https://processwire.com/api/variables/input/
    3 points
  4. hi surffun, of course this is possible. see the docs for all the options: https://github.com/somatonic/MarkupSimpleNavigation#markupsimplenavigation-116 // you need this line only once $menu = $modules->get('MarkupSimpleNavigation'); // your main menu echo $menu->render(array( 'outer_tpl' => '<ul class="show-only-on-big-screens">||</ul>', // all other options here )); // your footer menu for mobile echo $menu->render(array( 'outer_tpl' => '<ul class="show-only-on-small-screens">||</ul>', // all other options here )); and then you can hide/show the menu by defining css rules for the classes "show-only-on-small/big-screens": http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
    3 points
  5. I have found a working solution. Here is the code for others who are interested in. //check for email approval GET variables $cpageid = isset($_GET['page_id']) ? $_GET['page_id'] : ''; $ccode = isset($_GET['code']) ? $_GET['code'] : ''; $capprove = isset($_GET['comment_success']) ? $_GET['comment_success'] : ''; foreach($page->comments as $c) { if((($page->id) == $cpageid) AND (($c->code) == $ccode) AND ($capprove == "approve")){ $page->setOutputFormatting(false); $c->status = 1; $page->save('comments'); } } Best regards
    3 points
  6. I don't know where to put it so I'm creating this topic here (feel free to move it). I've just found it indirectly: http://www.sitepoint.com/easy-dynamic-on-demand-image-resizing-with-glide/ http://glide.thephpleague.com/ Just in case it interests someone.
    3 points
  7. Try getQueryLog(); (with $config->debug to true) https://processwire.com/talk/topic/11483-duplication-in-query-results/?p=106994
    2 points
  8. Hi, you can find some basic search logic in the search.php of the default site profile: https://github.com/ryancramerdesign/ProcessWire/blob/master/site-default/templates/search.php In https://github.com/ryancramerdesign/ProcessWire/blob/master/site-default/templates/_main.php#L61 you find the code for the search form. This should get you started. EDIT: If you should later decide to use AJAX, there is Soma's module: https://github.com/somatonic/AjaxSearch
    2 points
  9. If 'user' is the name of your page field that holds the users, try <?=$device->user->name?> or <?=$device->user->title?> // if you have a title field in the user template This works only if the user page field is set to hold only one page.
    2 points
  10. Thank you nik, for that code. I am using it and it works quite well. Only thing that needs to be changed is the while from while (count($results) > $limit); to while (count($results) = $limit); Otherwise it loops 1 more time than it should.
    2 points
  11. @marcus, No problem, thank you for your time on this and for your reply; I hope you feel better soon. Regards, Steve
    2 points
  12. Unfortunately no estimated time of arrival on my side, feeling sickly for a couple of weeks now, and drowning in customer work. Can't allocate time. Sorry :/
    2 points
  13. Hi 101Bram, Welcome to ProcessWire! So you somehow need to link one election page to one user account. Check out the Page field. On your user template, you can create a new Page field, let's name it "election". After creating the user and the corresponding election page, you can store the election page in this field. To create a link, you can simply use: $electionPage->url. Note that on your election template, you should check if the visiting user is equal to the user where the election page belongs to. If not, you can throw a 404 error. As always with ProcessWire, this is just one way of doing it Cheers
    2 points
  14. Follow the slogan "Everything in PW is a page". To stay flexible I would store orders and order items as pages. Use PageFieldEditLinks together with PageFields (ASM Select) to handle/ edit the Page Fields comfortably.
    2 points
  15. To extend the above example to hide the name, template and parent fields on the settings page of invoices, you can add the following to the ready.php snippet in the above post. /** * Work out if the template's settings should be tweaked to hide things that should be fixed... */ function shouldHideTemplateSettings() { // Super users retain super-setting-edit powers if (wire('user')->isSuperUser()) { return false; } // Are we even editing a page? if (wire('page')->process != 'ProcessPageEdit') { return false; } $id = (int) wire('input')->get('id'); if (!$id) { return false; } $editedPage = wire('pages')->get($id); if ($editedPage->template->flags & Template::flagSystem) { return false; } if (!isInvoiceTemplate($editedPage->template->name)) { return false; } return true; } /** * Hide some fields from the invoice settings page from non-super-users. * * There's not much point allowing edits to the name field, so we want it immutable (at least) and probably totally * hidden (better.) * * We don't want invoices being moved from their parent, so we hide the parent field. * We don't allow them to use a different template, so we hide the template field. * */ if (shouldHideTemplateSettings()) { $pages->addHookAfter("ProcessPageEdit::buildFormSettings", function($event) { $wrapper = $event->return; // To show the name field but make it immutable $wrapper->_pw_page_name->collapsed = Inputfield::collapsedNoLocked; $wrapper->_pw_page_name->description = ''; // Alternatively, to hide the name field do uncomment the following and comment out the 2 lines above //$wrapper->_pw_page_name->collapsed = Inputfield::collapsedHidden; // Hide the template changer, invoices can only use the invoice template $wrapper->template->collapsed = Inputfield::collapsedHidden; // Hide the parent page, as it is fixed in our page structure $wrapper->parent_id->collapsed = Inputfield::collapsedHidden; }); }
    2 points
  16. This module provides a very simple interface to a set of named counters. You simply call a single function, next('name'), to pull the next value out of a counter - or to set it up if it does not yet exist. Next() takes a few extra parameters to allow you to increment by values other than 1 or to start at a certain number. This provides some similar functionality to the built-in page naming feature of PW, and to this module recently posted by Stikki but I think it offers a little more flexibility than either. Having said that, I do like the simplicity of Stikki's new auto-increment module. Module Availability Here is my module on Github. Here it is in the module repository. Example Usage Here's how this module can be used to title and name a new page by adding a couple of simple hooks to site/ready.php. This example applies to new pages using a template called 'invoice' that can be quick-added to the page tree. In order to get the following to work, you must edit the template that will be the parent of the 'invoice' template and setup the template for children to "invoice" and set the "Name Format for Children" field to something other than the default blank value (I use title as my value.) <?php /** * Function to recognise our special template. */ function isInvoiceTemplate($template) { return ($template == 'invoice'); } /** * Pre-load the page title for invoice pages with a unique value * which includes a counter component. */ $pages->addHookBefore("Pages::setupNew", function($event) { $page = $event->arguments(0); $is_invoice = isInvoiceTemplate($page->template); $no_inv_num = $page->title == ''; if ($is_invoice && $no_inv_num) { $counter_name = 'WR-' . date('Y'); $number = $this->modules->get('DatabaseCounters')->next($counter_name, 10, 5000); $page->title = $counter_name . '-' . sprintf("%06u", $number); } }); /** * Prevent ProcessPageEdit from forcing an edit of the name if we got here * through a quickAdd from ProcessPageAdd. We can do this because we * preset the title field in the Pages::setupNew hook. */ $pages->addHookAfter("ProcessPageEdit::loadPage", function($event) { $page = $event->return; $is_invoice = isInvoiceTemplate($page->template); $is_temp = $page->hasStatus(Page::statusTemp); if ($is_invoice && $is_temp) { $page->removeStatus(Page::statusTemp); $event->return = $page; } }); Note, the above code + module is one direct solution to the problem posted here by RyanJ. Version History 1.0.0 The initial release.
    1 point
  17. ProcessWire 3.0.12 now supports the ability to use extended (UTF-8) page names, meaning your URLs can now have just about any characters that you want… https://processwire.com/blog/posts/hello-健康長壽·繁榮昌盛
    1 point
  18. Where do i get? From here: https://github.com/IDT-media/IntegerAutoIncrement What does this do? Adds additional option to Fieldtype Integer to make it auto increment. How to use? Simply install this module, Create / Modify Field that is Integer, set auto increment on/off. Enjoy!
    1 point
  19. This week we've been focused on one of the major 3.x roadmap items, which is to have strong Composer support in ProcessWire. In this post, we now have an outlined process and a full proof-of-concept module built to demonstrate it all, plus info on how other module authors can support Composer as an alternative installation method. To add to that, we get into Google's Client API with a new 3.x specific module and how to connect Google's Calendar services with ProcessWire. https://processwire.com/blog/posts/composer-google-calendars-and-processwire/
    1 point
  20. A couple of requests to make working with templates in Admin more streamlined: 1. Display the "Label" field in the "New Template" screen - I always like to label my templates and currently this requires you to re-open the template you have just created. Also, I'd rather have the template screen remain open after adding a template rather than be sent back to the Templates overview. These changes would make the "New Template" process more consistent with the "New Field" process. But of course the likely reason for no Label field and the closing of the template screen is because it's actually "New Templates" plural not "New Template" singular. Myself, I've never felt the need to add multiple templates at once but I expect others do. Maybe "New Template" and "New Templates" could be separate commands? 2. When duplicating a template (Add New Templates > Duplicate fields used by another template) it would be nice if field overrides (widths, descriptions, etc) were included in the new template(s). It can be quite time-consuming to set these up, and if you are duplicating fields of an existing template I think you also want to duplicate the overrides more often than not.
    1 point
  21. For Chinese characters, I just copied the characters I needed to use in a page name and appended them to my $config->pageNameWhitelist, like this: $config->pageNameCharset = 'UTF8'; $config->pageNameWhitelist = '-_.abcdefghijklmnopqrstuvwxyz0123456789' . 'æåäßöüđжхцчшщюяàáâèéëêěìíïîõòóôøùúûůñçčćďĺľńňŕřšťýžабвгдеёзийкл' . 'мнопрстуфыэęąśłżź健康長壽·繁榮昌盛'; You'll have to make sure that your /site/config.php file is UTF-8 encoded, which it should be by default. But depending on what editor you are using, it's always possible it's not.
    1 point
  22. Another way could be: When automatically creating the userpage in your hook, you can set wire('page')->created_users_id = wire('user')->id Now the page is owned by that user. When the user logs in to lets say .../userpages, in the template.php for userpages you can get the user's page with $pages->get("template=userpagetemplate, created_users_id={$user->id}") To be able to change the user of a page, you need to enable this in the template settings for the userpage-template in the Advanced tab towards the bottom.
    1 point
  23. Oh, I know that, it's fine Not pointing the finger or saying you have to it; it was more of a general thought for the project as a whole, that's all (I do appreciate you taking the time to arrange the Github-ness of it all!)
    1 point
  24. If this is something that is expected to be installed on a variety of platforms (some of which may not have the ability to change the server setting) then I'd vote for changing the code to use <?php, so it will appeal to a wider audience I know it's not required for this type of project - but the ProcessWire Coding Style Guide says (and is good to aim for):
    1 point
  25. I would remove the comments module altogether from the core
    1 point
  26. I think you can use what you best like. If you are comfortable with repeaters, you can use this. If you are more comfortable with others, use others. But I cannot understand why you want to do it from scratch, if your questions already start at this early point? Is this a free project, that you want build just for learning, or is this a productional project for a client?
    1 point
  27. Good call Tony. Forgot about that. Amended my code.
    1 point
  28. Thanks for that code snippet Kongondo. It was throwing a fatal error for me, but I added $p->setOutputFormatting(false); and it worked a dream. Here's my (fractionally) modified code: foreach ($pages->find('template=template-with-views-count-field') as $p) { $p->setOutputFormatting(false); $p->views_count = (int) $p->views_count_old; $p->save('views_count'); } Just thought I'd post feedback in case anyone else wants to use it and encounters the same fatal error
    1 point
  29. Oh, of course. When using this kind of foreach structure you have to reopen PHP to echo your object properties. You can open it with <?php or echo them with the shorter version <?= <?php foreach ( $pages->find('template=single, limit=5') as $single ):?> <div class='post'> <div class='content'> <a href='<?=$single->url?>'><h3><?=$single->title?></h3> </a> </div> </div> <? endforeach; ?> You can also use the most common PHP structure, where you don't go in and out of php. Your choice. Anyway, I think you would benefit a lot from studying the basics of PHP while using ProcessWire.It's not hard at all and will making everything more clear for you.
    1 point
  30. A minor correction to the above example: change the ";" at the end to ":"
    1 point
  31. +1 3. It would be great if we could enter the new template name directly before duplicating. So the template and field duplication process are equal.
    1 point
  32. Is there a way to contribute to the documentation or cheatsheet? I know, that the heavy users probably will now use kongondos apigen documentation or look at the core files themselves. But I think most users will first look at the documentation or cheatsheet. Often when I go through Ryans older blog posts, I find nice methods, that are nowhere else documented. Here are two examples: New $pageimage->maxSize($width, $height) method What's new in the core this week? New API syntax options! Those two examples can't be found neither in the documentation nor the cheatsheet. Also they can't be found through the site search and are hard to find through the Google Search. I wouldn't consider myself being capable writing the documentation, but I would like to post when I find something is missing. Should I do this in this forum or is there a form/mail address I can contact?
    1 point
  33. Well in my case the image field doesn't display the edit button when inside a repeater. When outside the repeater, the button appears. What gives?
    1 point
  34. The module could just check if Inputfield Ace Extended is installed and use it if so. That would prevent the big filesize like it's the case for hanna code and leave the code editor optional.
    1 point
  35. yes, good point... would be keen to see it. Mostly though, i never seem to be able to use stock systems, because the business logic is hard to encapsulate into one system, which is why if you build this with PW backend, then you are really tailoring it for specific use; I also say this because i just alighted from a 200+ hr asp.net project (where my part was only a fraction of the total labor) in building a custom app, and never a day went by when i observed how so many of the things we needed to constantly build and rebuild and fix could have been handled simply by pw admin;
    1 point
  36. Just for fun, I decided to try saving from copy-pasted CSV data using MySQL LOAD DATA INFILE. Now this MySQL feature is something you use for really serious transactions. Testing with 'only' 1000 values seems an overkill. Anyway, here's the results: Testing with same data as in my post above (10X100 table with 1000 values) Method 1: CSV + MySQL LOAD DATA INFILE 1. Copy-pasted CSV values in the format: Name|Age|Country|Bank Account|Phone|Credit Card|Email|Salary|Address|Post Code Quinlan T. Romero|36|Burkina Faso|RS31212461883550021066|(989) 462-3421|863|Integer.vulputate@Curabiturut.ca|£066.39|P.O. Box 161, 2347 Donec Street|6518 2. Flip the CSV values to match our db structure, i.e.: data(matrix_row) | matrix_column | matrix_value - explode csv line by line - str_getcsv csv line to create array of the csv line - push sanitised csv values into a new CSV array mirroring our 'db structure' (i.e. including row and column page->id) - we do this because our raw csv data is in matrix table format and LOAD DATA INFILE won't read it correctly array( [0] => ( [0] => row->id [1] => column->id [2] => value ) ) 3. Write CSV values to a data.csv file - fopen a data.csv in this page's /assets/files. Force create the file w+ if one doesn't exist - fputcsv the CSV array line by line 4. LOAD DATA INFILE - instantiate a new PW (PDO) $this->wire('database'); - Delete this page's existing values from db - Execute a LOAD DATA INFILE, reading through our data.csv and writing to db (at high speed ) - Delete data.csv Method 2: CSV + 'Saving Normally' 1. Similar to above but we don't write to a data.csv nor use LOAD DATA INFILE 2. Prepare csv array using str_getcsv similar to above...but 3. Our CSV array is slightly different (but timings don't matter because of the different structure) [row->id] => ( [column->id] => value ) Results: Memory usage and Timings Normal LOAD DATA INFILE processCSV() mem_end 15,105,984 13,767,352 mem_start 12,754,968 12,761,496 Diff 2,351,016 1,005,856 time 0.1240 0.0740 ___processInput() mem_end 14,974,128 13,328,584 mem_start 12,754,128 12,760,504 Diff 2,220,000 568,080 time 0.1240 0.0940 ___sleepValue() mem_end 15,504,760 Not Applicable mem_start 15,122,112 Diff 382,648 time 0.0160 Not Applicable As you can see LOAD DATA INFILE is the (clear?) winner. Not sure if LOAD DATA INFILE is enabled everywhere though? Anyway, for now, not sure if this is the route I should take. Besides, I got something else planned (in my head!) for handling really large grid tables.. Before you ask, no we are NOT using LOAD DATA INFILE with the LOCAL option (security concerns with that option!)
    1 point
  37. @Steve, Good catch about empty values! Don't know how I mised that! I have corrected it in Version 0.0.3 (post here soon), thanks! Memory issue: That was my next question. I would like to do/see some real world tests....+ there's also PHP post limits...Would appreciate if anybody could help test , thanks.
    1 point
  38. Hey rob. What diogo said. You can create a admin page using the "admin" template. It would be placed under the locked "admin" page tree. The admin template has a field "Process". After creating the page you'll see it under tab "content". Now you have to create a process module to serve functionality for the newly created admin page. Once installed it can be selected from the field "Process". I did a quick example that shows such a module, and even how to use the ProcessPageList module of processwire to create a tree. The id set will be the parent page (your Architects) for example. ProcessPageListCustom.module create the module under /site/modules/ and install it. <?php class ProcessPageListCustom extends Process{ public static function getModuleInfo() { return array( 'title' => 'Custom Page List', 'summary' => 'List pages in a hierarchal tree structure', 'version' => 100, 'permission' => 'page-edit' ); } public function execute(){ $pl = $this->modules->get("ProcessPageList"); $pl->set('id',1001); // or any other parent page return $pl->execute(); } } You can, of course, use any code to generate a list of pages.
    1 point
×
×
  • Create New...