Leaderboard
Popular Content
Showing content with the highest reputation on 01/08/2018 in all areas
-
DEPRECATED - USE ROCKMIGRATIONS INSTEAD I'm very happy to share my newest module called "ProcessWire Kickstart" that I developed during the holidays Maybe some of you already saw the preview thread about this... What it does: This module makes it possible to install ProcessWire in a fully automated process. You can define all necessary settings in one single php file and you can even define "recipes" that get executed after installation. This means you can install modules, adopt settings and do whatever you want with your new site using the PW API (like creating pages and so on). You could also place a kind of frontend boilerplate on your git account and grab that after installation and place it in your templates folder. I ran out of time so maybe someone could try that out and show how he did it Additional to that there is a ProcessModule to install in your ProcessWire admin which makes creating and testing recipes super easy. Note: Alpha realese until this module gets some more testing. Please be careful with this tool since it does some heavy file system manipulations (unzipping, moving and DELETING whole directories...). Use at your own risk. Usage: Just grab a copy of the kickstarter, place it on your server, visit yournewsite.com/kickstart.php, adjust settings (like username+password) as needed and hit "install". If your mysql user does not have the rights to create a new database then you have to create a database before running the installer! Download: via SSH: cd /var/www/yournewsitedirectory wget baumrock.com/kickstart.php // or using curl curl baumrock.com/kickstart.php -L --output kickstart.php Manually: Klick baumrock.com/kickstart.php and upload the file to your server Note: baumrock.com/kickstart.php returns the current master file from the gitlab repo and changes the namespace of the script so that it can install itself via recipe. If you don't need to install the kickstart processmodule via recipe you could also download the kickstart.php file from gitlab. Screenshots/Walkthrough: The initial Screen: You can either upload a file via the left panel or take my example file from the gitlab repo: This way you can create your own kickstartfiles and host it on your own accounts. When the file is loaded you can easily edit all necessary informations, like username, password and the url where to grab ProcessWire from. I just tried it with an old version as well... 2.7 worked just fine (having the old installer that recently was updated) but an ancient 2.2.4 version failed. I don't think anybody will ever need to install lots of old versions of pw with this tool but I wanted to mention it here. Hit "install" and lean back - on my VPS it takes 15 seconds to install my very own custom version of processwire with all modules that i need After logging into your admin you'll see that all modules from your recipe are installed: Recipe Editor: As recipes are executed after processwire was installed you have all your API magic available there. Running this scripts is only possible inside of a working processwire installation, so I created a module to help you with that task. See the comments of the sample recipe for more information! I hope this tool helps you to save lots of time and create lots of awesome ProcessWire websites I would be happy to see how you use this and please share useful recipes here in the thread so that everybody can profit. Maybe you just want to throw in an idea what could be done (for example I can imagine a recipe that checks file permissions on the system after installation)... Some parts of the code and maybe also part of the idea are taken from @Soma 's old and still great online installer, thx for that!7 points
-
There is the solution with the hook. In ready.php put the following code : wire()->addHookBefore('InputfieldFile::fileAdded', function($event) { $inputfield = $event->object; // handle to the image field if(!$inputfield instanceof InputfieldImage) { // we need an images field, not a file field return; // early return } if(version_compare(wire('config')->version, '2.8.0', '<')) { // horst code $p = $inputfield->value['page']; // get the page, PW < 2.8 } else { $p = $inputfield->attributes['value']->page; // get the page, PW >= 2.8 | 3.0 (or only from 3.0.17+ ??) } if($p->id == 1029) { // adjust page id which contain the gallery image field $image_id = 0; foreach($p->gallery as $image) { if(!empty($image->image_id)) $image_id = $image->image_id; $newimage = $image; } if(isset($image_id)) $image_id++; // increment id else $image_id = 0; $p->get('gallery')->trackChange('image_id'); // prepare page to keep track for changes $newimage->set('image_id', $image_id); // set the id $p->save('gallery'); // save the field } }); result :4 points
-
What @DaveP said. There are many advantages to that, including changing the image name or the image itself without having to rewrite your code again.. Anyway, if you want to access it like you've mention...other than using raw PHP, you can also do it this way. $config->paths->assets . 'default_wallpaper.png';// if in assets folder $config->paths->templates . 'somefolder/default_wallpaper.png';// if in 'somefolder' in templates folder http://processwire.com/api/variables/config/ Note though, you will not have the $image->methods() doing it like this. But, you can call imageSizer() method directly on your default_wallpaper.png4 points
-
Recently came across the fact that if you use PaymentPaypal, on redirect Paypal shows it's United States customer form regardless what country a customer had chosen on the Processwire website. Maybe somebody mentioned this earlier or even provided a fix. If not: The PaymentPaypal module apparently does not tell Paypal the customer's country. To fix this, add this after line 16 in modules/PaymentPaypal/payment_form.php: <input type="hidden" name="country" value="<?= $customer->country ?>"> Now the Paypal page shows the correct customer form for payment data (and later the right country in Paypal reports as well).4 points
-
Yes... $noAjax https://github.com/processwire/processwire/blob/57b297fd1d828961b20ef29782012f75957d6886/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module#L17 https://github.com/processwire/processwire/blob/57b297fd1d828961b20ef29782012f75957d6886/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module#L173 points
-
There's no image ID, but the page ID plus the image name are unique. Also you code example works fine. You could use a <img src="xxx/some.jpg" data-pageid="1001" data-imageid="some.jpg"> Then you know which page and image it is. $image = $pages->get(pageid)->images->get("name=imageid"); No need for extras fields or hooks.3 points
-
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!3 points
-
You would be better having your default image attached to an actual page, like your 'home' page, or a hidden 'settings' page, then all the usual PW image methods will work. As you have discovered, they don't work the way you are trying. There might be a module that could help, but if it is just the one image, that might be overkill.3 points
-
After some testing I now use a simple HTML file field embedded into a InputfieldMarkup: public function hookAfter_ProcessPageEdit_buildFormContent(HookEvent $event) { $p = $event->object->getPage(); if('my-desired-template-name' != $p->template->name) return; // early return !! $form = $event->return; $uploadField = "<input type='hidden' name='MAX_FILE_SIZE' value='{$this->MAX_FILE_SIZE}' />Diese Datei hochladen: <input name='userfile' type='file' />"; $f = $this->modules->get('InputfieldMarkup'); $f->attr('name', 'my_markup_fieldname'); $f->value = $uploadField; $form->add($f); // write back the modified form $event->return = $form; } In init or ready I check for the file fields value, and if a file is sent, I validate the file and add it to a hidden PW file field of the page.2 points
-
Further to my earlier reply, in case this might help someone, what I often do is have a 'Fieldset in Tab' on the Home page for sitewide settings something like this... Then, before output, a little bit of code like this $home = $pages->get('/'); allows me to do echo $home->site_title; // or echo $home->images_common->first()->url; (The observant amongst you will have spotted an alarming lack of naming consistency in the code above, but heyho, this is a real example from a real site, warts and all.)2 points
-
You might also find https://processwire.com/talk/topic/4865-custom-upload-names/ useful - that way you can control the name of each image on the page and also append an ID to the end of the name using the ### formatting option.2 points
-
2 points
-
2 points
-
@dougwoodrow I guess, $this->allFields doesn't return an array due to module update issues v0.2.1 -> v1.0.7. I'm not quite sure if it works to update directly, I tried to keep everything downward compatible, but this is a really huge difference.. You could try to update version by version and always make sure to save module settings. Otherwise you could try to update the module settings json manually (not recommended but maybe the only way; edit column data in table modules, row where class equals SimpleContactForm). @alan There' s a new module version (1.0.8) which adds an option to prevent form resubmission (activate checkbox in module settings).2 points
-
In /site/ready.php: $wire->addHookBefore('ProcessPageLister::execute', function(HookEvent $event) { $lister = $event->object; $lister->nativeDateFormat = 'd.m.y'; }); See here for the format options: https://processwire.com/api/ref/datetime/date/2 points
-
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 enjoy2 points
-
Hi y'all! Long time no see. Here's a little module aiming to help you build accessible websites ProcessWire Accessibility Tools Download: http://modules.processwire.com/modules/pwat/ Github: https://github.com/marcus-herrmann/PWAT A small, but hopefully growing toolkit for creating accessible ProcessWire sites. Right now it consists of the following little helpers: tota11y visualization toolkit by Khan Academy A toggle button to see view site in grayscale. The w3c recommends checking your page without colours to see if your design still works (accompanied by a colours contrast check, which is part of tota11y) A link to test your webpage with WAVE, webaim's Web Accessibility eValuation Tool. By the nature of this tool, the website under test must be available online, local hosts won't work. Installation Once you have downloaded PWAT, go to your module Install page and click "Check for new modules". Find "ProcessWire Accessibility Tools" and click "Install". During installation, PWAT creates a new role 'pwat_user'. To use the Accessibility Tools, you have to grant user this role. Following, you can start configuring the module. Usage PWAT starts with only the tota11y script activated. On the configuration page you can decide whether PWAT is visible on admin pages if tota11y is active if the grayscale toggle is active if the link to WAVE will be visible Credits The amazing tota11y visualization tool by Khan Academy Inspiration: Paul J. Adam's bookmarklets Inspiration: WordPress wa11y Plugin Best, marcus1 point
-
1 point
-
I've never tried it...but I don't see why not it shouldn't work in something like RuntimeMarkup field.1 point
-
Thank you Bernhard for your efforts. This looks great. Hope I find the time to test it in the next days.1 point
-
1 point
-
1 point
-
Two ideas, the first one, you can make a unique name for each image and identify them by their name. But eh.. if you can't control the image's name (eg: because there are some others editors) then you must go for the second. The second, use a custom field - ID - on your image field and in your loop (the one which iterate all image to make the gallery), write the ID field value as data attribute to the images. <?php foreach($images as $image) { echo "<img src='$image->url()' data-id='$image->ID'>"; } To automate the update of the custom ID field when images are added to the image field, you will have to hook and do your logic inside the hook: checking for existing ID and assigning a new one.1 point
-
Images and Files do not have unique identifiers as such. Did you generate the gallery yourself? If yes, then you can assign 'UIDs' yourself. Here are some alternatives: All images have a sort order. You can use that, although, if the order changes, that might distort previous likes count. You can use image names as the UIDs...i.e. the my image_0x260_.jpg Similar to sort, when outputting your images, use a counter $i; $i++; and use that with ProcessWire eq(n) to get the image you want One page for each image. The page ID is the UID. Sorry, I am in a hurry, can't explain further...1 point
-
Ah. Dumb me. I changed wrong property. Auto "memory_limit" blame. Thanks.1 point
-
@Lyndaa, Moderator note I have removed the link from your post. We do not allow links to third parties for first posters. This is to discourage spam (including subtle advertising). In fact, I don't see how your post is related to ProcessWire at all. I will revisit this and remove your post altogether unless you can otherwise show how it is related to ProcessWire.1 point
-
Change it in your php.ini...if you have access to system files on your server. If not, there are other ways.1 point
-
1 point
-
Just wanted to add that it's not just PHP that treats 0 as False and 1 as True. You'll find most (traditional) languages will do the same (at least the ones I've come across). There are some exceptions like Ruby & Lisp which treats 0 as true, AFAIK. If you're wondering why 0s & 1s ... well I don't have a definite answer myself as it's one of those topics that will divide opinion. IMHO I side with the view that it originates from Electronics & Boolean Algebra. But it certainly sounds like a question for Quora1 point
-
Version 2.0.0 of Version Control was just pushed to the 2.0 branch at GitHub. While I'd be happy to hear how it works for you, please note that this should be considered a beta release: so far it seems to be working with basic text fields and file/image fields, but honestly I've not tested it much yet (got the file field part working literally minutes ago). Note also that this version bumps the required ProcessWire version to 3.0.62 – the current master/stable version. Technically this release should work in 3.0.16 or 3.0.18 as well (the versions that introduced major changes to the image inputfield), but I don't plan to test this module in anything older than the master branch.1 point
-
1 point
-
This would be the most useful module for me, because I tend to do my sidejobs at the office after work (I know, it's not proper, commuting issues that's why ) and we have a strong Firewall that blocks FTP and CPanel pages, so this will come real handy, am assuming it has a code-editor in it. thanks a bunch.1 point
-
Those attributes are not useless - their use is that they mitigate against reverse tabnapping vulnerabilities for links that have target="_blank". https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/ https://mathiasbynens.github.io/rel-noopener/1 point
-
Hi @Juri Try to play with $config->sessionFingerprint $config->sessionFingerprint = 2;1 point
-
This might be useful to you: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users1 point
-
@FrancisChung - I agree, although I would go with JSON over XML given the choice.1 point
-
Just visited @apeisa's repo and found that I had forked it just over 5 years ago! (And lodged a pull request at the time.) Good job GitHub has a longer memory than me.1 point
-
Create a field "counter" with type "integer" and set it as "hidden, not shown in the editor" or "always collapsed, requiring a click to open", as you prefer. Put this code on your template: $page->counter += 1; $page->of(false); $page->save('counter'); $page->of(true); echo $page->counter; voilá1 point