Jump to content

Leaderboard

Popular Content

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

  1. We have it in use for years now on a very large site 400'000+ pages, no obvious issues so far.
    4 points
  2. Ukrainian translation, based on ProcessWire 3.0.88 Dev *** Не буду стверджувати, що переклад ідеальний, орієнтовно на 4+ https://en.wikipedia.org/wiki/Ukrainian_language uk-wire.csv
    3 points
  3. Yes, this is somewhat unexpected behavior and can be replicated with a short piece of code: $r = $pages->get('/'); $x = $r->children; $y = $r->children; $z = $r->children->prepend($r); echo $x . PHP_EOL; echo $y . PHP_EOL; echo $z . PHP_EOL; This outputs here: 1001|1005|1025 1|1001|1005|1025 1|1001|1005|1025 This illustrates that consecutive calls to children() return a pointer to the original PageArray while the very first call returns an independent copy. That's likely a caching thing, though I can't say if this is expected behavior. Tested with different versions of PW.
    3 points
  4. see this example: the key is the entityEncodeText option: https://processwire.com/api/ref/inputfield/
    3 points
  5. There is an option in field settings input tab:
    3 points
  6. I agree. Those small modules, included in the core modules, would not bring any overhead, on contrary, it would reduce the total number of hooking and autoload modules. I don't know, Ryan is the only one who could provide the answer. There is feature request for this https://github.com/processwire/processwire-requests/issues/136. In this post (Roadmap for 2016) https://processwire.com/blog/posts/happy-new-year-heres-a-roadmap-for-processwire-in-2016/ Ryan said: "One of the goals with 3.x is to make the core smaller rather than larger. Consistent with this, we'll be evaluating all the currently bundled core modules and determining which ones no longer belong in the core." Maybe this is the reason?
    3 points
  7. ProCache, Apache *hugahuga*.
    2 points
  8. Just logout then redirect the user : $session->logout(); $session->redirect("./"); And you could write a GET variable ?logout=1 in your link then check this var to logout the user. if($input->get->logout) { $session->logout(); $session->redirect('./'); } else { $out = "<p>You are logged in. <a href='./?logout=1'>Logout</a></p>"; }
    2 points
  9. Hi, I normally don't express myself on those kind of discussions, but as a newcomer, and a also as non-professionnal developper, I want to emphases about simplicity of PW. I really liked the fact I was able to construct something even with my basic knowledge of PHP, and the system could sustain more complicated things, with my knowledge growing. IMHO, it should stay like this, open to everyone. In the previous CMS I used, I started like this, simple and understandable, but with years become so focused to developers than it was impossible to follow developments if you don't used it on day-to-day basis (maybe because me and other people like me didn't feel included and never participated to roadmaps discussion!!). I understand those having different needs than me, but I don't know if it's possible to find a way to activate/install more advanced features without impacting a simple core. I agree with latest posters, small issues should be fixed. Furthermore, I still wondering why really small useful things are not included in the core (and already existent). Just 2 examples: I put on forum my wish to have a button to save+add new field (as already existing in pages). @Robin S created this module in couple of hours. Second example : PW upgrade : who don't use that? Why it's not included in core? There is many small things like this. Thanks everyone for your work AND your answers to my naïve questions. Mel
    2 points
  10. Since I was stuck to my flat today I took up a wish and rolled a Process module / CKEditor plugin combo that adds @-autocomplete like the mentions here in the forum to CKEditor fields. It's configurable, but only in module settings for now, the positioning of the select list is quite off and there's still some visual work to be done, so it is in early alpha state. Nonetheless, if you want to take a look, here it is: https://github.com/BitPoet/ProcessMention After installation, you may want to look into the "Additional selector" entry in the module's settings. You will most likely want to limit results to certain templates there. Edit: Updated to version 0.0.30 with fixed positioning of the dropdown. Edit2: Settings are configurable in field context now. If pwmentions is enabled, the according settings are shown on the "Input" tab.
    1 point
  11. If you've ever needed to insert links to a large number of files within CKEditor you may have found that the standard PW link modal is a somewhat slow way to do it. This module provides a quicker way to insert links to files on the page being edited. You can insert a link to an individual file, or insert an unordered list of links to all files on the page with a single click. CKEditor Link Files Adds a menu to CKEditor to allow the quick insertion of links to files on the page being edited. Features Hover a menu item to see the "Description" of the corresponding file (if present). Click a menu item to insert a link to the corresponding file at the current cursor position. The filename is used as the link text. If you Alt-click a menu item the file description is used as the link text (with fallback to filename if no description entered). If text is currently selected in the editor then the selected text is used as the link text. Click "* Insert links to all files *" to insert an unordered list of links to all files on the page. Also works with the Alt-click option. Menu is built via AJAX so newly uploaded files are included in the menu without the page needing to be saved. However, descriptions are not available for newly uploaded files until the page is saved. There is an option in the module config to include files from Repeater fields in the edited page. Nested Repeater fields (files inside a Repeater inside another Repeater) are not supported. Installation Install the CKEditor Link Files module. For any CKEditor field where you want the "Insert link to file" dropdown menu to appear in the CKEditor toolbar, visit the field settings and add "LinkFilesMenu" to the "CKEditor Toolbar" settings field. http://modules.processwire.com/modules/cke-link-files/ https://github.com/Toutouwai/CkeLinkFiles
    1 point
  12. Hi @Chris, you PM'ed me with the question if I once had written a module that creates one page per uploaded image. No, I never had. But those questions are better asked directly to our friendly and helpful community. I remember too that there was something, but was it somas images manager? or does anyone else has written something among that line? If there isn't anything else around here, you may strip out the upload and page creation process from somas module.
    1 point
  13. @Robin S Please don't apologise. Your assistance has been extremely helpful. I didn't need to execute the API code as I had already gone through all the posts and manually corrected them. The solution was to remove <page id> - from the name field, make any changes and then save them. However, the updated code you have kindly provided resolves the issue and avoids having to do that in future. Many thanks again for all your help.
    1 point
  14. Yes is normal. _init.php the page is already rendering and the APi vars are extracted.
    1 point
  15. 1 point
  16. The title field is a multi language field, not a language alternate field. The id of the HTML input element is of the format Inputfield_[field name]__[language id] (Example: Inputfield_title__1013). You can see the language id in the address bar when you edit a language. In the showIf condition, enter that HTML id without the Inputfield_ prefix, e.g. title__1013!=''
    1 point
  17. Tried same code, two different sites, one of which is nearly a fresh install with exactly the same issue. If the outer loop, loops through the top level pages (including home) and the inner loop loops through the children of the top level pages, home should never be output inside the inner loop, but it does for some reason. This only happens using: <?php $topLevels = $root->children->prepend($root); ?> <ul> <?php foreach($topLevels as $topLevel):?> <li> <a href="#"><?= $topLevel->title; ?></a> <ul> <?php foreach($topLevel->children as $topLevelChild): ?> <li><a href="<?= $topLevelChild->url ?>"><?= $topLevelChild->title ?></a></li> <?php endforeach; ?> </ul> </li> <?php endforeach; ?> </ul> There's literally no other code affecting this. Nothing in '_init.php' (which I do prepend) and this is just direct output. Check out the resulting WireArrays for these two variables ($topLevels and $topLevels2): <?php $root = $pages->get("/"); $topLevels = $root->children->prepend($root); $topLevels2 = $root->and($root->children); ?> They're not the same. This isn't an important issue, but I'm curious I can't see any errors in the code, or any other code that would affect this throughout the site.
    1 point
  18. I addition to the entityEncodeText that @bernhard mentioned, you might also find this useful: http://modules.processwire.com/modules/dynamic-description-notes/
    1 point
  19. @godmok and @szabesz - well that took way too much time It's very rough, but please test the new version on the dev branch: https://github.com/adrianbj/FieldtypePhone/tree/dev This new version has lots of breaking changes, so please don't update an existing site. You'll need to uninstall and reinstall to get the new format for the default formats to show. You could I guess copy/paste them in from the module code to that field if you have data already that you can't lose. Format options now have a proper name associated with them, so if you change the pattern for a format, it should update the output everywhere. Also, you can now see exactly how each format will look based on the pattern, rather than you having to enter that in a comment at the end. When defining formats, follow this format. The category headings are optional. The key things is: name | pattern Now you can also call these formats separately from the API regardless of what the selected output format is. You can call like this: $page->phone->australiaWithCountryAreaCodeNoLeadingZero
    1 point
  20. Hi, Also, you don't have the non-www version redirected to the www version, or vice versa. And you should normally only have one meta name="canonical" version in your source code. Currently, it changes depending on the non-www or www version.
    1 point
  21. Hi @adrian, Have you given any thought to the idea of making some of your modules PW3-only? For most modules I think it's nice to keep PW2 support (I have been doing that for my modules so far) but in the case of Admin Actions where the idea is that users can code their own actions it would be good to be able to declare the ProcessWire namespace in the action files, for the sake of code completion and avoiding false code warnings in an IDE. I could add the namespace to ProcessAdminActions.module manually (to avoid fatal PHP errors), but then it will get lost when the module is upgraded. This isn't a big issue and I can just comment out the namespace declaration in my action files after I've finished working on them. Just thought I'd ask for your view on things.
    1 point
  22. Sorry no experience in this sector - I've had a look at https://www.mollie.com/ but never had the possibility to try it out but they seem to offer easy recurring payments.
    1 point
  23. @ridgedale, sorry, I should have tested that hook better. It seems that PHP's strpos() function will not work with an integer (page ID) as a parameter. So the page ID needs to be cast to a string. I'll add the revised code below and edit my earlier replies. To fix your posts, first remove the hook in /site/ready.php. Next you will need to execute some API code. Not sure how experienced you are with that, so a couple of ways you can do it... 1. If you have Tracy Debugger installed you can use the Console panel. 2. Assuming your site is a dev site and you are the only person with access to it, you can put the code in a template file (e.g. home) and then load a page using that template on the front-end. Code is: $items = $pages->find("template=blog-post, include=all"); foreach($items as $item) { $item->of(false); $item->name = $item->id . '-' . $sanitizer->pageName($item->title, true); $item->save(); } When you have executed that and checked that your blog post names are okay you can remove the API code above from your template file (if you executed it that way) and add the revised hook back to /site/ready.php: $pages->addHookAfter('saveReady', function (HookEvent $event) { $page = $event->arguments(0); if($page->template != 'blog-post') return; // Only for the blog-post template if(!$page->id) return; // Skip pages that are brand new and aren't yet populated with data // If the page name doesn't start with the page id if(strpos($page->name, (string) $page->id) !== 0) { // Prepend the page id to the page name $page->name = $page->id . '-' . $page->name; } });
    1 point
  24. Hey thmsnhl, I'm using ProcessWire for a few projects at work as well as for my personal projects. Originally coming from Ruby On Rails I also encountered problems with our database synchronization when it comes to team development on a single project. Depending on the project we solved this using Field/Template Export/Import while also only working on certain parts of the page. Most projects are already finished in terms of template/field structure so there is no need to have an always up-to-date local database snapshot. If the project is not finished in terms of template/field structure we usually sit together and draft a "this-solves-everything"-kind of template/field and synchronize this to our local databases once and then just code ahead. Other frameworks solve this by using Migrations and although ProcessWire does not support Migrations in the core (as of now) you can use this module: https://modules.processwire.com/modules/migrations/ (Here are a few code samples and documentation: https://lostkobrakai.github.io/Migrations/). This module does not directly add tables and columns to the database like RoR migrations do but instead allows you to do nearly everything you can do in the Admin UI using code. You can for example create templates, move fields around, install modules, setup users etc. It can be a bit tedious at first to learn all the new APIs this module offers but the benefits, especially for large projects, speak for themselves. These migrations can be safely checked into your git repository and whenever one of your teammates encounters a problem with his out-to-date database he can simply run the migrations files. So instead of adding templates and fields on production you write them in code and deploy your changes to production, then you migrate either using the CLI utility or the admin backend. You can also integrate this into your build toolchain (like Amazon CodeStar). Check this code example I bet it feels quite familiar: <?php class Migration_2018_01_16_12_32 extends Migration { public static $description = "Add postalcode to a hotel"; public function update() { $this->insertIntoTemplate('hotel', 'postalcode', 'title'); $this->editInTemplateContext('home', 'postalcode', function($f){ $f->label = "Hotel Postalcode"; $f->columnWidth = 50; }); } public function downgrade() { $t = $this->templates->get('hotel'); $t->fieldgroup->remove('postalcode'); $t->fieldgroup->save(); } } This adds a `postalcode` field right after the title field to the hotel template. And it removes this field when you rollback your migration. This is how we tackle this problem.
    1 point
  25. Hi @flydev Thank you, this is indeed a great solution. But for my case I used another tactic, using the search technique, so my PHP code looks like this: <ul class="row shop list-unstyled" id="grid"> <?php // search.php template file // look for a GET variables named 'min', 'max' and sanitize it $min = $sanitizer->text($input->get->min); $max = $sanitizer->text($input->get->max); // did $min and $max have anything in it? if($min and $max){ // Send our sanitized query 'min', 'max' variable to the whitelist where it will be // picked up and echoed in the search box by _main.php file. Now we could just use // another variable initialized in _init.php for this, but it's a best practice // to use this whitelist since it can be read by other modules. That becomes // valuable when it comes to things like pagination. $input->whitelist('min', $min); $input->whitelist('max', $max); // Sanitize for placement within a selector string. This is important for any // values that you plan to bundle in a selector string like we are doing here. $min = $sanitizer->selectorValue($min); $max = $sanitizer->selectorValue($max); // Search the title and body fields for our query text. $selector = "price>=$min , price<=$max"; //if($user->isLoggedin()) $selector .= ", has_parent!=2"; // Find pages that match the selector $items = $pages->find($selector); // did we find any matches? if($items->count) { $count = "Görkezilen baha boýunça jemi $items->count sanysy tapyldy"; ?> <!-- product --> <p class="shop-results space-left"><strong><?=$count;?></strong> </p> <?php foreach ($items as $match): ?> <li class="col-sm-6 col-md-3 col-lg-3 product m-product" data-groups='["bedroom"]'> <div class="img-bg-color primary"> <h5 class="product-price"><?=$match->price;?> manat</h5> <a href="<?=$r->url;?>" class="product-link"></a> <!-- / product-link --> <img src="<?=$match->image->first()->url;?>" alt="<?=$match->image->description;?>"> <!-- / product-image --> <!-- product-hover-tools --> <div class="product-hover-tools"> <a href="<?=$match->url;?>" class="view-btn" data-toggle="tooltip" title="Giňişleýin gör"> <i class="lnr lnr-eye"></i> </a> <!--<a href="shopping-cart.html" class="cart-btn" data-toggle="tooltip" title="Add to Cart"> <i class="lnr lnr-cart"></i> </a>--> </div><!-- / product-hover-tools --> <!-- product-details --> <div class="product-details"> <h5 class="product-title"><?=$match->title;?></h5> <!--<p class="product-category">Hemme zat içinde</p>--> </div><!-- / product-details --> </div><!-- / img-bg-color --> </li> <!-- / product --> <?php endforeach; } } else { ?> <!-- product --> <?php foreach ($result = $page->children() as $r): ?> <li class="col-sm-6 col-md-3 col-lg-3 product m-product" data-groups='["bedroom"]'> <div class="img-bg-color primary"> <h5 class="product-price"><?=$r->price;?> manat</h5> <a href="<?=$r->url;?>" class="product-link"></a> <!-- / product-link --> <img src="<?=$r->image->first()->url;?>" alt="<?=$r->image->description;?>"> <!-- / product-image --> <!-- product-hover-tools --> <div class="product-hover-tools"> <a href="<?=$r->url;?>" class="view-btn" data-toggle="tooltip" title="Giňişleýin gör"> <i class="lnr lnr-eye"></i> </a> <!--<a href="shopping-cart.html" class="cart-btn" data-toggle="tooltip" title="Add to Cart"> <i class="lnr lnr-cart"></i> </a>--> </div><!-- / product-hover-tools --> <!-- product-details --> <div class="product-details"> <h5 class="product-title"><?=$r->title;?></h5> <!--<p class="product-category">Hemme zat içinde</p>--> </div><!-- / product-details --> </div><!-- / img-bg-color --> </li> <!-- / product --> <?php endforeach; }?> <!-- sizer --> <li class="col-sm-6 col-md-3 col-lg-3 shuffle_sizer"></li> <!-- / sizer --> </ul> <!-- / products --> and Javascript: var limitSlider = document.getElementById('range-slider'); noUiSlider.create(limitSlider, { start: [ 0, 10000 ], step: 1, behaviour: 'drag', connect: true, range: { 'min': 0, 'max': 10000 } }); var limitFieldMin = document.getElementById('range-slider-value-min'); var limitFieldMax = document.getElementById('range-slider-value-max'); limitSlider.noUiSlider.on('update', function( values, handle ){ (handle ? limitFieldMax : limitFieldMin).value = values[handle]; }); The range filter area in my page is: <div class="range-filter"> <form action="<?php echo $pages->get('template=shop-right')->url;?>" method='get'> <div class="column filter-button"> <button type="submit" class="btn btn-xs btn-default-filled btn-rounded">Saýhalla</button> </div> <!--/ filter-button --> <div class="column range-values"> <input type="text" class="value" name="min" size="6" id="range-slider-value-min" value=""> <input type="text" class="value" name="max" size="6" id="range-slider-value-max" value=""> </div><!-- / range-values --> </form> </div><!-- / range-filter --> So whenever I press button 'sort' which is 'sayhalla' in my example, all the values are posted and results are returned as a result. Your case is super as well, it works perfectly but for my template it is better to implement it this way. I tried to implement yours too, but no success. Thank you again!
    1 point
  26. To get you started, I give you an example of an ajax request triggered by a noUiSlider's event which update the markup. Do not hesitate to ask if you don't understand something. Javascript code : // slider element var slider = document.getElementById('noUiSlider'); // create the slider object noUiSlider.create(slider, { start: [0, 100], step: 1, // avoid float values range: { 'min': 0, 'max': 100 } }); // change the value when noUiSlider values are updated slider.noUiSlider.on('update', function( values, handle ) { if ( handle ) { $("#noUiSlider-data").data("max", values[handle]); } else { $("#noUiSlider-data").data("min", values[handle]); } }); // on event 'set' send ajax request slider.noUiSlider.on('set', function( values, handle ) { // get the min and max from the data attribute of #noUiSlider-data $data = {min: $("#noUiSlider-data").data("min"), max: $("#noUiSlider-data").data("max")}; // ajax request $.ajax({ url: $(this).data('url'), // url from the data attribute of #noUiSlider type: "post", data: $data }).done(function (response, textStatus, jqXHR) { $('#list').html(response); // write markup to #list element }) }); PHP code : <?php namespace ProcessWire; $list = ''; $limit = 100; if(isset($input->post->min) && isset($input->post->max)) { $min = $input->post->min; // don't forget to sanitize $max = $input->post->max; // don't forget to sanitize $li = ''; $products = $pages->find("template=product, start=$min, limit=$max"); // let assume there is a template 'product' foreach ($products as $product) { $li .= "<li>". $product->title . "</li>"; } $list = "<ol>$li</ol>"; echo $list; } ?> HTML Markup : <div id="noUiSlider" data-url="<?= $page->url; ?>"></div> <span id="noUiSlider-data"></span> <div id="list"> <?= $list ?> </div> #noUiSlider is the slider element #noUiSlider-data will contain values changed from the #uiSlider element #list is the element updated by the ajax response enjoy
    1 point
  27. 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
  28. Just for reference, now we have (thanks @Robin S):
    1 point
  29. Got it for ehm free. I'm a poor student so this is okay.
    1 point
  30. No need for double redirects i think, just define it in your site/config.php: $config->http404PageID = 27; This line is from wire/config.php. Setting it in site/config.php should override. Just replace '27' with the id of any page you desire. Untested and maybe i'm overlooking an obvious drawback but this should work.
    1 point
×
×
  • Create New...