Jump to content

BillH

Members
  • Posts

    271
  • 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,313 profile views

BillH's Achievements

Sr. Member

Sr. Member (5/6)

194

Reputation

  1. This gives a solution to what sounds like it might be the same problem:
  2. I don't know if this will help in your case, but my usual starting point for dealing with similar issues is this discussion:
  3. I haven't tried (and so could easily be wrong!), but I think the following would work: foreach ($pages->find("template=template_name") as $page) { ob_start(); $page->render(); ob_end_clean(); } The output buffering is to stop the pages rendering in the browser. It'd probably be easiest to put the code in a template file.
  4. To me, representing an unset timestamp with a valid timestamp (i.e. 0) would seem misleading and lose information - even if an intentional 0 seems unlikely to occur! If for your purposes you want a 0 rather than an empty string, you can simply cast the returned value to an integer: $myDate = (int) $page->getUnformatted('my_date');
  5. 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().
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. As this is (presumably) a one-off exercise, yes, that's a good point!
  11. 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.
  12. 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!
  13. 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.)
  14. 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!
  15. 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.
×
×
  • Create New...