Jump to content

Leaderboard

Popular Content

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

  1. If anybody wants to steal some code (or use that little module as is, of course), feel free...
    8 points
  2. So I stumbled over the request to allow limiting templates to be used only once under every parent page in this thread and found that this would actually come in handy (also in a site I've built). The code can be found on github and soon also in the module repo. After installation, you'll find a new checkbox "Only once per parent" in the family tab when editing a template.
    4 points
  3. SYNOPSIS A little guide to generating an sitemap.xml using (I believe) a script Ryan originally wrote with the addition of being able to optionally exclude child pages from being output in the sitemap.xml file. I was looking back on a small project today where I was using a php script to generate an xml file, I believe the original was written by Ryan. Anyway, I needed a quick fix for the script to allow me to optionally exclude children of pages from being included in the sitemap.xml output. OVERVIEW A good example of this is a site where if you visit /minutes/ a page displays a list of board meetings which includes a title, date, description and link to download the .pdf file. I have a template called minutes and a template called minutes-document. The first page, minutes, when loaded via /minutes/ simply grabs all of its child pages and outputs the name, description and actual path of an uploaded .pdf file for a visitor to download. In my back-end I have the template MINUTES and MINUTES-DOCUMENT. Thus: So, basically, their employee can login, hover over minutes, click new, then create a new (child) record and name it the date of the meeting e.g. June 3rd, 2016 : --------------------------- OPTIONALLY EXCLUDING CHILDREN - SETUP Outputting the sitemap.xml and optionally excluding children that belong to a template. The setup of the original script is as follows: 1. Save the file to the templates folder as sitemap.xml.php 2. Create a template called sitemap-xml and use the sitemap.xml.php file. 3. Create a page called sitemap.xml using the sitemap-xml template Now, with that done you will need to make only a couple of slight modifications that will allow the script to exclude children of a template from output to the sitemap.xml 1. Create a new checkbox field and name it: sitemap_exclude_children 2. Add the field to a template that you want to control whether the children are included/excluded from the sitemap. In my example I added it to my "minutes" template. 3. Next, go to a page that uses a template with the field you added above. In my case, "MINUTES" 4. Enable the checkbox to exclude children, leave it unchecked to include children. For example, in my MINUTES page I enabled the checkbox and now when /sitemap.xml is loaded the children for the MINUTES do not appear in the file. A SIMPLE CONDITIONAL TO CHECK THE "sitemap_exclude_children" VALUE This was a pretty easy modification to an existing script, adding only one line. I just figure there may be others out there using this script with the same needs. I simply inserted the if condition as the first line in the function: function renderSitemapChildren(Page $page) { if($page->sitemap_exclude_children) return ""; ... ... ... THE FULL SCRIPT WITH MODIFICATION <?php /** * ProcessWire Template to power a sitemap.xml * * 1. Copy this file to /site/templates/sitemap-xml.php * 2. Add the new template from the admin. * Under the "URLs" section, set it to NOT use trailing slashes. * 3. Create a new page at the root level, use your sitemap-xml template * and name the page "sitemap.xml". * * Note: hidden pages (and their children) are excluded from the sitemap. * If you have hidden pages that you want to be included, you can do so * by specifying the ID or path to them in an array sent to the * renderSiteMapXML() method at the bottom of this file. For instance: * * echo renderSiteMapXML(array('/hidden/page/', '/another/hidden/page/')); * * patch to prevent pages from including children in the sitemap when a field is checked / johnwarrenllc.com * 1. create a checkbox field named sitemap_exclude_children * 2. add the field to the parent template(s) you plan to use * 3. when a new page is create with this template, checking the field will prevent its children from being included in the sitemap.xml output */ function renderSitemapPage(Page $page) { return "\n<url>" . "\n\t<loc>" . $page->httpUrl . "</loc>" . "\n\t<lastmod>" . date("Y-m-d", $page->modified) . "</lastmod>" . "\n</url>"; } function renderSitemapChildren(Page $page) { if($page->sitemap_exclude_children) return ""; /* Aded to exclude CHILDREN if field is checked */ $out = ''; $newParents = new PageArray(); $children = $page->children; foreach($children as $child) { $out .= renderSitemapPage($child); if($child->numChildren) $newParents->add($child); else wire('pages')->uncache($child); } foreach($newParents as $newParent) { $out .= renderSitemapChildren($newParent); wire('pages')->uncache($newParent); } return $out; } function renderSitemapXML(array $paths = array()) { $out = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; array_unshift($paths, '/'); // prepend homepage foreach($paths as $path) { $page = wire('pages')->get($path); if(!$page->id) continue; $out .= renderSitemapPage($page); if($page->numChildren) { $out .= renderSitemapChildren($page); } } $out .= "\n</urlset>"; return $out; } header("Content-Type: text/xml"); echo renderSitemapXML(); // Example: echo renderSitemapXML(array('/hidden/page/')); In conclusion, I have used a couple different processwire sitemap generating modules. But for my needs, the above script is fast and easy to setup/modify. - Thanks
    4 points
  4. @noelboss just posted a comment in this thread and the thread is just one of many examples of people looking for solutions of a proper staging/production strategy. we have some modules that try to close this gap, but imho this is an important part of a professional workflow and therefore should be part of the core. don't know how that could be implemented exactly, but at least it would be great to have a thought-out strategy and maybe some kind of standard/best practise guide of how to keep staging/production in sync, be safe while editing, integrate GIT in this process etc. while other features are nice to have for me, this is really one thing that makes me feel totally unprofessional and is a huge pain. i don't think that the options we have so far are as good as they could be. for example if i had to push a fix to a live system, i wished it would be possible to: pull the latest version from live to dev with one click (excluding a predefined list of files / db tables) work on that dev version locally (having all files on the local computer makes searching all files a lot easier) push the fix to git push the fix to production some parts of this workflow can be done with the migrations module, some with the quite new duplicator module, some could be implemented via githooks, but, hey... we are talking about ProcessWire and where PW really shines is making our lives as devs easier and in this special case i feel that this is not true maybe i'm just too inexperienced in this topic and there are proper solutions out there, but following the forum over the last years i didn't see a solution that felt "processwire-awesome". maybe a blog-post covering this topic could be a first step. and maybe i'm totally alone with this opinion... a feature request-voting system could also help a lot here [pub] that was the tracy-boost
    3 points
  5. Ah true, forgot to mention it, this was also one of the only things I identified as a drawback while working on my first PW project. While not perfect, there is a solution for WP that could help as an inspiration: https://deliciousbrains.com/wp-migrate-db-pro/ We are using Gitlab with Hooks to automatically deploy files to the staging and live systems on the corresponding branches and wp-migrate-db-pro for DB syncs as well as the .htaccess method to reference files not found on staging and development environments. If it would work reliably, this module could be an easy solution to migrate templates:
    2 points
  6. To follow up on @Robin S's Tracy example, you can also access this without even needing to do an manual dump call. If you go to edit the field in the backend, you will see this in the Request Info panel. In this case you can quickly see that the inputfield is "InputfieldCheckboxes". You can also find this when viewing a page on the frontend if you go to Request Info > Field List & Values where you will see this, which is just one row of a table which shows the same info for all fields on the page.
    2 points
  7. I used to use that module, but these day I prefer AdminOnSteroids for that functionality.
    2 points
  8. Filling the bounding box is the standard behaviour for the size() method. $image->size(300, 200); For fit, I think it's a not a good idea to add background colour to the canvas. Better to use maxSize(), or size() with cropping set to false, and then center the image within the bounding box with CSS. But if you want to add a background colour you can do this with the canvas() method of Page Image Manipulator.
    2 points
  9. HI @lickny2001 Try to use "insertAfter" method https://processwire.com/api/ref/wire-array/insert-after/
    2 points
  10. That's an amazing list of 2017's features. Seeing them in a single place makes you appreciate how lucky we and our clients are. Thanks for another incredible year of updates. I imagine everyone's wish list is different. This is what I'd like to see natively in PW. I know some of these are already available as Modules so no offence if you're reading this and have already put tons of work into creating something similar. Processwire Multi-Admin A Processwire dashboard which allows me to monitor multiple installs across different servers. This dashboard would list my installs, version number, and display available upgrades (Module and Core) and allow me to update above from central place. It might show me logged in user(s), uptime etc. Media Manager A built in MM which acts as a single place to manage all uploads. Using the MM you can find, list and edit any uploaded file/image. and its versions. Add tags, crop, delete, rename, copy, bulk upload etc Furthermore the MM should work with user permissions so a MM for me might list different assets than an editor etc Importantly, the look of the MM would be consistent with what's already in place and the new UI Kit theme. SEO A native SEO Module that is maintained and updated as modern SEO evolves. Image Cropping Pre-set image crops and a way to define and manage them. That's it :-/
    2 points
  11. Just a little update because of new API additions, so now you could just do foreach ($pag as $p) { foreach ($languages->find('name!=default') as $lang) { $p->setAndSave("status$lang", 1); } } Thanks @szabesz for mentioning I'm adding this here for completeness
    2 points
  12. In this post, we take a look at all that was covered in 2017, and our roadmap for 2018, which includes plans for the year ahead. https://processwire.com/blog/posts/processwire-2018-roadmap/
    1 point
  13. If i were faced with your issue, i would change the structure of the pages and all of that, it doesn't make sense to me; i guess it must make complete sense to someone else, whoever set it up that way, but obviously the module author(s) never accounted for this sort of setup; You can also just roll your own RSS feed, then you don't need to be straddled with module interactions; it's not that hard to just make your own RSS class that takes into account any arbitrary structure and outputs it how you want; you could also just extend the module itself and modify the Module Class to a new one, and work from there until it works...
    1 point
  14. Hi @sebr You have to install the Process module called ProcessDuplicator. You can find it in the menu Modules > Install > ProcessDuplicator then once installed, you will find the module under Setup > Duplicator or click the link <eye-icon> Package Manager in Duplicator.
    1 point
  15. You posted the correct link, but Adrian missed it
    1 point
  16. This approach works for the backend too. $wire->addHookBefore('InputfieldSelect::render', function (HookEvent $event) { $inputfield = $event->object; $field = $inputfield->hasField; if(!$field || $field->type != 'FieldtypeOptions') return; if($field->required) $inputfield->options = array('' => 'Choose One') + $inputfield->options; });
    1 point
  17. Yeah, it's not a solution. There is an open GitHub issue for this: https://github.com/processwire/processwire-issues/issues/349
    1 point
  18. Glad you have it working. Just a couple of things to be aware of if you do it this way: 1. Depending on how many Walk Variations are within a Walk, and how many Walk Segments are within a Walk Variation, you could end up loading way more pages into memory than you actually need (you only need the Walk pages). But if the number of pages isn't large then this could be fine. 2. If there are a lot of Walks in the continent, and for efficiency you want to paginate them into groups of 20 for example, this becomes difficult. Because you don't know how many Walks will result from any set of Walk Segments until you loop over them.
    1 point
  19. Not quite sure what you mean here. You somehow edited the Map Marker fieldtype to include a continent subfield? Or do you just mean you added a field Continent to the Walk Towns template? It might depend a bit on what type of field Continent is, but something like this should work: $walks_in_africa = $pages->find("template=walk, (children.children.start_town.continent=Africa), (children.children.end_town.continent=Africa)");
    1 point
  20. I want to see a separate channel in the forum where everybody can upload graphics, banners, animations and video clips to promote processwire.
    1 point
  21. I'm using mod_rewrite to link to files on the live system if they are not found on the development systems: # file: .htaccess <IfModule mod_rewrite.c> RewriteEngine On # Get all asset files from remote if localy not available RewriteCond %{REQUEST_FILENAME} !-f [NC] RewriteCond %{REQUEST_URI} ^/www/site/assets/files/ RewriteRule ^(.*)$ https://www.live.com/$1 [L] </IfModule>
    1 point
  22. Thanks for those reports @godmok - should all be fixed in the latest version, although I didn't quite understand so could you please check that is working now as well. I assume it was related to the leading zero issue which is now fixed.
    1 point
  23. You may know this already, but just to explain the reason... Guest users do not have direct access to repeater pages because they live under the Admin branch (guest users can only view repeater content via a repeater field). One solution is to add "check_access=0" to the selector if it is definitely the repeater pages themselves you want to find. Or instead you might want to find the pages that the repeater pages are contained within... $container_pages = $pages->find("Images_With_Variations.title|Images_With_Variations.keywords*=" . $search_term_string);
    1 point
  24. Hi, I just want to thank to flydev and everyone else who has contributed to this wonderful module. For me, Duplicator It has worked flawlesly to make backups and bring those backups to my local machine to test new functionality. Sincerely a fellow Processwire developer.
    1 point
  25. If you're not comfortable doing this manually, take a look at this action in the AdminActions module: Copy Content to Other Field This action copies the content from one field to another field on all pages that use the selected template. This can be useful if you decide you need to split one field into two to allow different settings on different templates. It also makes it easy to move content from one field type to another one that is incompatible.
    1 point
  26. For each field that you want to change to CKEditor, add a new CKEditor field to the template. Then use the API to set the formatted value of the textarea field to the CKEditor field. When you have done the API operations and checked that everything is okay you can delete the old textarea field. See here:
    1 point
  27. You will need to use a repeating field type "Players" for the players. For me, the order of preference in terms of UI would be: 1. ProFields Table 2. Repeater 3. PageTable Within each item of Players you have two Page Reference fields - one for Player and one for Instrument. The safest thing would be to specify the instrument for every player in the Players field. But if the default instrument of a player is something that is fixed once selected (i.e. a player never changes their default instrument) then you could consider including the default instrument within the "Custom page label format" of the Player field. Then the instrument field could be named "Instrument override" and you only set it if the player is performing with something other than their default instrument. This would make it a quicker process to add players to a concert.
    1 point
  28. There is a SEO module already. I guess it's not maintained anymore, but it can be a good base for extensions. What do you miss? Personally, I don't think a SEO module belongs to the core (if it's that what you have meant by "native"), because the core should keep it's clean and generic character. Keep in mind that ProcessWire is not just used for websites, and even a lot of websites don't need that much SEO.
    1 point
  29. If there are many such fields, consider changing the textarea values via API + regex. e.g. with https://gist.github.com/jbroadway/2836900 Just take care about when using / removing / adding which textformatters in the whole process. Perhaps do a test with only a handful of fields first, and see if it works out OK?
    1 point
  30. Please post your code or explain exactly what you are doing.
    1 point
  31. SEO and image cropping is also what I find very useful. In addition to image manipulations it would be great to add a feature that makes the scaling of images to FIT/FILL bounding boxes possible. Take a look at http://a32.me/2012/06/scale-images-to-fit-fill-bounding-box-in-php-using-gd/ for a detailed example. This is useful if you have images with different proportions fitting in a box (fe. logos of different partners, product images). Best regards
    1 point
  32. Hi @Antonio Iorio, Regarding where to place your ads, is dependant on the ad itself. For example, a creative with wide dimensions doesn't fit in a sidebar. When I wrote the ad manager plugin fo wp many years ago, I referenced the IAB Standards for ad sizes. In your screenshot you will notice a Leaderboard 728x90 type ad. This ad is designed to display in one of three locations (I used the term zone in my plugin). This banner should be placed in the header and or footer of your page, or even between two separate sections of body content. The <script> section of your screenshot is apparently how altervista wants you to include the ads. You would simply edit your PW templates and include that script at the location you want the ad to appear. You repeat that process for all the ads you want to present. One note of caution. While ads can be a good means to generate a small income, you should use them sparingly. No user wants to weed through a bunch of ads in order to continue reading your content. So I would keep with the old axiom, less is more. I hope this helps. Let us know if you have any further questions.
    1 point
  33. Hi Antonio, and welcome to the forum. With regard to incorporating altervista advertising, I did not see any reference (I don't speak Italian) regarding any form of advertising options for their hosted members. I did notice they have a support forum link at the bottom of the page. I would ask your advertising question there. Once you have the necessary information you can ask here how best to include that information. Regarding your css and php file changes, you usually need to clear any cached data in your browser before you see any changes.
    1 point
  34. I know this old, but the answer to this question is to add: $accept->attr('data-href', wire('config')->urls->admin . 'page/edit/?id=1479'); Remove this line: $accept->attr('href', 'http://localhost/winkelmann/www/bewerbertool-talents/admin/page/edit/?id=1479'); Hope that helps the next person.
    1 point
  35. It sounds like one of the factors that determines which roadmap items get attention first is the level of interest within the community (makes sense). But it would be good to have a more accurate and transparent gauge of the interest in each roadmap item. A simple solution would be to have an official Roadmap sub-forum with a topic for each roadmap item (separate from the Wishlist sub-forum). The community could then indicate their interest in each item by "liking" it, and give feedback or ideas about implementation in topic replies. My vote for most desirable roadmap item: Add support for custom properties in file/image fields.
    1 point
  36. There are loads of favicon generators. I generally use https://www.favicon-generator.org/ then point the link href to the appropriate directory & file
    1 point
  37. Hi @Robin S In a process module I am writing, there is a function to create a new user. With PasswordGenerator installed (a must have!) I get the following notice : PHP Notice: Trying to get property of non-object in .../modules/PasswordGenerator/PasswordGenerator.module:76 When I dump $field, Tracy return a null value : $field = $inputfield->hasField; // line 47 There is nothing special in the function, I just declare a new InputfieldPassword : [...] // password $field = new InputfieldPassword(); $field->attr("id+name","password"); $field->label = __("Mot de passe"); $field->required = true; $field->minlength = 6; $field->columnWidth = 50; $form->append($field); [...] $out = $form->render(); return $out; Thanks.
    1 point
  38. I usually go by @rafaoski's approach. I first go to http://www.favicomatic.com/, upload a 500x500 image to generate a full icon pack. Then I place the icons in their own folder inside the templates folder. Usually /site/templates/img/favicon/ Favicomatic gives you a rather large HTML snippet. Slap that on your template, and on each line that points to a file, you'll have to fix the url, like so: <link rel="icon" type="image/x-icon" href="<?= $config->urls->templates ?>img/favicon/favicon.ico">
    1 point
  39. https://processwire.com/docs/tutorials/how-to-structure-your-template-files/ https://processwire.com/blog/posts/processwire-3.0.49-introduces-a-new-template-file-strategy/ https://processwire.com/talk/topic/740-a-different-way-of-using-templates-delegate-approach/
    1 point
  40. jquery shopping carts are vulnerable on the client side as prices can be changed before checkout. many jquery shopping carts have this known security flaw. Please do some research before you are going to use a jquery based shopping cart. You have to verify that each item in the cart exists and that the price is correct. Snipcart should be safe to use. https://www.reddit.com/r/javascript/comments/1dxiy0/this_javascript_shopping_cart_just_looks_too_easy/
    1 point
  41. What @DaveP said...For example: /var/www/html/site /var/www/html/wire /var/www/html/favicon.ico /var/www/html/.htaccess
    1 point
  42. It's the folder that /site/ and /wire/ live in; the one where index.php and .htaccess are (in a standard install).
    1 point
  43. This seems to work Perhaps it could be more efficient. <?php foreach($page->verspreidingen as $country){ // all countries echo "<a href='". $country->url . "'>" . $country->title . "</a>"; $s = null; $s_out = null; $states = null; $sarray = new PageArray(); foreach ($page->sub_verspreiding as $state) { // foreach state on the page that is child of a country if ($state->parent == $country) $sarray->add($state); } foreach($sarray as $s){ $s_out .= "<a href='". $s->url . "'>" . $s->title . "</a>"; if($s != $sarray->last()) $s_out .= ", "; } if(isset($s_out)) echo " (" . $s_out . ")"; if($country != $page->verspreidingen->last()) echo ", "; } ?>
    1 point
  44. Welcome to the forums @mikhail $page->find() could be useful here. I think something like this should do the trick: // This category plus all child categories under it $categories = $page->find()->prepend($page); $pano_results = $pages->find("location_category=$categories, sort=-shoot_date, limit=10");
    1 point
  45. Hey @arjen. This is a list I published in my blog article Why ProcessWire is the best choice for your website (not always, but in most cases) to convince people, that ProcessWire is not so unknown.
    1 point
  46. I'm not sure if this is best in here or in the Modules/Plugins section – I've just been doing some general housekeeping on a site that's nearing the end of development. I deleted some fields that were no longer in use and afterwards I get an error when I try to open certain templates – Error: Call to a member function getInputfield() on a non-object (line 222 of /var/www/xxxxxx/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module) Form the error it's related to a repeater in the template, but the problem templates all have 3 repeater fields in common, so it could be anyone of them that's causing the problem. Is there any way to find out which one it might be, how can I fix the error, and what might have caused it? Update Managed to fix the errors by using the "Check field data" checkbox at the bottom of the suspected problem field Action tabs. One of the fields had a load of redundant rows in the database, deleting them seems to have done the trick.
    1 point
  47. addHookMethod !== addHook, but wire() is namespaced as ProcessWire/wire() since 3.0.
    1 point
×
×
  • Create New...