-
Posts
5,039 -
Joined
-
Days Won
340
Everything posted by Robin S
-
Headings Case A plugin for CKEditor fields in ProcessWire CMS/CMF. Adds a toolbar button for changing the case of all headings or selected headings between sentence case and title case. This is useful when you are copy/pasting text from a document that has been supplied with an inconsistent or incorrect system of capitalisation. Installation The plugin folder must be named "headingscase" – if needed, rename the folder to remove the "-master" suffix added by GitHub. Copy the "headingscase" folder to /site/modules/InputfieldCKEditor/plugins/ In the field settings for each CKEditor field that you want to activate the plugin for: Check the "headingscase" checkbox at Input > Plugins > Extra Plugins Add "HeadingsCase" at Input > CKEditor Settings > CKEditor Toolbar Usage To change the case of all headings, click the toolbar button with no text selected in CKEditor. The first click applies sentence case; the second click applies title case. To change the case of a single heading, select all or part of the heading in CKEditor before clicking the toolbar button. There can be situations where the results need manual correction: proper names, acronyms, etc. Exceptions for small words Certain short English prepositions and conjunctions (three letters or less) are excluded from capitalisation when title case is applied. Edit the exceptions array in the plugin source code if you want to customise this list of exceptions. https://github.com/Toutouwai/headingscase
-
Great, pull request made.
-
In general, you should do this by putting your HTML structure into your template files. Only content should come from your fields. So this... ...should be in your template file, not in a textarea field. Once you've got the hang of "normal" template files you can explore field template files too - these are more of an optional extra than a must have.
-
Not tested thoroughly, but this should work, in /site/config.php: $config->paths->files = $config->paths->assets . 'example/'; $config->urls->files = $config->urls->assets . 'example/';
-
Module Profile Export module (also upgrade PW 2.0 to 2.1)
Robin S replied to ryan's topic in Modules/Plugins
@ryan, could you please add an option to include setlocale() in the exported config.php if it is defined. Now that PW is giving warnings if setlocale() is missing it would be nice not to have to remember to manually add this each time a profile is installed. -
SmartyPants Typographer incorrect curly quote
Robin S replied to alexcapes's topic in General Support
I can't reproduce that. Maybe you have some odd unicode character in your text that is confusing SmartyPants? Or an unclosed open quote before the sentence in question?- 4 replies
-
- 1
-
-
- smartypants
- module
-
(and 1 more)
Tagged with:
-
No ideas about the cause of this issue sorry. This may not be as bad as it sounds. Export/import fields via core feature Export/import templates via core feature Export/import modules and module settings via Module Toolkit Copy PHP files: templates, config, ready, etc Here's where it gets a bit experimental: Export/import pages via new core feature. @horst has had some success with it.
-
Welcome @nasenfloete Maybe you can post the API code you are using the add the repeater items so others can see if they can reproduce the problem. I don't see why the role or permissions of the user should have any influence on adding repeater items to the user page via the API.
-
That's because "Manual drag-n-drop" is the default sort setting, i.e. choosing it is the same thing as leaving the setting empty. Manual drag-n-drop means the "Move" option in the page list actions: Whether this solves the order of your menu is another story though. You'd need to post the code you are using to generate your menu before people can help with that.
- 1 reply
-
- 1
-
-
How to change the published date format in find lister
Robin S replied to Mirza's topic in General Support
Currently you cannot. There is a @todo note in the code: // @todo make this format customizable via wireDate() https://github.com/processwire/processwire/blob/57b297fd1d828961b20ef29782012f75957d6886/wire/modules/Process/ProcessPageLister/ProcessPageLister.module#L1264-L1267 Edit: you cannot set the date format individually for the 'created', 'modified' and 'published' columns, but if you don't mind using the same format for all you can use this hook in /site/ready.php: $wire->addHookBefore('ProcessPageLister::execute', function(HookEvent $event) { $lister = $event->object; $lister->nativeDateFormat = 'Y-m-d'; // see https://processwire.com/api/ref/datetime/date/ for format options });- 3 replies
-
- 3
-
-
- published date column
- lister
-
(and 2 more)
Tagged with:
-
Getting categories that have entries with Page Reference field
Robin S replied to mciccone's topic in General Support
What @Alxndre' is suggesting is something like the below... First you get your category pages, then you loop over the categories, for each category finding pages that have that category selected in the Page Reference field. If there are some matching pages, output the category heading and the list of posts. $categories = $pages->find("template=category"); foreach($categories as $category) { $posts = $pages->find("template=article-post, category=$category"); if(count($posts)) { echo "<h3>$category->title</h3>"; foreach($posts as $post) { // whatever markup you want for the post echo "<p>$post->title</p>"; } } } This is fine for a lot of circumstances, but note that you do a database query to get the categories and then for each category you do a database query. If you have a lot of categories this would mean a lot of database queries. There is another approach that is more efficient: get all the posts sorted by category (as you are already), then for each post check if the category is different from the previous post's category. If it is different then output a heading. $posts = $pages->find("template=article-post, sort=category"); $category_title = ''; foreach($posts as $post) { if($post->category->title !== $category_title) { $category_title = $post->category->title; echo "<h3>$category_title</h3>"; } // whatever markup you want for the post echo "<p>$post->title</p>"; } -
I don't think these classes are related to anything you may or may not have defined in mystyles.js. The mystyles.js file is for populating the Styles dropdown in the CKEditor toolbar. The classes defined in the Page Edit Image module config relate only to the three alignment buttons in the module modal:
-
@szabesz, I think this is covered by $input->url() and $input->httpUrl() now, which were introduced since I wrote my post above. There's a blog post about it somewhere but I can't find it at the moment.
-
The class names are defined in the config for the Page Edit Image module (ProcessPageEditImageSelect).
-
Turns out it's not difficult to do this using the core ImageSizer. Here's a function showing the basics - could be turned into a module, enhanced with some error checking, etc. /** * Resize Pageimage using custom name/path * * @param Pageimage $pageimage * @param int $width * @param int $height * @param array $options * * @return string * */ function resizeImage($pageimage, $width = 0, $height = 0, $options = array()) { $filename = $pageimage->filename(); $basename = $pageimage->basename(); $path = rtrim($filename, $basename); $dirname = $width . 'x' . $height; $variation_name = $path . $dirname . '/' . $basename; $variation_url = rtrim($pageimage->url(), $basename) . $dirname . '/' . $basename; $force_new = isset($options['forceNew']) ? $options['forceNew'] : false; if(!file_exists($variation_name) || $force_new) { wire('files')->mkdir($path . $dirname . '/'); copy($filename, $variation_name); $sizer = new ImageSizer($variation_name); $sizer->setOptions($options); $sizer->resize($width, $height); wire('files')->chmod($variation_name); } return $variation_url; } // example $image = $page->images->first(); $src = resizeImage($image, 500, 300); echo "<img src='$src'>";
-
The built-in image sizing methods are convenient but they're not the only way to resize an image. You could use a third-party PHP library such as WideImage and save your images with any naming or directory structure you need.
-
Third normal form with processwire: How to reference data?
Robin S replied to HarryPhone's topic in Getting Started
A Page Reference field will work great for your "Homepage Listung" field. It's no problem to set a Page Reference field using data from a CSV import. You don't say how you are importing the CSV data, but let's say you are using the ImportPagesCSV module. The module readme says... Probably the easiest way in your case is to use the title of the page. So a basic outline of what's involved... The template for the pages in your Page Reference field should contain the "Title" field and a "Label" text field. Create the pages for the Page Reference field - one for each option that might occur in your CSV data. For the page Title use the value that appears in the CSV data. For the page Label use the label that belongs to that value. Example... Title: "NE2", Label: "n. Endkundenrelevant" Create the Page Reference field and add it to the template used for the pages you will be importing. Specify the pages you just created as the "Selectable pages". For the "Label field" setting, choose "label". Import your CSV data using the ImportPagesCSV module. Done. -
Hi @Martijn Geerts, Thanks for this module. I'm wanting to explore using it with a custom module that extends ProcessPageLister but the way the module checks if the page ID supplied to the url() method has the correct process is a stumbling block. In the module there is this test... if (strpos('ProcessPageListerPro', $listerPage->process) !== false) return $listerPage; ...which seems like a weird way to check that the process is okay. For instance, a process named 'age' would pass this test. And any process that has a different name yet may still be an instance of ProcessPageLister fails the test. How about a different test? $process_module = $this->modules->get($listerPage->process); if($process_module instanceof ProcessPageLister) return $listerPage;
-
Third normal form with processwire: How to reference data?
Robin S replied to HarryPhone's topic in Getting Started
I'm having a bit of trouble understanding, but you can automate pretty much anything in PW - nothing has be done manually. Suppose you go with a Page Reference field for your options (which is usually the most flexible approach) - you can create new options (i.e. pages) on-the-fly as you import your data if you need to. But from what you say in the first post, it sounds like you already know the the options ahead of time and that is how you are able to set up the Table field with those options on the Home page. Instead of the Table field, create one page per option under some special branch of the page tree that is dedicated to that purpose. Set up a "Homepage Listung" Page Reference field that uses those pages as options. When you import the data you don't have to know the ID of the option (page) - you can find the option by title (e.g. "Bestätigt") or value (e.g. "JA1") and then set that option (page) for the "Homepage Listung" field. -
Splitting PageArray into two new arrays (with half the items each)
Robin S replied to SamC's topic in General Support
$index is the key of the array item, which in the case of a PageArray like this is the zero-based index of the item in the array. So it starts at 0 and goes up with each subsequent item. The "</div><div class='col-6'>" portion is where we end the first column and start the second column. There was an error in my code which I have corrected now - we only want this inserted once, when $index matches half the number of items in $testimonials rounded up to the nearest whole number. -
Third normal form with processwire: How to reference data?
Robin S replied to HarryPhone's topic in Getting Started
Hi @HarryPhone, If I understand right, what you are doing looks more complicated than it needs to be. If you just need values/titles in a select inputfield and your site editors don't need to edit these options then you can define the values/titles in an Options field: https://processwire.com/api/modules/select-options-fieldtype/#separate-option-values If your site editors do need to edit or add new options then you can use a Page Reference field. In the template for the pages you would use the Title field for the option title and add a text field for the option value. -
Nice tutorial, thanks! You could simplify the methods a little by making sure you always get the Images field as a Pageimages array, e.g. $wire->addHookMethod('Page::siteFeaturedImage', function($event) { $page = $event->object; if ($page->template != "article") { throw new WireException("Page::siteFeaturedImage() only works on 'Pages of article template', Page ID=$page is not such!"); } $article_featured = $page->getUnformatted('article_featured'); // always a Pageimages array if (count($article_featured)) { $img_url = $article_featured->first()->url; } else { $img_url = urls()->templates . "assets/img/missing-article_image.jpg"; //we show this when image is not available } $event->return = $img_url; });
-
Splitting PageArray into two new arrays (with half the items each)
Robin S replied to SamC's topic in General Support
Nice one. Just another way to skin the cat... <?php $testimonials = $page->testimonials; $testimonials->shuffle(); $firstTestimonial = $testimonials->shift(); ?> <div class="jumbotron jumbotron-fluid bg-color"> <div class="container"> <h2><?= $firstTestimonial->title; ?></h2> <p><?= $firstTestimonial->testimonialBody; ?> - <i><?= $firstTestimonial->testimonialReviewee; ?></i></p> </div> </div> <div class='container'> <div class='row'> <div class='col-6'> <?php foreach($testimonials as $index => $testimonial): ?> <?php if($index == ceil(count($testimonials) / 2)): ?> </div> <div class='col-6'> <?php endif; ?> <h2 class='py-3'><?= $testimonial->title; ?></h2> <p><?= $testimonial->testimonialBody; ?></p> <p class="font-weight-bold text-muted">- <i><?= $testimonial->testimonialReviewee; ?></i></p> <?php endforeach; ?> </div> </div> </div> -
I forked this module and made it PW3 compatible. See the readme and the commit for details of what was changed. https://github.com/Toutouwai/ProcessBatcher If folks want to test it and report back I can make a pull request for @Wanze. @tpr, I hid the AdminOnSteroids datatables filterbox and the title case-change button because the layout was a bit messed up. Maybe you could take a look at that when you have time?