Jump to content

iank

Members
  • Posts

    101
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by iank

  1. Hi @bernhard, I'm working on my first site using your superb RockPageBuilder and for some reason I can't seem to get Textarea/TinyMCE fields 'properly' front-end editable - instead, double-clicking just opens the modal for the block. Standard Text fields are front-end editable, no problem. I must be missing something obvious, but I can't see it. I've installed your demo 'Text' block and the TinyMCE field works - even if I refactor your latte file to a basic view.php file (I'm using PHP view files for my blocks for now). I know that's not much to go on, but perhaps you might know of somewhere I can start to look? As far as I can tell I've pretty much followed all the instructions quite carefully! Is there a hidden setting that I'm not seeing somewhere that makes these fields front-end editable? Many thanks in advance, Ian.
  2. Just a thought - do you have your template specific classes extending 'DefaultPage' rather than 'Page' ? The scenario you're describing has always worked just fine for me.
  3. In your Pages::saveReady hook, the $event->object is actually \Processwire\Pages. The actual page being saved is what's returned from $event->arguments(0). In this case you are assigning it to $user, but that won't always be meaningful; only when you're saving a user. Bernhard's solution will work of course, but it may also be advisable to assign $event->arguments(0) to the variable $page (rather than $user) to avoid confusion in the future. You can then check for $page-template == 'user' if you want to do something specific for users being saved.
  4. I did a little more digging too. It seems as part of the field rename process, the corresponding (old) table is temporarily renamed to tmp_field_yournewname, and then tries to rename this temp table to the correct new name: field_yournewname. This second part fails because the table already exists, so I believe this throws an Exception and you would expect the admin to re-render with an error notice. (Like it does with the normal duplicate field name error). However, since the underlying field's DB table has been renamed to its _tmp version, there's another exception, showing the error. At least I think that's what's happening. DB table names are lowercase by default ($config->dbLowercaseTables is true unless overridden), so 'Body' will try to create 'field_body'. @FireWire, you might find there's a tmp_field_body table in your DB, with all your content intact. Good to know there's a Github issue opened.
  5. I think I may have replicated this. (PW 3.0.200). My suspicion is that it's related to renaming the field to 'Body' (uppercase 'B') when the field 'body' (lowercase 'b') already exists. Processwire lets you name fields with upper and lowercase characters. Here's what I did on my dev system: Create a new field 'test_content'. (The field 'content' already exists). Add 'test_content' to a template and populated several pages with data. Check the db. The table field_test_content exists containing the data just added. Attempt to rename 'test_content' to 'Content' (note uppercase C). Receive error as shown below. Check db again. The table field_test_content is no longer there. It looks as if PW correctly checks for an existing field if the case matches, but goes ahead and deletes the table if not. Subsequently, whenever I try to edit a page with a template containing that field, I now receive the same error.
  6. Just a thought... One possibility is if you have Mod Security installed on the hosting. Often you will get a 403 (Forbidden) message on immediate posting if there's something in the page or posted content that triggers one of the modsec firewall rules. If this happens, nothing gets posted, and the 403 message is shown very quickly. I suspect the PHP Notice is probably unrelated.
  7. @Laegnur Are you running an older version of PW by any chance? InputfieldSelect::addOptionAttributes was only added around version 3.105. The above code works for me, (PW Version 3.200) if I use: $field->addOptionAttributes('Alicante', array("selected" => "selected"));
  8. Markup regions can keep your template files cleaner. Let's say for instance you have common header and footer section for all your pages. Without markup regions you might abstract these to include files and then include them in all your templates, for example: <head> [your template specific head content] </head> <body> <?php include($config->paths->templates . "_header.php"); ?> [Your template specific page content here] <?php include($config->paths->templates . "_footer.php"); ?> </body> Now this is fine if you only have 3 templates, but if your site grows bigger and more complex with possibly more include logic, that's where markup regions become of more value. In _main.php, I often have an empty <region id="pw-styles"> </region> just before my closing </head> tag, and a <region id="pw-scripts"> </region> before my closing </body> tag. Where I have a need for template-specific stylesheets and scripts (e.g for a lightgallery), I can just add these regions into those templates and put the necessary code in there.You can leave these entire region tags out of most templates, then just add them to the 'lightgallery' template, keeping your other templates clean. Over time you might find the need to add additional common code to all your templates. If your site has grown, this could mean updating a fair number templates with that code (or another include). With markup regions, you can just add this new code to _main.php and it's immediately included in all templates using _main.php. Meanwhile your template files remain clean with just their specific content, e.g. a basic page template might just be as simple as this: <region id="pw-content"> [your template specific page content here] </region> <?php include($config->paths->templates . "_main.php"); ?> And your _main.php would look like this: <head> [your common head content] <region id="pw-styles"> </region> </head> <?php include($config->paths->templates . "_header.php"); ?> <body> <region id="pw-main"> </region> <?php include($config->paths->templates . "_footer.php"); ?> <region id="pw-scripts"> </region> </body> Wheareas a template with lightgallery might look like this: <region id="pw-styles"> <link rel="stylesheet" href="/css/lightgallery.css"> </region> <region id="pw-content"> [your template specific page content here] </region> <region id="pw-scripts"> <script src="/js/lightgallery.js"></script> </region> <?php include($config->paths->templates . "_main.php"); ?> Whether that makes things clearer for you I don't know ?, but if you only have 3 templates for your entire site then using markup regions may be overkill.
  9. If you're saving a field's value to a page you need to set output formatting off first. However, to quickly save a field's new value you can use setAndSave(), which doesn't have this requirement: $oldValue = $page->numbers; $page->setAndSave('numbers', $oldValue++);
  10. I'm not sure if this should be considered a bug, a feature, or just something to be aware of, but I came across this behaviour today: Scenario: I have a 'body' field which is a CKEditor textarea field. I'm using $sanitizer->truncate() to output a truncated summary of the body for use on a parent 'list' page; e.g.: $sanitizer->truncate($page->body,200); Everything worked fine. Longer body content is truncated, shorter (<200) is output in its entirety. I then enabled the PageFrontEdit module for the site, and allowed the body field to be automatically editable (Option A). Suddenly, all the shorter body fields were being duplicated in the output. For example, when the body field contains just this: <p>More information will be coming soon...</p> The output from the above $sanitizer->truncate() call was this: More information will be coming soon... More information will be coming soon... After some investigation, I realised this is because the formatted value of the body field in this scenario looks like this: <div id=pw-edit-2 class='pw-edit pw-edit-InputfieldCKEditor' data-name=body data-page=1115 data-lang='0' style='position:relative'><div class=pw-edit-orig><p>More information will be coming soon...</p></div><div class=pw-edit-copy id=pw-editor-body-1115 style='display:none;-webkit-user-select:text;user-select:text;' contenteditable><p>More information will be coming soon...</p></div></div> ... including all the PageFrontEdit wrapping context. When stripped of the html tags the text appears twice and still being less than 200 characters, is output twice. Solution: It's easy to fix in this particular example. Just get the unformatted value before sending to $sanitizer->truncate(): $sanitizer->truncate($page->getUnformatted('body'),200); I don't know if this should be opened as an issue, since $sanitizer->truncate() doesn't know the context of what it's receiving; it's just a string. Maybe this can help others who might run into this problem.
  11. Hi @astock, No problem. You just need to check for the new page's parent in the selector, something like this: $wire->addHookBefore("ProcessPageEdit::buildForm", function (HookEvent $event) { $page = $event->object->getPage(); $myTemplate = "logbook"; //or whatever your template is called if ($page->template != $myTemplate) return; if ($page->startMileage) return; //not if the start Mileage is present $parent = $page->parent; //get the current page's parent //get the most recent logbook with an endMileage value for the current parent $prevPage = wire('pages')->get("template=$myTemplate,endMileage!=,parent=$parent,sort=-created"); if ($prevPage->id) { $page->startMileage = $prevPage->endMileage; } });
  12. Yes, I think a hook would be needed. Something like this should give you a start, added to site/ready.php: $wire->addHookBefore("ProcessPageEdit::buildForm", function (HookEvent $event) { $page = $event->object->getPage(); $myTemplate = "logbook"; //or whatever your template is called if ($page->template != $myTemplate) return; if ($page->startMileage) return; //not if the start Mileage is present $prevPage = wire('pages')->get("template=$myTemplate,endMileage!=,sort=-created"); //get the most recent logbook with an endMileage value if ($prevPage->id) { $page->startMileage = $prevPage->endMileage; } });
  13. The answer's almost in your question! $s = $location->getUnformatted('location_message_start');
  14. Hi, I'm not sure if anyone can help with this, but something odd is happening on one of my PW sites in the Admin=>Logs. When viewing an individual log's entries, the first page displays just fine, but as soon as I click Page 2 or beyond, the content doesn't refresh; the spinner icon stays visible, and the devtools console shows the 404 page is being returned, instead of JSON. I updated PW (from 3.0.94 to 3.0.165) yesterday, but that seems to be unrelated - I've tried reverting to v94, and the issue remains. I probably just haven't noticed it previously. There's nothing in the Tracy Logs or in debug mode that I can see. Lister page pagination is working OK, and pagination on the front-end is fine; it's just in the Log viewer in Admin. The same happens on localhost as well as the live site. Can anyone suggest where to look? It's not a big deal, just frustrating.
  15. I used PDFLayer (https://pdflayer.com/) recently in a project, and it did a good job of rendering some quite complex CSS. It's free to sign up for an api and you get 100 api calls/month with the free version. It could get expensive though if you have a lot of API calls to make (e.g. $9.99/month for 1000 api calls, $39.99 for 10,000). It was quite straightforward to use though, and you can set it to "test" mode for development, where it will overlay "Sample" on the PDF output, but not use any of your API requests.
  16. No, unfortunately not - I've had to disable the AutoSmush (or at least disable the optimize on upload option in the module). I guess it's a case of keeping an eye open to monitor when they'll fix their SSL. It's affecting non-PW users too: https://wordpress.org/support/topic/ssl-certificates-expired-on-resmush-it-servers/ Regards, Ian.
  17. Are you using the AutoSmush module by any chance, configured to use the reSmush.it service? I've encountered similar problems on a site with this installed, and there seems to be a problem with the SSL certificates on one or more of the reSmush.it servers since late December.
  18. Also, $sanitizer->pageName("raphaël", true) produces raphael. The second param being $beautify, which according to the docs: "Because page names are often generated from a UTF-8 title, UTF-8 to ASCII conversion will take place when $beautify is enabled."
  19. Scenario: I'm importing a whole number of pages via the API which will have titles such as "A Page Title | October 2018" and "Another Page Title | November 2018" and so on. However, there are some duplicates (the titles come from repeaters in another PW installation; these may well have the same title, but a different photo, for example). So, if I'm importing several pages with the same name, let's say: "A Page Title | October 2018" "A Page Title | October 2018" "A Page Title | October 2018" PW knows how to increment page names when they would be duplicated. I want these to create page names like the following: a-page-title-october-2018 a-page-title-october-2018-1 a-page-title-october-2018-2 but instead, the generated page names are: a-page-title-october-2018 a-page-title-october-2019 <= a-page-title-october-2020 <= not what I wanted!! The same behaviour occurs in the PW admin too. Does anybody have a suggestion how to override this situation? Thanks, Ian.
  20. @alexmercenary - Very strange! (as per the title of this thread!)
  21. Hmm, that is weird! It appears as though the first call to a subsequent page number other than the base (1) is overwriting the cached page for the base, though I don't understand how that can happen. I presume you're using ProCache? If so, maybe check the versions of the cached files themselves: When you clear the cache and call the base (first) page and it's rendered correctly, does it save the correct cached index.html in the appropriate ProCache folder in assets? What happens when you then visit one of the higher page numbers, say /page5? Does this 'root' index.html file immediately get overwritten? Is there an index.html in the page5 folder in ProCache assets? How do these two compare? You can also access the cached files directly in the browser since you'll know your own unique ProCache folder structure. This would eliminate any (unlikely) rewrite rule problems.
  22. Hi @alexmercenary, I don't think it's the same problem as I had - that was down to me not validating my UrlSegments. However I have had problems where the wrong "start" value is supplied to the selector, generally by being set by some other part of the code (some other selector with limit elsewhere in the code). I'm not sure that's your issue either, but it may be related. It seems that on your very first page of results, the "start" is somehow being set at a different value, and then this is being cached, generating the wrong set of results and corresponding pagination. If you bypass the cache (https://www.edmplus.co/uk-ltd/edm-consumables/?test=1) or explicitly specify the first page number (https://www.edmplus.co/uk-ltd/edm-consumables/Page1) then it works as expected. I'd look for something that could be inadvertently setting the start value or the $input->pageNum() when these aren't otherwise defined for the selector in question. Not sure if that helps, but maybe it's a start... Others more experienced may chip in!
  23. Hi @adrian - I've submitted an issue to the PW issues github. As you say, it doesn't quite feel like a bug, but at least it's officially on record now.
  24. Hi @adrian: Yes, I think that would work. At least then there is always something visible to the user for the key fields and button texts. I wonder if the cache thing may be an issue though, even if using template cache or WireCache. I'm not sure if there's an easy way around this. Sorry to keep adding problems Adrian..
×
×
  • Create New...