Leaderboard
Popular Content
Showing content with the highest reputation on 01/31/2023 in all areas
-
Hello everyone! Recently I wrote these scripts for TracyDebugger console in order to make work with RepeaterMatrix easier and faster. I want to present them to the community. Show relationship between all types, names and labels. $repeaterMatrixModule = $modules->get('FieldtypeRepeaterMatrix'); $fieldName = 'content_blocks'; $repeaterMatrixField = $fields->get($fieldName); $typesArray = []; foreach($repeaterMatrixModule->getMatrixTypes() as $matrixName => $matrixType) { $typesArray[$matrixName] = $matrixType . ' ' . $repeaterMatrixModule->getMatrixTypeLabel($matrixType, $repeaterMatrixField); } db($typesArray); Show all pages which have specific type in field (repeater_matrix) with this name: $repeaterMatrixModule = $modules->get('FieldtypeRepeaterMatrix'); $typeName = 'block_text'; $fieldName = 'content_blocks'; $repeaterMatrixField = $fields->get($fieldName); $typeId = $repeaterMatrixModule->getMatrixTypeByName($typeName, $repeaterMatrixField); $typeLabel = $repeaterMatrixModule->getMatrixTypeLabel($typeId, $repeaterMatrixField); $pagesWithType = $pages->find("{$fieldName}.type={$typeName}"); db($pagesWithType); db($typeLabel, 'Name of type'); This list can be continued as soon as I'll invent more scripts.5 points
-
TextformatterRockDown ProcessWire Textformatter for simple mardown-like text formatting ideal for headlines: *bold* _italic_ ~strike~ ```monospace``` #monospace# This module does intentionally not support full markdown syntax! It is intended to be used for simple formattings that you usually want to apply to headlines. Problem The title field is always available in ProcessWire and it is often used for page headlines. But unfortunately when using such a plain textfield it will not be possible to print some words in bold or italic font. One solution is to create a CKEditor/TinyMCE field, but it's a lot more tedious to setup. Also it's not easy to make it single-line-only. Solution Just apply this textformatter to your field and you'll get quick and easy headlines with bold and italic fonts that will also work with frontend editing. Backend Editing: Frontend Editing: Formatted: Custom tags You can add custom replacements easily via hook in /site/ready.php $wire->addHookAfter("TextformatterRockDown::replace", function ($event) { $str = $event->arguments(0); $start = $event->arguments(1); $end = $event->arguments(2); $str = preg_replace("/$start@(.*?)@$end/", "$1<span style=\"color:red;\">$2</span>$3", $str); $event->return = $str; }); Download https://github.com/baumrock/TextformatterRockDown https://processwire.com/modules/textformatter-rock-down/4 points
-
@BrendonKoz, you can use the hook below to target the children() selector used in PageListSelect/PageListSelectMultiple and remove the "status" clause that allows unpublished and hidden pages. Because those inputfields use ProcessPageList the tricky part is only affecting the inputfields and not the main page tree. After some digging I found that you can distinguish these cases by a "labelName" GET variable. $wire->addHookBefore('ProcessPageList::find', function(HookEvent $event) { $selector = $event->arguments(0); $name = $event->wire()->input->get('labelName'); if($name === 'your_page_reference_field_name') { $selector = str_replace(', status<9999999', '', $selector); $event->arguments(0, $selector); } }); Before: After:2 points
-
@nabo Sorry for the trouble. I was able to reproduce the error (installation was working locally but not on my production server). This should now be fixed. Please update the module. For those who have problems with the installation of the module, please make sure that you update to the latest version2 points
-
I typically work with three hosting environments: local, stage (on external server), and live. PW currently supports config-dev.php and config.php. I'd love to see support for an additional config file such as: config-stage.php config-test.php config-review.php config-local.php config-localhost.php or something similar. It would make it much easier to manage three hosting environments, each with their own database.1 point
-
That is mighty impressive. I'm going to look this over more carefully later this evening, but (1)that's awesome, and (2)I was apparently looking in the completely wrong place(s). Ugh. ?♂️ Thank you so much, Robin! This will undoubtedly prove useful now, and in the future. UPDATE: It's 3 days later and I finally had an opportunity to look at this and give it a shot. I'm still lost on how Robin maneuvered through the file structure to identify where to adjust the call - that's some magic there - but I'd just like to clarify one thing: This hook doesn't allow you to target a specific template (PW conditional hooks); nor was I able to find a passed value to access the intended template (I did find a value, but when trying to access it directly, I only got a null value), so unless someone discovers how to target the intended calling page's template, this would be best for overriding only a field that is going to globally be overridden in this manner. Other than being aware of this, it works great!1 point
-
yeah looks very cool @gornycreative Perhaps if you don't mind sharing it, it would be great to have a look! - this is somewhat the original intention of the module, to be able to provide all of those types of settings interfaces like people build for WordPress etc..1 point
-
1 point
-
Thx for sharing. Screenshots would be nice for all that can not transform code into pictures on the fly in their brain (me included) ?1 point
-
Yep. I've added support for custom tags via hook: Custom tags You can add custom replacements easily via hook in /site/ready.php $wire->addHookAfter("TextformatterRockDown::replace", function ($event) { $str = $event->arguments(0); $start = $event->arguments(1); $end = $event->arguments(2); $str = preg_replace("/$start@(.*?)@$end/", "$1<span style=\"color:red;\">$2</span>$3", $str); $event->return = $str; });1 point
-
@Stefanowitsch yeah that's what I often did as well. I just stripped down all the options of CKE to only show the bold button. But that's a lot of work for a very simple and common need. That's why I finally built the formatter ? Yes, it's a simple preg_replace that finds *bold* and replaces it with <strong>bold</strong> $start = "(^| )"; // allowed start $end = "($|\W)"; // allowed ending whitespace $str = preg_replace("/$start\*(.*?)\*$end/", "$1<strong>$2</strong>$3", $str); $str = preg_replace("/$start\_(.*?)_$end/", "$1<em>$2</em>$3", $str); $str = preg_replace("/$start~(.*?)~$end/", "$1<s>$2</s>$3", $str); $str = preg_replace("/$start```(.*?)```$end/", "$1<tt>$2</tt>$3", $str); $str = preg_replace("/$start#(.*?)#$end/", "$1<tt>$2</tt>$3", $str); You can do that with CSS, or am I missing something?1 point
-
It's markdown... so: https://www.markdownguide.org/cheat-sheet/ You could by using: [title](https://www.example.com) Sometimes there was the need for a link... I didn't like it but the client paid for it. This would probably work out as expected. Still I didn't like it in the title field therefore took other fields and tried other approaches.1 point
-
Thx - that's why I found no link and no docs ? The main difference that I see: I can point my clients to the readme of my module and it is instantly clear what it does: https://github.com/baumrock/TextformatterRockWhatsApp Markdown/Parsedown: I don't know exactly what it does and I did not find it with a quick research. Seems to be the same for you (as you where asking)? But I guess they are very similar. Also my module is super simple and does not need any other libraries. Easy to understand. Easy to maintain. It looks as if the core module supports lists and headlines. I don't want that in my markup as it's intended to be used for quick and easy headline styling and not for richtext. Maybe that's the main difference ? Thx for the question, didn't know about that core module!1 point
-
1 point
-
Now it works!!!! Thanks, now I can start play a bit ?1 point
-
Can't you use the "Extra Allowed Content" line in the field's settings?1 point
-
Now solved. For the benefit of others, you need to set the sort property of the repeater rather than use a custom property. i.e. for each repeater page: $subPage->sort = $j; // where $j is the required sort index $subPage->save(); then after all 'subPages' have been set: $page->$repeaterName->sort('sort'); and save the page.1 point
-
To me, saving database credentials to a Git repository, even if that repo is private, is a big no-no. So I've been tinkering with different ways to deploy sites to production environments without saving the database credentials to the repo. I know that there is a the config-dev.php option. But that hasn't worked for me, as I will explain later. I added this to my config.php: $config->env = "dev"; if($config->env == "dev") { $config->dbHost = 'localhost'; $config->dbName = 'processwire'; $config->dbUser = 'root'; $config->dbPass = 'root'; $config->dbPort = '3306'; } else { require("./{$config->env}.config.php"); } So if $config->env = "production", production.config.php should be loaded: $config->dbHost = 'localhost'; $config->dbName = 'processwire-production'; $config->dbUser = 'username'; $config->dbPass = 'productionPassWord'; $config->dbPort = '3306'; I can't see anything wrong with the syntax of this at all - but for some reason, if that file is added with require() or require_once(), ProcessWire never loads. If it's loaded with include(), I get an error about the page not being found, and there being no install.php present. So it seems like for some reason, there is no way to include a file in config.php, which confuses me immensely. How my brain works I'll try to explain my thought process behind this a little more. I think it's a good idea for dev environments (especially those that come with a Vagrant box and a defined database already installed) to include dev-level database creds. It should just work. If someone works on this site after me, they shouldn't have to spend a ton of time getting a config file set up. Secondly, having a config.php file and a config-dev.php file frustrates me because for the developer that comes after me, they could really use the config-dev file! But if it's in the repo, it gets deployed. If it gets deployed, it gets called on the staging/production server, and that is no good! Also, config.php and config-dev.php would in most cases pretty much completely mirror one another with the exception of database creds, and maybe debug or a few other things. That is why I want to have all the configs in the repo within config.php except for the tiny bits that are environment-specific. They should be able to be included, right?1 point
-
Too simple to be a module, consider a script like this: $array = $pages->find("template=basic-page")->explode(function($item){ return array( 'id'=> $item->id, 'title' => $item->title ); }); $fp = fopen('file.csv', 'w'); foreach ($array as $fields) fputcsv($fp, $fields); fclose($fp); Note, $pagearray->explode() used here is only available in 2.4 (2.3 dev) http://cheatsheet.processwire.com/pagearray-wirearray/getting-items/a-explode/ And the anonymous functions requires php >= 5.3 http://php.net/manual/de/functions.anonymous.php1 point
-
First off, I won't stop developing ProcessWire unless I'm dead. But lets say that one of you showed up at my door and shot me, and then I'm gone for good. This is free software and you don't get any guarantees there, no matter what CMS it is or how big the community or adoption of it is. But what you do get is the source code and permission to use it and do with it what you need to. There is far more security in that than any proprietary or commercial system. We should all feel very lucky that this project has attracted such a capable development community around it (more than any project I've ever seen), and there are several guys here that are fully capable of taking over the project if I go down in a hang-glider crash. I'm always reluctant to list off people because there are so many people that contribute to the core and I don't want to forget anyone. Suffice to say, I may hold the keys to the master GitHub account, but this is a project of many developers, at least 5 of which are fully capable of taking over the project if I kick the bucket. I'm certain that some of these guys could do better than me with it. Please don't take that as an invitation to show up at my door with a weapon. But I would suggest this may be better odds than with the bigger projects you'd mentioned. Lets also point out here that ProcessWire is not WordPress–it does not need daily updating in order to keep running. Most sites I build with ProcessWire are running the version they are launched with. With ProcessWire, you do not need to upgrade your site every time a new version comes out. You can generally upload it and forget it, and it'll keep running till the site as long as the server itself is running. What other CMS can you say that for? (I can't think of any) Personally, I think adoption of something like Drupal, Typo3, Joomla, etc. is more of a risk, because you are dealing with a legacy platform – you are adopting technology from 10 years ago. You are also adopting something that is a target for hackers and spammers. WordPress is perhaps the biggest target, and something I've very apprehensive to setup for clients. Ultimately when a company chooses to adopt a legacy platform because "it's what the clients know" or [more likely] what they themselves know, it's a lazy decision. It's not looking out for the clients' best interests, and it's pursuing mediocrity. When you pursue mediocrity, you pay for it in the long run. There is no better testament to that than the legacy platforms that agency seems attached to. 1-3 years after installing [Drupal/Joomla/Typo3/WordPress/etc.] for the client, they are going to be looking for "something different" in terms of the CMS (we all know this) and they won't be coming back to the same agency. The agency that thinks it's playing it safe is really just hurting themselves when they give their clients something tired and mediocre that anyone can give them. Instead, give them ProcessWire, and they'll know you are different and better (a secret their competition does not have), and they'll be a lifetime client.1 point