Leaderboard
Popular Content
Showing content with the highest reputation on 04/12/2016 in all areas
-
6 points
-
Ok, another one for @netcarver // enable unchecking radio buttons // http://stackoverflow.com/questions/6191621/jquery-check-uncheck-radio-button-onclick#answer-13575528 $page->addHookAfter('render', function ($event) { if ($this->page->template != 'admin') return; $js = <<< HTML <script> $(document).ready(function(){ $("input:radio:checked").data("chk",true); $("input:radio").click(function(){ $("input[name='"+$(this).attr("name")+"']:radio").not(this).removeData("chk"); $(this).data("chk",!$(this).data("chk")); $(this).prop("checked",$(this).data("chk")); }); }); </script> HTML;4 points
-
4 points
-
http://cheatsheet.processwire.com/fields/field-methods/field-getfieldgroups/ This will give you all fieldgroups (aka templates) you need to remove the field from before deleting it.4 points
-
That would require an in-memory sort. One way to do it (as we wait for @LostKobrakai's better answer ).... Create and populate a property 'distance' on the fly for each page in the PageArray then sort the array by that property. An example: // get a PageArray $res = $pages->find('template=basic-page, limit=15'); // assign distances to a property 'distance' created on the fly foreach ($res as $r) { $r->distance = rand(5, 100);// we assign some random distance just for testing } // testing output $out = ''; // sort #$res->sort('distance');// sort ascending $res->sort('-distance');// sort descending // confirm sorting worked $out .= '<ol>'; foreach ($res as $r) { $out .= '<li>' . $r->title . ': distance - ' . $r->distance . ' Miles</li>'; } $out .= '</ol>'; // it works! echo $out; You should get results similar to this: X-Small: distance - 84 Miles XX-Large: distance - 84 Miles Small: distance - 77 Miles US Open: distance - 75 Miles About Us: distance - 74 Miles Our Achievements: distance - 69 Miles Key Staff: distance - 65 Miles Who We Are: distance - 57 Miles X-Large: distance - 57 Miles Senior Management: distance - 51 Miles Medium: distance - 41 Miles Sizes: distance - 39 Miles Colours: distance - 25 Miles Large: distance - 10 Miles What We Do: distance - 9 Miles Useful reading: PageArray3 points
-
@thetuningspoon - thanks for reply... holy smokes, figured it out, and soma's post was staring at me the whole time... you need to add hook properties for this type of inputfield... so adding the below to the init() $this->addHookProperty("InputfieldText::selectizeThis", $this, "addProperty"); $this->addHookProperty("InputfieldText::userStringsList", $this, "addProperty"); and adding this method to the module: public function addProperty(HookEvent $event) { $event->return = 0; } makes it work... so for future reference...this is how to add custom attributes/settings to a text field... https://processwire.com/talk/topic/9462-adding-a-configuration-setting-to-an-existing-module-with-a-hook/?p=911493 points
-
3 points
-
Hi kathep! You just need to store the images in a variable just like $content is. So, change the loop: if (count($page->images)) { $images = ''; foreach($page->images as $image) { $image = $image->size(800); $images .= "<img src='{$image->url}' /><br />"; } } ... rest of code // Primary content goes here $content = $assignment_w_heading . $semester . $images . $page->body; You can remove the <br /> after each image if you prefer.3 points
-
For most modules, I would agree with you, but this one potentially has 8 custom permissions. I think most users will probably only want the "tab-settings-view" or "tab-settings-hide" permission. I'd rather not pollute the permissions list with 7 additional unnecessary permissions if you are planning on only using one. Do you see my point?3 points
-
3 points
-
3 points
-
Function Following tpr's request here, this module allows Radio Buttons in the admin interface to be deselected. Links Github Module Repository (once moderation has taken place) Version History 1.0.1 Merged tpr's mods 1.0.0 Initial Release2 points
-
If you need partial matching you'd need to use the %= operator. It's using mysql's LIKE to get matches.2 points
-
One could possibly build that around the core export/import functionality. It's already working with json data.2 points
-
hi john, that would be absolutely awesome! it would open up a lot of possibilities and could solve an often discussed problem with pw of having different live/production states of a site. see for example this post (and above example of lostkobrakai's update script): https://processwire.com/talk/topic/12383-developmentstaging-of-processwire-site/?p=115027 if we could outsource the config of all the templates and fields to files and then synch them to github or even update a site like this via github commits that would be great!!2 points
-
Maybe the "new" permission suggestion screen, which ryan implemented for the various optional core permissions, could also hold optional module permissions.2 points
-
PageimageSizerImagick isn't compatible with PW greater than 2.5.11 ! It doesn't support the then (2.5.11) introduced naming scheme for image variations in PW. It was more like a case study. But maybe you can switch to PW 3 devns, there you will find support for Imagick PHP-Extension, ImageMagick-CLI and NETPBM-CLI supported. If you can do, you need to read upon how to "convert" CroppableImage to work with PW 3. KentBrockman and noodles have posted this into its support thread: https://processwire.com/talk/topic/8709-croppableimage/page-7#entry1139412 points
-
2 points
-
Hi all, after moving a new 2.5 install to a different server, I always get this error message in the backend: Unrecognized HTTP host: 'subdomain.mydomain.tld' - Please update your $config->httpHosts setting in /site/config.php The entry in config.php contained the new domain when I installed. Then I set the entry to an empty array. $config->httpHosts = array(''); But the error still displays in the backend. How can I get rid of it?1 point
-
@AndZyk: that's a good point. I don't enjoy working with template engines and thus I don't do it unless I really have to, but in the past I've had a few cases where I really did have to. The biggest mistake I did back then was that I tried to add too much logic on the front-end side. Sure, that's almost always a bad idea, but with Twig (and any other language designed for building simple templates) the repercussions are tenfold. The lesson here is to never, ever add complex (business) logic to your Twig templates. Twig is not intended for complex stuff and even if it can be done – it has macros, is easy to extend with custom features, and supports both includes and template inheritance out of the box – the end result is almost always really ugly and way more confusing than it would be if it was written in plain PHP. In theory this is easy, but then there are the border cases. For an example, imagine that you've got a bunch of raw data you need to format and output; do you iterate over the whole dataset in PHP and handle the formatting part there before sending it to Twig, or do you just send it to Twig and handle formatting and output in one go? If you decide to use Twig for both steps, chances are that you're in for one heck of a rough ride. If Twig helps you keep your templates clean, by all means go for it, but in my opinion you will need another layer for handling the business logic, data formatting operations, etc. Twig is a good companion to a larger architectural pattern (such as MVC), but on it's own it's a major pain in the a*s.1 point
-
Looks like $foo->set('name$lang', wire('sanitizer')->pageName($value)); does the trick.1 point
-
Just my opinion, but I wouldn't recommend Twig. I realized three projects with it and first it is all fun, how simple the syntax is for outputting something. But every time I wanted to build something a little more complex (for example a contact form or search function), I first had to learn how to build it in PHP and after that try to recreate it in Twig. I always had the impression, that the api of twig is somehow limited, but maybe I haven't looked close enough at the documentation.1 point
-
I think you're missunderstanding fieldgroups. Fieldgroups hold the fields for templates. Each template does have it's own fieldgroup. You just need to remove your field from the fieldgroup. Do not delete the whole fieldgroup or the template of it won't have fields anymore.1 point
-
You can sort by runtime fields as well. You'd just need to make sure to populate it before sorting.1 point
-
Hi Guys, I think I finally solved this Or at least, I solved it for my case. The problem I had with this was that I used a form which submitted the page to a "www." variant of the page while all other standard pages where rendered without the "www.". By changing this in the config.php file I was able to keep all session variables and cookies (which previously also got dropped) $config->httpHosts = array( 'processwire.com', // our primary hostname 'www.processwire.com', // alternate hostname 'dev.processwire.com', // staging server 'localhost:8888' // MAMP local dev server ); I changed the one first to a www. variant, and the second one to a non-www. variant. in /site/config.php I hope this helps someone in the future! Bram1 point
-
I took a conservative approach and added some stylesheet onload bookkeeping. I'm optimistic this will fix the flash of unstyled content once and for all.1 point
-
Thanks to Ryan the language fields on MarkupCookieconsents option work with this patch for devns. So either apply yourself (like I did) or wait for the next release, probably coming on friday. https://github.com/ryancramerdesign/ProcessWire/commit/2fe134b7b059fff023f0f37c7f172a9853c88af2 You only need to update ProcessModule.module from the linked GitHub page, the other fix is as mentioned in the title not needed for the language fields to work.1 point
-
@pwired: How about using wireRenderFile() so just you specify which template partial you need, effectively using them (and their Page counterpart if needed) as "blocks". If it is just something that displays data coming from other Pages (say last five blog posts), we do not even need its own page, it is just a lonely "block/widget", but we might need to configure it somehow, so some sort of storage might still be needed. Since there are no rules for the frontend, it depends on our creativity to setup our own "blocks system".1 point
-
While developing I love to have it all in front of my nose. Can do that, on the other-hand it shouldn't be that hard to replace </body></html> with Tracies markup plus </body></html> I guess.1 point
-
Hi Adrian, When tracy is injected to the page, it breaks the W3c validator. It's not a real big deal but never-the-less: Are you willing to make Tracy compatible with the W3c validator .1 point
-
If you're talking about the frontend I can suggest talking a look at this: http://adamwathan.me/2016/04/06/cleaning-up-form-input-with-transpose/ In the backend you'll probably use repeaters or pagetables (FieldtypeMultiplier would work, too, for a single repeatable field).1 point
-
I use PHP5.5 on my local dev environment, but 7.0 on production. It's a small sacrifice for the convenience of using step-by-step debugger instead of echo and var_dump(). It sucks that PW doesn't work well, but until it gets fixed, I'll have to settle for v5.5.1 point
-
I had this problem today and solved it. In my case I had multiple pages with children, and want to show parent pages titles as group labels, and their child pages as group options. // $f = $this->modules->get('InputfieldSelect'); /* here we have some array of pages and foreach loops */ /* inside inner foreach fill $group_options array */ $f->addOption( $group_label, // $parentpage->title (I had troubles here, use var_dump to check that value!) $group_options, // $group_options[$childpage->id] = $childpage->title $opt_attr // array for option attributes ); If this is confused, here is part from some my custom field module where parent pages use "blank" template: $f = $this->modules->get('InputfieldSelect'); $opts = wire('pages')->get(1078)->children(); foreach($opts as $opt){ if($opt->template->name == 'blank' && $opt->numChildren()){ $group_options = array(); foreach($opt->children as $option){ $group_options[$option->id] = $option->title; // <= main part to get group options } $group_label = $opt->title . ''; $f->addOption($group_label, $group_options, array()); } } $f->attr('name', $name . '_widget[]'); $f->attr('value', $widget); Regards.1 point
-
Thank you, Sérgio! I installed and tooled around with ProcessMigrator, and I don't think it does what I had in mind. To clarify, I was wondering if there was a way—whether natively, or by module—to save the template and field settings to a text file (JSON would be perfect) somewhere in the /site directory. ProcessWire would then use that config file instead of the Templates and Fields panels. So instead of configuring Templates and Fields in ProcessWire's UI, these settings would be entirely configured in a text file, that could be kept with the template PHP files in version control. Does that make sense? Based on my quick look at ProcessMigrator, it lets you save your Templates and Fields settings (and a lot more) to the file system, but it doesn't read that data back into ProcessWire unless you trigger an Import using the Migrator panel. Is that right?1 point
-
Problem originates from the use of __debugInfo() magic method that comes with v5.6. Try using PHP 5.5. Processwire + xDebug doesn't play well with PHP >= v5.6.1 point
-
Adrian's Migrator does that => https://github.com/adrianbj/ProcessMigrator Allows automated migration and sharing of page tree content along with their templates and fields via JSON files. These JSON files can be imported into another PW installation to recreate the entire structure and content, including files and images.1 point
-
Version 1.1.2 is released: http://mods.pw/BC - Updated packaged php-mf2 library to version 0.3.0 - Added config option to automatically monitor a page for approved vouch domains (see below). - Better authorship algorithm support. One of the bottlenecks for the Vouch protocol is "how do you easily manage the list of domains you will accept a vouch from?" In the 1.1.0 release, it was just a text field that you had to manually enter each domain into. As of version 1.1.1, there is a new config field “Vouch whitelist URL.” You can enter the URL of your blogroll or other whitelist. It will be monitored once a day and new domains will be added to the list of approved vouch domains. Links must use the h-card microformat. No domains will be removed from the approved vouch domains. This should help automate the approved vouch domains list. I'm trying this out on my own site currently: http://gregorlove.com/following/ If you're using this plugin, I'd love to hear from you! Feel free to send webmentions to this post: http://gregorlove.com/2016/02/quite-pleased-to-officially-release/1 point
-
Yes exactly the problem... my previews version of php 5.3 and now with 5.5 all work fine. Thank you1 point
-
#1: Only Superusers can see the modules (listing) page #2: No (but I think you are referring to this? It (can auto-check but not auto-upgrade) - ProcessWire Upgrade1 point
-
@Loges, Thanks for purchasing Media Manager and giving me your feedback. I'll address each point you raise in a later post. Oh, and welcome to the forums1 point
-
Removing the session_start() from the AutoFbPost.module at the beginning solves this problem1 point
-
Composer is a package manager. If the package is a framework, a library or just a code snippet is not really relevant so much. And here you go about what things to use/do with composer. My goto libraries: Carbon, Nette/Forms, kahlan, faker, any of those when needed; As soon as I've more time to put into CI I'll certainly look into using phpdotenv. Probably every third party service integration like Mail / Calender / Paying Gateway should be managed by composer. Any finally if you ever need to use non-php software on your server like redis or elastic-search or others you can find php libraries to use those as well.1 point
-
Database migrations are "better" supported in other frameworks because they wouldn't function without them. A laravel framework doesn't have any databases beside those setup by migrations. But these are actually really bare bone in that they mostly update schema changes. For migrating db rows most use database seeding libraries, which then create the necessary models to be stored. Both can be done with the processwire api without actually needing to learn something new. This is basically what model factories do in frameworks (besides the autofill functionality). $pages->add('basic-page', $pages->get("/url/"), 'profile', array( "someField" => "value", "anotherField" => 202 ); And this may be what migrations do. // Create field $f = new Field(); $f->name = 'text'; $f->type = 'FieldtypeTextarea'; … $f->save(); // Add to template $bpt = $templates->get('basic-page'); $bpt->fields->add($f); $bpt->fields->save();1 point
-
I've just found gogs. It's self-hosted like gitlab, but it's written in go and the speed is just impressive. I've it running on the smallest DigitalOcean instance and it's still damn snappy, what I've never had with gitlab.1 point
-
What I just thought about is: What if you add the property to the Inputfield using a hook. And it works you can do $this->addHookProperty("InputfieldText::overwrite", $this, "addProperty"); Then public function addProperty(HookEvent $event) { $event->return = 0; } Then this works $this->addHookAfter("InputfieldText::getConfigInputfields", $this, "hookConfig"); public function hookConfig(HookEvent $event){ $fields = $event->return; $field = $event->object; $modules = wire("modules"); $f = $modules->InputfieldCheckbox; $f->attr("name", "overwrite"); $f->attr("checked", $field->overwrite ? "checked" : ""); $fields->add($f); }1 point
-
Thanks for your feedback! Horst, I can totally understand your anger about the Google mobile optimization thing. While in the long run their recommendation might be a good idea, this is definitely not helpful at all for at lot of projects at the moment. And especially not, while the picture element isn't something we can rely. However I don't really see how this relates to PHP static code analysis. It's one thing when a quasi-monopolist transnational company tries to force conventions on how you should write markup, but it's another whether users of a piece of software can freely choose whether they want to use a tool or not. I don't think that anybody would doubt that the right tools have a big influence on how efficient you can work on something, and the right tools are normally the ones you already feel comfortable with. For any piece of software, this means that it's an advantage to allow the usage of as many tools as possible. For sure this should never stand in the way of making an API concise and well consumable for humans. But in my opinion it's worth to consider both. For example when I work on projects based on Symfony or CakePHP (yep, introducing a slippery slope argument here, since both projects have a fundamentally different scope than Processwire) in my IDE, I can always click on a method call and the file where it is defined is opened. I get autocompletion for classes, methods and variables and I can read the documentation of all of them by merely hovering an occurence. In addition, obvious errors (like reading a variable that has never been declared, calling a non-existing function etc.) are shown with a curly red line under it. All of this (and a lot more) is pretty helpful to me. I have been working on PHP projects for years without any IDE or debugger, was absolutely satisfied with my technique and thoroughly opposed to the idea of using a heavyweight IDE. Then I discovered PhpStorm, gave it a try and it easily multiplied my work outcome and my grasp of the architecture of frameworks and libraries I used. However, with Processwire – that I love in nearly every other aspect – I have to eschew some of the benefits I was used to. I don't think that everybody should work like I do, to the contrary: everybody should choose his/her own tools by preference. But the current situation excludes some tools that rely on static analysis in the first place. Well, all I wrote is also slightly offtopic, because there's not really a possibility to reconcile all of this requirements for humans and robots. The only method I can imagine to fulfill all criteria while keeping the great flexibility would be dynamic code generation. And this is in itself creepy enough that I would dare to propose it. In the future the already mentioned runkit extension might be of some help, not for static analysis but for debugging. Otherwise I learned a lot about why the current implementation was chosen in this thread and can now much more appreciate its benefits. The questions I'm still eager to discuss, though, are how to improve the granularity and the documentation of hooks. @interrobang: Thanks for pointing out what can be achieved with PhpDoc comments! This is just great and I'm already using all of this and have TemplateStubs installed as the first step in every new PW instance. Works like a charm but because of the dynamic nature of the software, there are still a lot of uncovered areas, especially when working on modules.1 point
-
Hello folks, I was working on different projects and needed to have a better way to organize my code and a workflow. And I came across this methodology https://about.gitlab.com/2014/09/29/gitlab-flow/ Here's a video explaining the workflow Hope it helps1 point
-
Well, soma alone is a "feature" that most software projects can only dream of.1 point
-
Hi there! first of all, this is a great module Nevertheless, i was missing one little thing, and that was the possibility to style your map with a style from snazzy maps. So i tried to get it in there... I don't know if that's the right way, but it works: in MarkupGoogleMap.module: $MapStyle = $options['mapStyle']; // adding a field 'mapStyle'... $id = $options['id']; $out = ''; if($n === 1) $out .= "<script type='text/javascript' src='{$this->config->urls->MarkupGoogleMap}MarkupGoogleMap.js'></script>"; $out .= "<div id='$id' class='$options[class]'$style></div>"; $out .= "<script type='text/javascript'>" . "if(typeof google === 'undefined' || typeof google.maps === 'undefined') { " . "alert('MarkupGoogleMap Error: Please add the maps.googleapis.com script in your document head.'); " . "} else { " . "var $id = new MarkupGoogleMap(); " . "$id.setOption('zoom', $zoom); " . "$id.setOption('styles', $MapStyle); " . // and outputting it here to the js. "$id.setOption('mapTypeId', google.maps.MapTypeId.$type); " . ($options['icon'] ? "$id.setIcon('$options[icon]'); " : "") . ($options['useHoverBox'] ? "$id.setHoverBox('" . str_replace("'", '"', $options['hoverBoxMarkup']) . "');" : "") . "$id.init('$id', $lat, $lng); "; As i said, it works, but i'm not too sure if it's right. Also, i'd like to add the option to the admin panel, but i'm not too sure how...1 point
-
Btw, for anyone else trying to install Pear/PHPUnit on the latest MAMP (and possibly other recent versions), Nik's install instructions don't seem to work, at least they didn't for me. I think it's because MAMP has it's own [already installed] copy of Pear separate from OS X's copy. The very last entry on this page at Stack Exchange worked for me. It's the one answered Oct 9 '12 by Allen Hurff. Failed asserting that actual size "two words" matches expected size "one word".1 point