Jump to content

Leaderboard

Popular Content

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

  1. JSON API response testing in the Console panel I know we all know about json_decode($var, true), but here's a useful tip when working with APIs that return JSON. Note that I am using the new shortcut for specifying a depth of 7 so I get to the deeper levels of the JSON response. Obviously that's a LOT nicer than:
    5 points
  2. There is also 'X-Powered-By: Processwire' in response headers. $config->usePoweredBy = false; // to prevent it output
    4 points
  3. And here are the official results ~4,7% for Processwire (33,9% of the „Other“ results) 4th Place https://www.drweb.de/diese-cms-nutzen-leserinnen-dr-web-magazins-alltag/ (German)
    4 points
  4. This is a good thing. I'd suggest that you first get a thorough grounding of the basics before plunging into creating anything. The resources suggested in the previous posts are all good. However, without a basic understanding of ProcessWire, they will not make much sense to you. People learn differently. Some people like to dive in and pick up the basics as they go along. Others (me included ) prefer to get the basics first before diving in. So, if you can go through these first, you'd be the better for it in the long run. Selectors PHP foreach loop (in case loops are newish to you) $page $pages Yes, what you asked is doable. But you will need to get those hands dirty with some custom code. It'll be fun though. Welcome to the forums .
    4 points
  5. This doesn't appear to be the usual .htaccess-related kind of thing Visiting shows that the 404 is PW's 404 page and clicking internal links tries to load the appropriate page (browser URL field changes) but it is still 404. Completely groundless wild guess - could it be a multi-language related problem?
    4 points
  6. You need to add: xhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest"); This is something that jquery does automatically, but you have to do yourself with vanilla JS. I think you may also need to add this inside your xhttp.onreadystatechange function. xhttp.getAllResponseHeaders();
    4 points
  7. In /site/modules/InputfieldCKEditor/contents.css: .cke_panel_list h1, .cke_panel_list h2, .cke_panel_list h3, .cke_panel_list h4, .cke_panel_list h5, .cke_panel_list h6, .cke_panel_list pre, .cke_panel_list address { font-family:sans-serif, Arial, Verdana, "Trebuchet MS"; font-weight:normal; font-style:normal; font-size:14px; } Do likewise for any custom styles you have added to the Styles dropdown.
    4 points
  8. I'm not sure this is the 'hard way' . Since this is a Fieldtype, it has no admin page, unlike a Process module. So, if you need a page for it, then the page needs to be created. You can do all these using the API and the template file stuff (copying it to /site/templates/ using PHP. E.g., when installing ProcessWire, it writes to/populates config.php and moves it into place under /site/config.php. That's the approach I am talking about. If unsure how to do it, I can show you how. It is good to create the page to for your FieldtypeYourClass stuff under /admin/. That way, it won't be tempered with by non-superususers. You can even throw in a hidden status on it. A couple of my modules (including Menu Builder) use this technique. The only difference is that they do not have template files, since I post to the Process Module instead (which has a page under /admin/. So, my suggestion. FieldtypeYourClass should auto install InputfieldYourClass. In Fieldtype add the install() method. In there, you can either (a) Directly create the assets needed (page, template, template, file, etc) or (b) call a method or methods within your FieldtypeYourClass to do these or (c) Call a YourClass.php or someOtherFile.php file with the script to create these assets. Creation of template first, then create the page, then copy the templateFile.php to /site/templates/. You will need to decide if the parent of the page will be /admin/, in which case you don't want it to appear in the admin menu, so apply hide status. An alternative to creating this page is creating a Process Module to handle your ajax calls. Once, the page is created, grab its $page->id (e.g. saving it to a class property). In your Field's ___getConfigInputfields(), create a hidden input to store the $page->id. Alternatively, since you know the template used by your $page, as well as its name, you can be grabbing it like that when responding to the ajax calls, so no need for this hidden input. As for the right place for a template file, I'd go for /site/templates/. That's where template files live. Alternatively, you can have a template file there that just calls yourOtherCode.php to handle your ajax calls. If you don't want other pages to be created using your template file, you can add that setting using the API when creating the template. As for install() in Fieldtype Modules, have a look at FieldtypeOptions. It calls install(), so, yes, this can be done. When initiating your FieldtypeYourClass (have a look at FieldtypeEvents), you can make it have a setPage() method that sets your $page, hence making it available to your InputfieldYourClass. Other things you can do Lock your hidden $page (so as not to delete it by mistake). Have your FieldtypeYourClass check for the presence of the $page and throw an error if one not found (or auto-recreate it). On uninstall, delete the assets you created for the module (page, template, template file, etc). I think I've answered this above. A Fieldtype does not have its own page in the sense of a Process Module. So, you would need to create your own. Hope this helps.
    3 points
  9. https://stackoverflow.com/questions/5479073/when-is-it-good-to-use-pass-by-reference-in-php https://www.elated.com/articles/php-references/ So I think you have to decide on your own taking into account performance and code readability.
    3 points
  10. something interesting to make the backend faster without modifying everything: https://m.signalvnoise.com/stimulus-1-0-a-modest-javascript-framework-for-the-html-you-already-have-f04307009130 code: https://github.com/turbolinks/turbolinks https://github.com/stimulusjs/stimulus
    3 points
  11. Hi @Robin S, congrats to one more nice module! And I totally understand why you created it. I also (wanted to) use such a feature in different scenarios. Therefor once I added the "weighten" option to the PIA module. Hopefully you don't mind my following propagation of an alternative way to apply such a functionality. Maybe it is usefull for some people to have a different way to define / calculate / imagine the resulting images. You call it Megapixels, Pia uses image pixel dimensions for width & height or a single dimension for squares, defining a bounding box and get the images contained & weightened into that box. Additonally Pia handles one out of four values to the weighten-option to prioritize the landscape or portrait images in two ways: So, what you wanted was allready available in the modules directory for about three years. But I believe, when seeing all your modules, you have had fun building and sharing it. OT: For me, the last two years it is not possible to keep track of all the good new stuff coming into the core and from community members (like you). Some years ago, it felt doable for me. Lately I also found "a new possibility" to do things that was allready three years available. Even I had read it in the past and bookmarked it under my other several hundred PW links, it got out of focus. If somebody know a good way to keep track and or archive all the good stuff from here, (besides the few things that get mentions in the weekly news & blog posts), please share.
    3 points
  12. Actually, you can shorten the CSS override to this: .cke_panel_list * { font-family:sans-serif, Arial, Verdana, "Trebuchet MS"; font-weight:normal; font-style:normal; font-size:14px; }
    3 points
  13. @Monty this might help: https://www.pwtuts.com/processwire-tutorials/creating-a-main-menu-and-sub-menu-for-your-website/
    3 points
  14. Thank you for the wild gess about the languages problem, it seems that the is related to the languages. I had only one language active that was Portuguese, and after added a new language the home was shown correctly, now I need to verify the issue in other pages. Many thank you for help I think now it is just a time issue to verify all the pages and file templates.
    2 points
  15. Anyone following this thread have any issues with the dev version before I merge to master? I'll merge later today if I don't hear anything. Thanks!
    2 points
  16. . Yeah, @Robin S has been on fire! I've learnt a lot about Inputfields and Hooks from his work. That's me! .
    2 points
  17. @DaveP I went over a similar topic to this a while back ...and it was suggested to leave the user as just email/password i.e. just the very basic authentication requirements and create a 'profile' page instead which is associated with a user (which is auto created when they sign up with a page ref field on profile back to the user page). For example, for users with different roles (admin vs member), they might not all need the same fields. Never been sure what approach to take as I've still not built anything with members yet. The setup of this could possibly be important for the OP though for maximum flexibility for the future. p.s. hi @NoWords welcome to the forum
    2 points
  18. As @BitPoet said, there is AdminCustomFiles module (I've never used it), and AdminOnSteroids module can do it too. Also in config.php something like this: $config->scripts->add($config->urls->templates . "admin/admin_global.js"); $config->styles->append($config->urls->templates . "admin/admin_global.css"); A related good read: http://soma.urlich.ch/posts/custom-js-in-processwire-admin/
    2 points
  19. Welcome NoWords! Short answer to a long question - Yes, almost certainly. Bit longer answer - Most (if not all) of your needs could be accomplished by creating a ProcessModule. This will require some programming, which you may or may not be comfortable with. See This will allow all the control over member budgets etc that you need. In PW a user page is just a page so any custom fields can be added to a user just as they would any other page. Depending on your requirements around 'events', there are various calendar modules available but without knowing a bit more about that side of things, the built in date support might be all you need. Have a look at @bernhard's tutorial above, and come back to us with any more questions you might have.
    2 points
  20. If you want a navigation different from the page tree you can write it also in HTML and add it to the template. Theres no need to use a function to create it. You can get the URL for a page in this way: $url = $pages->get(Id of the page)->url; fe. if the page has the id 45 you get the url like this: $url = $pages->get(45)->url; You can use it to write the menu in HTML and add the URLs with PHP like this <a href="<?php $pages->get(45)->url;?>"><?php $pages->get(45)->title;?></a> This outputs the link and as linktext the title of the page. There are many ways to create a navigation. I recommend you to take a look at the cheatsheet.
    2 points
  21. Hi @Monty, and welcome to the forum! With the blank profile, you are left to build everything you may need for your site. However, you can use the code from other profiles, such as from the site-default/templates/_main.php file to generate your menu navigation, like so: //place this code in your template where you want the menu displayed. <ul class='topnav' role='navigation'><?php // top navigation consists of homepage and its visible children foreach($homepage->and($homepage->children) as $item) { if($item->id == $page->rootParent->id) { echo "<li class='current' aria-current='true'><span class='visually-hidden'>Current page: </span>"; } else { echo "<li>"; } echo "<a href='$item->url'>$item->title</a></li>"; } ?></ul> Another option could be to use the _func.php file located in the site-default/templates folder of the processwire zip file you downloaded. This file contains a similar function to generate a navigation menu which you can call from a template. It all depends on which method (eg, Delayed Output) you are using to create your site and the structure of your pages, so this is only a general information. Is this the planets tutorial? Feel free to post your structure and someone will be able to give you more specific suggestions.
    2 points
  22. Since today, 31-01-2018, we have support for this in the PW Core. Therefore I updated this module to version 2.0.2 This version handles the detection of the core support and dismiss its installation then. If the core module is available but not installed, it get installed instead of this third party module. If you have this third party module already installed since a previous PW version and upgrade your wire folder, this module will detect the core module and install it. Its own hook isn't registered then and you get a notification about the changes.
    2 points
  23. Inspired by the "max megapixels" option for the client-side image resizer, I made a simple module that adds target megapixel resizing for Pageimages. Image Megapixels A module for ProcessWire CMS/CMF. Adds methods to Pageimage objects useful for resizing to a target megapixel value. Example use You are creating a lightbox gallery of images with different aspect ratios. For the enlargements, rather than setting a fixed maximum width or height you want all the enlargements have the same size in terms of area, allowing a panoramic image to be wider than a square image, for instance. Another use case is sizing a gallery of sponsor logos. The supplied logos are different aspect ratios but you need to ensure the logos are sized so each has equal prominence on the page. The effect of resizing three different aspect ratios by the same megapixel target value can be seen in the screenshot below: Installation Install the Image Megapixels module. API // basic usage $pageimage = $pageimage->megapixels(float $megapixels); // usage with all arguments $pageimage = $pageimage->megapixels(float $megapixels, array $options = []); Example: foreach($page->images as $image) { echo "<img src='$image->megapixels(0.8)->url' alt='$image->description'>" } If needed you can supply an array of options for Pageimage::size() as a second argument. Getting dimensions If you just want to get the height and width dimensions needed to size an image to the given number of megapixels you can use the Pageimage::megapixelsDimensions() method that this module also adds. It returns an array with width and height as keys. Example of how this could be used to output a gallery of logos: foreach($page->logos as $logo) { $dimensions = $logo->megapixelsDimensions(0.01); $width = $dimensions['width']; $height = $dimensions['height']; $width2x = $width * 2; $height2x = $height * 2; echo "<img src='{$logo->size($width, $height)->url}' srcset='{$logo->size($width, $height)->url} 1x, {$logo->size($width2x, $height2x)->url} 2x' alt='Logo' width='$width' height='$height'>"; } https://github.com/Toutouwai/ImageMegapixels https://processwire.com/modules/image-megapixels/
    1 point
  24. Hello everyone! I'm Marco, It's my first website with Processwire and I like it a lot!! There is just a few things that i can not understand well. I try to looking in the forum but not have find an answer, so I write here my first question! When I create a new images field I can upload images only from outside website, I mean, I can not reuse the images I've already uploaded. Example if I have to load icons inside a repeater field I have to upload the images every time, and the system will create a folder for every images, with different url. There is an away for let me reuse the images I've already uploaded ? something similar at an option to choose from a madia library like for the CKEditor ? Thank a lot!
    1 point
  25. Thank you. I am trying to write a simple image picker field because of this thread. The idea is to Just click the button -> click the image -> done. It is already working but there is still a lot to do.
    1 point
  26. OK, v2 has been merged to master. Be warned about the breaking changes!
    1 point
  27. Hehe sure but i think it‘s good for Processwire but the 5th Place was already before my post here...
    1 point
  28. 1 point
  29. Sorry @bernhard - I replaced the first image after my initial post, and accidentally replaced the second one as well. Take a look now
    1 point
  30. 1 point
  31. Many thanks to all, I was getting frustrating about this, saved the day.
    1 point
  32. First thank you to all for the help!! Great know there are many user active! @horst OK I think the this solution cloud work, so I have to make one hidden page like principal category and every page for each image to call it from the back-end page where I want show up the images, exact? Thank you @Robin S and @theo Media Library + fieldtype-assisted-url look interesting, I can use this and replace it with image fields, but if I do I will lost all the api image? this could be nice also because i can use it with external folder like make my image folder. no? @szabesz thank you I'll go see the page.
    1 point
  33. Anyone following this thread have any issues with the dev version before I merge to master? I'll merge later today if I don't hear anything. Thanks!
    1 point
  34. 1 point
  35. Theres a conflict Its to separate different values of the selector... https://processwire.com/api/selectors/#values
    1 point
  36. And if it's mainly within CKEditor fields that you want to reuse images from a central media library then there is this module from @BitPoet: Media Library
    1 point
  37. Hi @MarcoPLY, welcome to the forums. Imagefields are tied to a page, therefor the images you upload through this page are stored under /site/assets/files/<ID-OF-THE-PAGE>/. You are using repeaters, maybe as one of multiple options to reuse fields on a single page. Repeaters are also pages (behind the scene), therefor the images you upload to a repeater item are stored under /site/assets/files/<ID-OF-THE-REPEATER-PAGE>/. For all images you want to use in multiple places, one recommended way is to create a hidden page with an imagefield. Some people don't create an extra page but uses their homepage for that. Both do store all the stuff that is needed on multiple places, also text like contact data, files and not only images. But let us focus on the images now: If you need them into different pages with ckeditor fields, you need to click on the images button. In the opened dialog you can read " If you would like to select images from another page, select the page below.". Below is the name of the current page and a button or link called "change". Clicking on it opens a page tree to let you choose another page. (The homepage is the first one, what may be the reason some people store their reusable stuff there). With clicking on the pagenames you can traverse through the tree to every single page that exists in your system. Clicking "select" on the page of your desire displays all its images as thumbnails.
    1 point
  38. My migrations module cannot install processwire, nor itself, but after that it can basically do whatever php and the processwire api allows you to do.
    1 point
  39. That's what OR-groups are for. $userTest = $users->get("(nick={$input->post->nick}), (email={$input->post->email})"); Btw., don't forget to sanitize your input before using it in selectors.
    1 point
  40. This is one of the few cases where I don't care that much since getting the new CSS selectors isn't difficult, so I just make sure to document these small UI hacks in a dedicated place in the admin area. The format and styles plugins (as well as some other basic widgets that are internally realized as plugins) are already included in the main ckeditor.js.
    1 point
  41. Just a quick fix: "...the most powerful tool on this planet..."
    1 point
  42. @godmok and everyone! Ok, hopefully this is the last update before pushing dev to master. This new version moves the "example numbers" into the Output Format Options syntax so that you can specify different numbers for each format which is important so you can tell from the dropdown whether the numbers are being formatted correctly or not. The syntax is: name | format | example numbers For example: northAmericaStandard | {+[phoneCountry]} {([phoneAreaCode])} {[phoneNumber,0,3]}-{[phoneNumber,3,4]} {x[phoneExtension]} | 1,221,5673456,123 australiaWithCountryAreaCodeNoLeadingZero | {+[phoneCountry]} {([phoneAreaCode,1,1])} {[phoneNumber,0,4]} {[phoneNumber,4,4]} {x[phoneExtension]} | 61,07,45673456,123 Note that the example numbers are comma separated for each component of the number. You can see the output in the dropdown in this screenshot. See how I have a leading zero/two digit area code and 8 digit number for the Australian examples vs 3 digit area code and 7 digit number for North America. Remember that this new 2.x version needs a different syntax for the format options, so if you are upgrading from 1.x, you will need to adjust, or empty the settings to have the new defaults populate automatically. This is OT, but I think it's a good excuse to advertise @netcarver's awesome ModuleReleaseNotes which shows what's changed when you go to upgrade a module (using Ryan's PW Upgrade module). Most importantly it highlights when a module is tagged as having breaking changes, which this new v2 of FieldtypePhone has. I hate implement breaking changes, but sometimes you just have to I'll give it another couple of days for the dust to settle (and here back from you guys) before pushing to Master.
    1 point
  43. I changed it to this now: Sorted out the 'h2 {word-wrap: break-word;}' for those long paths too on the tutorial, broke the layout on mobile. You can see in the video when I demonstrate saving a page (missing required fields) at 1:06, I much prefer more subtle errors/warnings like this but that was a pain to change with the label colour being the same as the background of the error message. I find the default one very old fashioned, is like this: so I changed it to this: Sounds tasty! Look forward to seeing this!
    1 point
  44. Cheers! Yeah, I guess I should have posted the link here, too. I've been developing with ProcessWire for a few years now (and bugging the community here with whatever issues I ran into -- which so far have always been my own fault!). I just wanted a place where I could explain how and why I picked ProcessWire as my CMF of choice, and to sort of explain a bit how this particular website gets made. I plan to add more to the blog about how some of the stuff works, what my rationale is behind some things, etc. Might not always deal exclusively with ProcessWire, but some upcoming topics will deal with how I handled the watermark branding on social media images (with the great PageImageManipulator module and some creative switcheroo in the PHP code of templates) and how I went about to create the structure and code for a timeline (which isn't online yet due solely to the fact that it has too little content yet). I always like reading patch notes, so I figured I'd add a changelog to the website to keep those who are interested in these kinds of things to keep track of changes that I implement. The roadmap is there to sort of explain where we're going with the website, even if one or two things that are a bit more experimental are kept under wraps (since they may never lead to anything); it also helps remind me what I'm supposed to be working on.
    1 point
  45. So I restructured the code a bit and also added some validation and sanitising, and the part that did not work before ($np->set($f->name, $form->get($f->name)->value);) started working Did I do the validation and sanitising parts correctly? Or are there more efficient/better ways of doing this? Here's the fully working code: $page_id = (int) $input->post->select_product; // page ID if ($page_id) { $p = $pages->get($page_id); $template = $p->template->name; // this is the template where we will get the fields from // make a form $form = $modules->get('InputfieldForm'); $form->method = 'post'; $form->action = './'; $form->attr("id+name",'subscribe-form'); // add the page's fields to the form $fields = $p->fieldgroup; foreach ($fields as $field) { $inputfield = $fields->{$field->name}->getInputfield($p); $form->append($inputfield); } // add template name field to the form $field = $modules->get("InputfieldHidden"); $field->attr('id', 'Inputfield_template_name'); $field->attr('name', 'template_name'); $field->value = $template; $form->append($field); // append the field // add select_product to the form $field = $modules->get("InputfieldHidden"); $field->attr('id', 'select_product'); $field->attr('name', 'select_product'); $field->value = 1156; $form->append($field); // append the field // add a submit button to the form $submit = $modules->get('InputfieldSubmit'); $submit->name = 'save_new_aanvraag'; $submit->attr("value", "Go"); $form->append($submit); // only show the form if it was not just submitted/processed if (!$input->post->save_new_aanvraag) echo $form->render(); } // process the form if it was submitted if ($input->post->save_new_aanvraag) { // now we assume the form has been submitted. // tell the form to process input from the post vars. $form->processInput($input->post); // validation $email = $form->get("email"); if ($email && (strpos($email->value,'@hotmail') !== FALSE)) { // attach an error and it will get displayed along the field $email->error("Sorry we don't accept hotmail addresses for now."); } // see if any errors occurred if (count( $form->getErrors() )) { // re-render the form, it will include the error messages echo $form->render(); } else { // successful form submission $np = new Page(); // create new page object $np->template = $form->get("template_name")->value; // set template $np->parent = $pages->get('/aanvraag/'); // set the parent $np->of(false); // turn off output formatting before setting values $np->save(); foreach ($np->fields as $f) { $inputval = $form->get($f->name)->value; // sanitize fields if ($f->type == 'FieldtypePageTitle') { $sanitizer->text($inputval); // also set page name based on title $np->set('name', $sanitizer->pageName($inputval)); } if ($f->type == 'Email') $sanitizer->email($inputval); if ($f->type == 'Text') $sanitizer->text($inputval); if ($f->type == 'Textarea') $sanitizer->textarea($inputval); if ($f->type == 'Integer') $inputval = (int) $inputval; // attach fields to page $np->set($f->name, $inputval); } $np->save(); //create the page echo "<p>Page saved.</p>"; } } else { //echo $form->render(); }
    1 point
  46. Got it for ehm free. I'm a poor student so this is okay.
    1 point
×
×
  • Create New...