Leaderboard
Popular Content
Showing content with the highest reputation on 05/02/2016 in all areas
-
Template Latte Replace Latte template engine support for ProcessWire Having wrote about this one for a few times and now here it is. The readme is not complete but should give a solid starting point. Feel free to ask if something's not clear. http://modules.processwire.com/modules/template-latte-replace/ https://github.com/rolandtoth/TemplateLatteReplace3 points
-
@saml: Have a look at the documentation. It's listed as an option and a basic example is available as well.3 points
-
Since I didn't see it mentioned in any changelogs, I just want to give a heads up to the new ability to import field values via JSON files, which @justb3a implemented in top notch quality after my fiddly proof-of-concept patch . I find this to be a major improvement, since it enables so much easier import of data from e.g. Drupal, so just wanted to make you all aware of it. I have outlined in very broad broad terms how I went about transferring data from a Drupal 7 site, to processwire, in this post.3 points
-
I don't know if there is a better way to achieve the same result,I had (for a previous project) to insert : CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: config.protectedSource.push(/<i[^>]*><\/i>/g); config.enterMode = CKEDITOR.ENTER_BR; // I added this because I didn't want a new <p> tag on every new line, <br /> instead. }; CKEDITOR.dtd.$removeEmpty['i'] = false inside site\modules\InputfieldCKEditor\config-body.js (you shoud already have that file there). To be honest I don't know why this is necessary and doesn't work by default, but as far as I know it's not related to processwire, rather by Ckeditor itself.3 points
-
@heldercervantes For images, look at removeAll() for getting rid of everything in the field or just removeVariations() to kill off the size variations.2 points
-
There's no difference in how you would use $session, $input, or any API variable or any PHP superglobal ($_GET, $_POST, etc). These have nothing to do with namespace. If you must disable the template compiler, edit your /site/config.php and add $config->templateCompile = false; to it. That will prevent any of your template files from getting compiled. As for compiling modules: At this time I wouldn't recommend disabling the module compiler, otherwise almost no 3rd party modules will work. That's because there are few if any PW3-specific modules at present. If you come across a module that isn't working after being compiled, let me know about it so I can investigate it. When it comes to template files (and you've disabled the template compiler): you don't need to add a namespace to all of them. You only need to add it to those that are calling ProcessWire specific functions like the wire() function, or those that are referring to ProcessWire constants or classes directly. Things like this: $foo = new PageArray(); $date = wireDate('Ymd'); $page->addStatus(Page::statusUnpublished); The parts in bold above are those that are referring to things in the ProcessWire namespace. Adding "namespace ProcessWire;" to the top of the file makes it simple, that's all you'd have to do. If you didn't want to do that, you could also just update a wire() function call to be like this: $date = \ProcessWire\wireDate('Ymd'); Or you could just enable the template compiler, which will do this for you. However, maybe you aren't using things like the wireDate() or wire() functions and maybe you aren't referring to things like Page::statusUnpublished. If that's the case, you can skip adding a namespace at all, and likewise don't need the compiler. ProcessWire's API variables like $pages and $input and $session and all of that are going to be present either way. These have nothing to do with namespace.2 points
-
Thanks @horst! This'll do just fine. When I get v1.1 finished, I'll open specific forum thread for this and push it to the modules directory.2 points
-
@Roope: sorry for this with the image array(), but you already have found your way to get the informations before resize and how to alter them within imagesizer. If you need the pageimage as your final result, you can store it with your first hook. If I remeber right, you already hook into before pageimage:size, right? Store it then, and after you have your tinified file, create a variation pageimage like this: $tinifiedPageimage = clone $this->previouslyStoredOriginalPageimage; // from your first hook !! $tinifiedPageimage->setFilename($filenameOfTinifiedFile); $tinifiedPageimage->setOriginal($this->previouslyStoredOriginalPageimage); return $tinifiedPageimage;2 points
-
2 points
-
Thanks! Keep in mind that it requires PW 3 because of the namespace. There' no specific reason to make it PW 3 only but currently I have no time to rewrite. Just added two global functions t() and n() to make string translations easier (v0.12).2 points
-
01. Is the name of your field in the actually 'meta_title'? 02. ProcessPageEditTruncate.js should be in '/site/templates/AdminCustomFiles/'!2 points
-
Looks like phil is trying to install it on PW 2.x where namespaces aren't supported. Perhaps add a requirement in getModuleInfo for >= 3.0.10 for all those not looking at the module's description? requires => array('ProcessWire>=3.0.10')2 points
-
I think I may be getting somewhere thanks for Soma's new ClearCacheAdmin module (thanks mate!) Once I installed this, I loaded up the Cache Admin screen and noted there were 2 FormBuilder cache files in place. I don't know if there should only be one but I nuked both of them. My next test form was successfully logged in my PostMark account.2 points
-
I tried almost every command, but haven't noticed any issues with PW3. Maybe some of the heavy users will notice something. Thank you for this awesome CLI.2 points
-
Hello @ all I want to share my code of a module which copies values from a parent page to a child page by using the add button of a pagetable field. If you find it useful you can copy the code or you can improve the code and post your ideas of improvement here. The intention for me was that I have pages with events and I dont want to write all the data for an event manually. Especially if only the date of the event is different. I use a pagetable field for the events and I want to click the add button of this field and a new childpage will be created with all the data of the event (title, description, summary,...) so I have only to fill in the start and end date for the event. So far so good, but it was a little bit tricky to get this to work with the add button of the pagetable field. So I decided to write a module which does the work for me. Here is the piece of code: <?php class CopyPageTableAdd extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Pagetable copy values', 'summary' => 'Copy Pagetable content by pressing the add button', 'href' => '', 'version' => 001, 'autoload' => true, 'singular' => true ); } public function ready() { $this->pages->addHookBefore('ProcessPageAdd::execute', $this, 'copyaddpage'); } public function copyaddpage() { //configuration $parenttemplatename = "events"; //the template name of the parent template $childtemplatename = "single-event"; //the template name of the newly created child template $page = new Page(); $page->parent = $this->input->get->parent_id; if ($page->parent->template == $parenttemplatename) {//check if it is the right parent template $page->template = $childtemplatename; //set the template for the created child page //copy all fields field values from the parent template (start) //enter all fields which you want to copy into the child page $page->title = $page->parent->title; $page->eventstatus = $page->parent->eventstatus; $page->eventtype = $page->parent->eventtype; $page->summary = $page->parent->summary; $page->headline = $page->parent->headline; $page->importanteventstext = $page->parent->importanteventstext; $page->importanteventstext = $page->parent->importanteventstext; $page->notifiable = $page->parent->notifiable; $page->reservationtype = $page->parent->reservationtype; $page->participantlimit = $page->parent->participantlimit; $page->participantmaxnumber = $page->parent->participantmaxnumber; $page->eventmaxstatus = $page->parent->eventmaxstatus; $page->eventcosttype = $page->parent->eventcosttype; $page->eventprice = $page->parent->eventprice; $page->eventpriceadd = $page->parent->eventpriceadd; $page->eventlocationname = $page->parent->eventlocationname; $page->street = $page->parent->street; $page->postalcode = $page->parent->postalcode; $page->eventlocationname = $page->parent->eventlocationname; $page->place = $page->parent->place; $page->region = $page->parent->region; $page->country = $page->parent->country; $page->googlemap = $page->parent->googlemap; //copy all fields field values from the parent template (end) $page->addStatus(Page::statusUnpublished); //this foreach loop is only if you have a multilanguage site to get the path names in each language //if your site is only single language you can use $page->name=$page->parent->name (but not tested) foreach ($this->languages as $lang) { $lname = $lang->id; $pageName = $page->title->getLanguageValue($lang); $page->set("name$lang", $pageName); if ($lang->isDefault()) continue; $page->set("status$lang", 1);//activate the multilanguage checkbox } $page->save(); $this->session->redirect("../edit/?id=$page"); } } } The configuration part: //configuration $parenttemplatename = "events"; //the template name of the parent template $childtemplatename = "single-event"; //the template name of the newly created child template This is the part where you have to define the templates. The name of the parent template is responsible that the module only run on that template (in my case the template with the name "events). The name of the child template ist the template which should be created after pressing the add button (in my case the template with the name "single-event"). You have to fill in your template names. The module runs only if the parent template has the specific name and creates only child pages with the child pages template name. Copy all field values par: //copy all fields field values from the parent template (start) //enter all fields which you want to copy into the child page $page->title = $page->parent->title; $page->eventstatus = $page->parent->eventstatus; $page->eventtype = $page->parent->eventtype; $page->summary = $page->parent->summary; $page->headline = $page->parent->headline; $page->importanteventstext = $page->parent->importanteventstext; $page->importanteventstext = $page->parent->importanteventstext; $page->notifiable = $page->parent->notifiable; $page->reservationtype = $page->parent->reservationtype; $page->participantlimit = $page->parent->participantlimit; $page->participantmaxnumber = $page->parent->participantmaxnumber; $page->eventmaxstatus = $page->parent->eventmaxstatus; $page->eventcosttype = $page->parent->eventcosttype; $page->eventprice = $page->parent->eventprice; $page->eventpriceadd = $page->parent->eventpriceadd; $page->eventlocationname = $page->parent->eventlocationname; $page->street = $page->parent->street; $page->postalcode = $page->parent->postalcode; $page->eventlocationname = $page->parent->eventlocationname; $page->place = $page->parent->place; $page->region = $page->parent->region; $page->country = $page->parent->country; $page->googlemap = $page->parent->googlemap; //copy all fields field values from the parent template (end) This ist the part where you can fill in all fields which you want to copy the values. It copies the values from the parent page to the child page. You can do this also with a foreach loop, but I dont want to copy all field values so I write it manually for each field. The multilanguage part: foreach ($this->languages as $lang) { $lname = $lang->id; $pageName = $page->title->getLanguageValue($lang); $page->set("name$lang", $pageName); if ($lang->isDefault()) continue; $page->set("status$lang", 1);//activate the multilanguage checkbox } The multilanguage part is necessary if you have a multilanguage site, because it creates the path names for each language in the right language. After that the multilanguage checkbox for the non default language should be checked to activate the page in this language. Here are some screenshots: 1) Press the add button of the pagetable field 2) A new child page will be created with prefilled values of the parent page 3) Path names are in the right language and multilanguage checkbox is activated So this might be useful for others Best regards1 point
-
You simply do nothing and it should work exactly like beforehand. That's 90% of the reason the file compiler does exist in the first place. So the question is rather why it doesn't work for you.1 point
-
1 point
-
1 point
-
Hello As I remember I pulled the newest version from GitHub before I tried to install the module. I will check the exact installed version this evening.1 point
-
@horst - I'd need your help bit further with this one... When hooking to ImageSizer::resize is there a way to get the original resized Pageimage object? Your code example below had something like this: public function hookEventBeforeResize($event) { $this->image = $image = $event->object->image; } But $event->object->image is referring to the array that contains information about the image width and height, not the actual Pageimage. Also, as a reference if someone else is using info from this thread, on ImageSizer you can't set quality property directly - it'll throw fatal error (cannot access protected property ImageSizer::$quality). Instead there is a setter method for doing this: public function hookEventBeforeResize($event) { $image = $event->object; $image->setQuality(100); } Why I need Pageimage object from ImageSizer is that it would make returning compressed tiny variation a breeze when you can just clone the source Pageimage: private function tinyPageimage(Pageimage $image) { $tinyimage = null; $filename = $this->tinyFilename($image); // tiny image file exists, let's clone the original Pageimage if(is_file($filename) && filemtime($filename) >= filemtime($image->filename())) { $tinyimage = clone $image; } // tiny image file is not available, proceed if we can compress the source if(!$tinyimage && $this->compressionAllowed()) { // copy the original source and clone it if compression was ok if(copy($image->filename(), $filename)) { if($this->compressImage($filename) !== true) unlink($filename); else $tinyimage = clone $image; } else { throw new WireException("Failed to copy Tiny image variation: $filename"); } } // return tiny variation of Pageimage when available if($tinyimage instanceof Pageimage) { $original = $image->original ? : $image; $tinyimage->setFilename($filename); $tinyimage->setOriginal($original); return $tinyimage; } return $image; }1 point
-
Your markup doesn't seem like proper Markdown formatted. # Image ![Alt description here](http://plauclair.me/site/assets/files/1772/logo_processwire-1.421x0-is-hidpi.png) Also be sure to have the Markdown module installed and assigned/applied to the field.1 point
-
1 point
-
That make sense, but here's another scenario for you. What if the dev sets the maxFiles to 3 and the Which Images to All Available. And it is attached to a textarea field where they can enter multiple videos - what images get kept, and which ones get deleted when additional video links are added? Obviously it would be a silly combination to set up, but you never know. At least the way it is now if you want just one video per page you can use a text field (not textarea) and choose First Available. That way you'll only ever get one image - the only caveat is that you need to do $page->images->first(). If you want the manual upload override you can have a separate field, or you could tell the site editors to simply order the images field so that their manually uploaded one is in first position. Or, the template logic could look for the presence of an image without the "video-" prefix and use that if it exists? I am still not convinced I am right, so I would still like to hear from other users of this module! Thanks for your continued thoughts on this!1 point
-
I think you already solve that scenario with if(strpos($imageVideoName, 'video-') === false) continue; So a manually uploaded image will not be replaced (well, unless the image name by chance included the string 'video-' but that's unlikely). And that makes total sense to me. It wasn't what I expected at first but now I understand the intention behind it I see how it's the best option. And this behaviour could be mentioned on the module config screen or module description to clear up any confusion.1 point
-
do you see any notice / hint in the PW logs? site/assets/logs/errors.txt site/assets/logs/exceptions.txt site/assets/logs/warnings.txt1 point
-
Thanks - yeah, it is certainly doable, but the problem I see is that if the dev sets the max to 1 and doesn't prevent users from manually uploading an image, and this modules works like PW in that a single image is replaced if the max is one, then manually uploaded image will be lost. So it doesn't work for the scenario where you want the user to be able to override the default image from Youtube/Vimeo. I think it's better in that scenario to have a dedicated "manual override" image field - at least that is my current thinking. Is there anyone else there with any thoughts on this? I'd like to get a consensus before I go making anymore changes.1 point
-
Soma This Module just helped me with my Form / PostMark problem https://processwire.com/talk/topic/12322-mandrill-upcoming-changes/page-2#entry1192291 point
-
Hi Adrian, It's totally fine if you think it's best to require the thumbnail field to have maxFiles '0' - as I mentioned above, I can only see myself using the module with a dedicated image field that I will make non-editable to users, so for me the field will only hold a single image even if maxFiles is set to 0. But if you wanted to support fields with maxFiles '1' I found that simply reordering the code in your module (the version before your most recent release) fixed the bug. By placing this section... //Delete any images from videos that were removed from the text fields during this update if($page->{$this->videoImagesField}){ foreach($page->{$this->videoImagesField} as $videoImage){ $imageVideoName = pathinfo($videoImage->filename,PATHINFO_FILENAME); if(strpos($imageVideoName, 'video-') === false) continue; if($this->whichImages != 'firstAvailable') { $imageVideoNameArray = explode('-',$imageVideoName); $imageVideoID = str_replace('video-', '', trim(str_replace(array_pop($imageVideoNameArray), '', $imageVideoName),'-')); } else{ $imageVideoID = str_replace('video-', '', $imageVideoName); } if(!in_array($imageVideoID, $allVideos)){ $page->{$this->videoImagesField}->delete($videoImage); $page->of(false); $page->save($this->videoImagesField); } } } ...above the sections that grab the thumbnails from YouTube/Vimeo any unneeded thumbs are disposed of before the field is repopulated with the new thumbnail. But I didn't do extensive testing so there are perhaps consequences to reordering the code like this.1 point
-
@laban, sorry didn't spot your question earlier. But here's the answer. // DOM is ready $(function () { // field with the name attribute title $("[name='title']").truncate({ characters: 55, prefix: '', suffix: ' character(s)' }); // field with the name attribute an-other-field $("[name='an-other-field']").truncate({ characters: 160, prefix: '', suffix: ' character(s)' }); });1 point
-
@Robin S, Sorry for the delay on this - partly no time, and partly not sure what to do. That bug you noted at the end there is new since I added checks to prevent extra images being added to an image field with MaxFiles not set to '0'. I am actually thinking that the easiest and best solution is to simply require that the image field that is selected for this module has a maxFiles set to '0'. My reasoning is that there are three scenarios where you might end up with more than one image in the field. 1. You allow users to manually upload other images to that field 2. You are using a textarea field where they can enter multiple video links 3. You have chose "All Available" for the thumbnails to be grabbed There are also combinations of the above. I don't see a simple, logical way to make this work without the potential for losing images if I continue to allow a single image field and overwrite existing images. I have gone ahead and made these changes - hopefully it won't impact your (or anyone else's) use cases. Please let me know if you have any problems with this new version.1 point
-
Thanks for your detailed answer! Very impressive stuff. The vangoghroute.nl site is very nice too.1 point
-
Thanks @adrian. I noticed that if the nominated thumbnail field is limited to one image and an image is already loaded there then the image is not replaced with the video thumbnail (but the description is updated to the video title). Is that intentional? I expected the existing image to be replaced. Although I suppose that would create a problem for someone who is wanting to load their own custom video thumbnail in place of the one grabbed from YouTube/Vimeo. Now that I've used the module a bit I've realised that in most cases I would use a different field setup to what I first tried. Initially I thought I would use an existing field on the page - in my project a user can choose a featured image or a featured video, so I thought it made sense that if a video URL was entered the featured image field contained the video thumbnail. That prompted my mention of the maxFiles issue. But now I think I want different field settings for the video thumbnail - I want to set it to non-editable because I don't want editors to try and manually override the video thumbnail or think that they need to load a thumbnail image. So I've decided that it's better to create a dedicated image field for the video thumbnail and then use field visibility settings to show/hide image fields based on if the video URL field is populated. I think I would use this kind of setup in future too so the maxFiles thing isn't an issue for me after all (sorry!). --- Edit: just noticed you already discussed some of this here and the module only replaces an existing image if the image is a video thumbnail grabbed by the module. However there does seem to be a bug. If the video URL field contains a URL and the image field contains a video thumbnail grabbed by the module (i.e. not a manually loaded image), and then the URL is changed to a different video, on page save the image field becomes empty. On a subsequent page save the image field gets the new video thumbnail.1 point
-
I'm in the process of getting wireshell PW3 ready. But I think it could use a bit more testing before I'll finally push it into the master branch. So I started a RC branch just for this purpose. If someone wanted to try and test it – which I would really appreciate: here you go (or: checkout branch feature/devns) !1 point
-
That's a good point. I remember that I changed something like that a long time ago. I found my snippet sql errors - check (mysql 5.6.15): sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" remove STRICT_TRANS_TABLES1 point
-
Have a look if your mysql configuration has strict_trans_tables or strict_all_tables set. This prevents zero dates (since 5.7.4) from working. See http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-changes for details.1 point
-
1 point
-
Thanks again for the port to leaflet! I prefer OSM over google maps and have been using it for quite some time. Leaflet is very powerful and opens up many possibilities. I forked Mats' module and added support for leaflet-providers so we can choose different map tile providers (see my post here). It is still a work in progress but seems stable. Once it is ready for production I'll make a pull request. Mats, do you think we should use leaflet-providers as standard or offer the user a choice whether they want to use it or not? Next up I will add an icon field and support for Leaflet.awesome-markers.1 point
-
This is my version of Ryan's starter: $requested_pid = (int) $input->get->pid; $t = $pages->get($requested_pid)->path; if($user->isLoggedin()){ if($requested_pid == ''){ $session->redirect('/'); } else{ $session->redirect($t); } } if($input->post->username && $input->post->pass) { $username = $sanitizer->username($input->post->username); $pass = $input->post->pass; $u = $users->get($username); if($u->id && $u->tmp_pass && $u->tmp_pass === $pass) { // user logging in with tmp_pass, so change it to be their real pass $u->of(false); $u->pass = $u->tmp_pass; $u->save(); $u->of(true); } $u = $session->login($username, $pass); if($u) { // user is logged in, get rid of tmp_pass $u->of(false); $tmp_pass = $u->tmp_pass; $u->tmp_pass = ''; $u->save(); // now redirect to the profile edit page if($tmp_pass == $pass){ $session->redirect('/profile/'); } else{ $session->redirect($t); } } } // present the login form $headline = $input->post->username ? "Login failed" : "Please login"; $content = " <h2>$headline</h2> <form action='./?pid=".$requested_pid."' method='post'> <p> <label>Username <input type='text' name='username'></label> <label>Password <input type='password' name='pass'></label> </p> <input class='bluebutton' type='submit' name='login' value='Login'> </form><hr /><br /> <p><a href='/reset-pass/'>Forgot Password?</a></p> "; Then wherever you have a link to login: <a href="/logout/?pid='.$page->id.'">Login</a> Of course you can do the same with logout too. Hope that helps1 point
-
Thanks for the FTP access. I found out what the issue was. Your server needed this part of the .htaccess file uncommented: # RewriteBase / Once I uncommented that (by removing the '#') it started working. Please let me know if you run into any more issues.1 point