
BillH
Members-
Posts
267 -
Joined
-
Last visited
-
Days Won
4
BillH last won the day on April 21 2022
BillH had the most liked content!
About BillH
- Birthday 03/06/1962
Contact Methods
-
Website URL
https://arkesis.co.uk
Profile Information
-
Gender
Male
-
Location
London, UK
Recent Profile Visitors
3,137 profile views
BillH's Achievements

Sr. Member (5/6)
192
Reputation
-
BillH started following Field output order on page , Sanitizer to match TinyMCE encoding , Full-text search of linked files? and 6 others
-
Take a look at the flags for $sanitizer->entities(), which is essentially a wrapper for PHP's htmlentities(). You could also consider PHP's htmlspecialchars().
-
Following on from @Tiberium's suggestion, which is how I've done such things myself in the past, if you want to extract text for search out of just about anything there's Apache Tika. It's in Java so, again as suggested, you'd need some sort of VPS or dedicated server – or perhaps you could make it part of a pipeline (e.g. on a local machine) to deliver content to your site.
-
Most Markdown parsers allow raw HTML to pass through by default. This is the case with Parsedown, the parser used by TextformatterMarkdownExtra. I've just tried Test Markdown in TextformatterMarkdownExtra settings (v. 1.8.0, PW 3.0.210) and it passes through HTML as expected.
- 1 reply
-
- 1
-
-
The following should help to get you started. This is totally off the top of my head, so apologies if any of it isn't correct! $sourcePages = $pages->find("A suitable selector here"); foreach($sourcePages as $sPage) { $sPage->of(false); // Turn off output formatting // Get the image and caption $sourceImage = $sPage->myImageField->first(); if(!$sourceImage) continue; // Skip if no image $sourceCaption = $sourceImage->get('caption'); // Assumes a custom image field named 'caption' // Find the target page $targetPage = $pages->get("Create a suitable selector here"); $targetPage->of(false); // Set fields in the target page $targetPage->myImageField->add($sourceImage->filename); $newImg = $targetPage->myImageField->last(); $newImg->set('caption', $sourceCaption) // Save $targetPage->save(); } I suggest commenting out saving the target page while testing.
-
The Tracy Debugger console might be the easiest mechanism for implementing and running the code – though the code itself will be very similar however you do it. If you don't have it installed, Tracy Debugger is a highly recommended module. The advantage of using the console is that it's easy to run code and get an output, so you can work in an interactive way, testing things and running them. I suggest trying it out with straightforward code (note that the context is the current page, so $page->title returns the title of the current page) to see if it's a way of working that'd suit you.
-
As this is (presumably) a one-off exercise, yes, that's a good point!
-
You will need to write your own script – either to run in Admin Actions or as a separate PHP script (say if you need guidance on how to set this up) or in a template. The Admin Actions "Copy Content..." should, I think, have duplicated the image. One quick way to check for sure if the image has been duplicated to the new page is to look in the directory /site/assets/files/ and find the directory named with the ID of the page in question.
-
Slow initial loading of a form using InputfieldPageAutocomplete
BillH replied to BillH's topic in Module/Plugin Development
Many thanks @bernhard, you put me on exactly the right track to fixing this. The cause of the trouble was in another module that was loading and processing data from many pages when the current page loaded for editing. Fortunately, I'm already planning to replace the problem module with something much more efficient. I knew it was struggling, but it didn't occur to me that it might interfere with the new module! Thanks again! -
As @Tiberium suggest, the best way would be to run a PHP script from an external file (how I'd do it) or in a template. Or an alternative would be to set up an Admin Action: https://processwire.com/modules/process-admin-actions/. If you're not familiar with running scripts that access the API, I suggest starting with https://processwire.com/docs/front-end/include/. And another helpful page is https://processwire.com/docs/start/api-access/. In all cases, the procedure would essentially be this. First rename field sand add them to templates manually through the admin interface (if necessary, temporarily rename fields, then name them what you finally want when everything is in the right place). Then set up a script to loop through the pages with the source of the images, copying each image from the old field to the new field on the relevant page. (If each field has only a single image, you won't need to loop through the images in the field.)
-
I have created a module that uses a modal dialog (an iframe containing a PW form) to insert anchors into a CKEditor field. It is heavily based on ProcessPageEditLink, though is substantially simpler. The purpose of the dialog is to make selecting a page with a certain template much easier and more efficient for users than with the standard ProcessPageEditLink dialog. This is necessary because the selection is from about 7,000 pages with a particular template - and the number will grow. (The pages are bibliographic entries that are frequently linked to in the text.) The only active field in the form is InputfieldPageAutocomplete (not used in ProcessPageEditLink), as this is the most efficient way (that I can think of) to find the page needed. So, clicking a button in CKEditor (CKE plugin) opens an iframe containing a PW form (PW module). An "Insert Reference" button inserts the anchor (using a simple endpoint to get the URL for the page, as InputfieldPageAutocomplete doesn't provide this). The problem is this: the first time the dialog loads for a particular page, there's a delay of about 6–8 seconds before the content of the modal appears – that is, the modal appears, but remains blank for several seconds. Subsequently, the delay is only a fraction of a second. If I go to a new page I suspect the InputfieldPageAutocomplete field is the cause of the issue, but I can't find any evidence to support this. As I understand it (and I could be wrong), InputfieldPageAutocomplete doesn't preload data – it does an AJAX search on pages. I've tried all the profiling I can think of (timers in the scripts, monitoring network traffic), but this hasn't revealed anything. Does anyone have suggestions for what the cause of the trouble might be – or even where I could look next? Or ideas for an alternative plan? Thanks!
-
Or if acceptable (which it might not be!), use a text list of names - maybe with icon-sized versions of logos. Perhaps this could be combined with the suggestion from @BrendonKoz.
-
Following from @wbmnfktr's suggestion, note that the documentation for sort=sort states "But note that if the results have multiple parents, the resulting order isn't likely to be that useful." I find that in cases like yours something along the lines suggested in this post is often what I need:
-
One approach might be to keep a log of a certain number of timestamps for the most recent hits on each page (dropping the oldest when adding a new one). Calculating the average difference between the timestamps would give a rate at which the page is being hit. It might also work to look at the age of the oldest timestamp, and if it's less than a certain age assume the page is receiving a lot of hits. You might find some useful techniques in the Page Hit Counter module.
-
I assume that you are talking about a user of the back end being able to change the order. The nicest way that comes to mind would be to use the ProFields Repeater Matrix (a paid module), which would allow dragging fields into order. Otherwise, I'd suggest a Page Reference or Select Options field to define the order of fields. You could use radio buttons with predefined field arrangements (e.g. 'main text / slider / image' , 'slider / main text / image', etc). It might also be possible to use AsmSelect instead of radio buttons, with each value being a field, and with preselected or default values that include all fields. However, you'd probably want to omit the delete button on each item and the selection dropdown, which could get complicated (perhaps easiest using CSS). Others may have better ideas!
-
That's a serious amount of PW awesomeness you've provided! Bookmarked for my own purposes ?