Jump to content

MarkE

Members
  • Posts

    1,090
  • Joined

  • Last visited

  • Days Won

    12

MarkE last won the day on September 12 2024

MarkE had the most liked content!

Recent Profile Visitors

6,288 profile views

MarkE's Achievements

Hero Member

Hero Member (6/6)

653

Reputation

  1. ALTER DATABASE databasename CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; Just need to change the field tables which need to hold emoticons
  2. I have enabled the emoticons plugin for TinyMCE. It appears to work when editing the page but, after saving, the emoticon just appears as ???? Any suggestions?
  3. Prompted by @ryan's recent enhancement of the page tree display, I wanted to display an alphabetical index of pages rather than a numerical one, so I built a hook after MarkupPagerNav::render. You can see the result here: https://ncorchards.co.uk/main/fruit-orchards/apples/ Basically the hook just replaces render() with a modified version. The key modifications are to select all the items without limit: $items = $event->arguments(0); //PageArray $itemSelector = $items->getSelectors(true); // true returns the string rather than the object $noLimit = preg_replace('/,\s*limit=-?\d+/i', '', $itemSelector); and then to modify the pager: $pagerNav = new PagerNav($object->totalItems, $object->itemsPerPage, $object->pageNum); $pagerNav->setLabels($objectOptions['previousItemLabel'], $objectOptions['nextItemLabel']); $pagerNav->setNumPageLinks($object->numPageLinks); $pager = $pagerNav->getPager(); $allItems = $this->find($noLimit)->explode('title'); $itemsPerPage = $object->itemsPerPage; foreach($pager as $key => $item) { if(!ctype_digit("$item->label")) continue; $index = (int) $item->label; $itemTitle = $allItems[($index - 1) * $itemsPerPage]; $item->label = substr($itemTitle, 0, 2); } If anyone wants the full hook code, let me know, but you will probably want to modify it for your own use anyway and the above are the key bits.
  4. v0.4.0 adds the ability to break out of the modal into a full page view. This is useful for admins who might require full page access but should not be used when the modal is called from the front end. It is enabled by showing a button in the modal.
  5. See my post re the context Now that I know the cause, my solution is to build a selector that always operates on the DB, by merging the user's selector with the one that was used to generate the Page Array: /** * Find the first generation of children that matches the given selector. * * This method traverses the children of the given parent page, generation by generation, * and returns the matches in first generation that has matches for the provided selector. * * @param Page $parentPage The parent page whose children are to be searched. * @param string $selector The selector to match against the children. * @return PageArray Returns a PageArray of the first generation that has matches, or an empty PageArray if no matches are found. */ public function findFirstMatchingGeneration(Page $parentPage, string $selector) { $currentGeneration = $parentPage->children(); $count = 1; while($currentGeneration->count()) { $currentSelector = $currentGeneration->getSelectors(true); $matching = $this->pages()->find("$currentSelector, $selector"); if($matching->count()) { return $matching; // Return the first generation that has matches } // Move to the next generation $nextGeneration = new PageArray(); foreach($currentGeneration as $child) { $nextGeneration->add($child->children()); } $count += 1; $currentGeneration = $nextGeneration; } return new PageArray(); // Return an empty PageArray if no matches are found }
  6. AKA 'bugs'? Are these documented somewhere. I'm wondering if it is possible to apply a sanitizer hook to fix them.
  7. I know this seems fairly basic, but I'm a bit stumped. I have a Selector field that returns something like "template=198" in response to the user selecting a template (i.e. it returns the id, not the name). Another field on the same page selects a parent page, say "parent=20940". If I use $pages->find("parent=20940, template=198") then the correct pages are found. If I do $subPages = $pages->find('parent=20940'); d($subPages); $subPages = $subPages->find('template=198'); d($subPages); then the second dump is an empty array. This can be fixed by using 'template.id=198' in the second selector. However, at least in my context, it is not really feasible to hack the selector that is returned from the Selector field. I have no idea what the selector might be. (BTW, the context, in case it is relevant, is that I am iterating the selector test down the page tree, starting at the parent page's children and stopping at the first level that finds a match). Any ideas?
  8. Yeah. That’s what I’m doing. I just wondered….
  9. This may seem like a really stupid question, but is there anywhere a really simple guide for completely non-technical editors explaining the basics of ProcessWire. The sort of things that might be covered are: what are pages and fields and templates adding new pages - title and name (including dealing with duplicate names) different types of fields - including page references publish vs unpublished the page tree and actions thereon trash vs delete but not covering editing fields or templates or any coding html or css stuff.
  10. So much to agree with in all of the above. My brief contribution: I came to ProcessWire having used WordPress and CodeIgniter. WP was fine if you just wanted a really simple website, but rapidly got frustrating if you needed something a bit more (adding a bookings capability to my holiday let website involved all sorts of contortions). CodeIgniter (ok, a bit passé now, I know) worked ok but needed a lot of coding and was a bit of a straitjacket. I looked at a whole load of CMS alternatives - Drupal etc. - but only ProcessWire had the right balance between CMS and CMF based on a really simple and intuitive concept (everything is a page). Completely unopinionated, but quick to get something working which can then be built on as necessary. As your needs grow, so you realise that PW grows with you.
  11. Hi @Juergen. I've hit another issue that seems to be related to your module. I have what I believe to be 2 identical environments for dev and live. However, after adding a new page, the dev environment (when in superuser) shows 2 buttons: 'Publish' and 'Save & keep unpublished', but the live environment (or not as superuser) just has 'Publish' and 'Save'. Any ideas what might be causing that (the dev superuser version is more helpful, I think). For this particular page, I don't want the 'Publish' button to be available unless certain criteria are met, so I added a hook: public function afterPageEditBuildForm(HookEvent $event) { $form = $event->arguments(0); // Get the form $page = $event->object->getPage(); // Get the page being edited if($page->template->name == 'NewsItem' && (!$page->final || !$page->approved)) { foreach($form->children as $field) { if($field->name == 'submit_publish') { $form->remove($field); } } } } That removes the 'Publish' button OK. However, if I am not superuser, clicking the 'Save' button does actually publish the page, even though the 'Publish' button was removed. If I am superuser, clicking 'save' saves it as unpublished. In order to make the hook work in all instances, I have to add: $page->addStatus('unpublished'); $page->of(false); $page->save(); but that really ought not to be necessary. The page in question is selected to 'add fields to templates' in your module but the fields are left blank. If I deselect the template then everything works correctly, but the helpful 'Save & keep unpublished' is just replaced by 'Save' (and of course, I no longer have the functionality). All a bit confusing!
  12. Ta @adrian. Posted an issue at https://github.com/processwire/processwire-issues/issues/2039
  13. When I switch a user and view the page tree, I get the following error. Any idea what is causing it? Not a big deal as it is only a warning, but it repeats hundreds of times. (PHP 8.1, Core 3.0.244 and Tracy 4.26.64). ErrorException: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/wire/core/DatabaseQuery.php:468 Stack trace: #0 [internal function]: Tracy\Bar->Tracy\{closure}(8192, 'trim(): Passing...', '/var/www/html/w...', 468) #1 /var/www/html/wire/core/DatabaseQuery.php(468): trim(NULL, ', ') #2 /var/www/html/wire/core/PageFinder.php(2294): ProcessWire\DatabaseQuery->__call('where', Array) #3 /var/www/html/wire/core/PageFinder.php(1956): ProcessWire\PageFinder->getQueryAllowedTemplates(Object(ProcessWire\DatabaseQuerySelect), Array) #4 /var/www/html/wire/core/Wire.php(419): ProcessWire\PageFinder->___getQuery(Object(ProcessWire\Selectors), Array) #5 /var/www/html/wire/core/WireHooks.php(968): ProcessWire\Wire->_callMethod('___getQuery', Array) #6 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\PageFinder), 'getQuery', Array) #7 /var/www/html/wire/core/PageFinder.php(803): ProcessWire\Wire->__call('getQuery', Array) #8 /var/www/html/wire/core/Wire.php(419): ProcessWire\PageFinder->___find(Object(ProcessWire\Selectors), Array) #9 /var/www/html/wire/core/WireHooks.php(968): ProcessWire\Wire->_callMethod('___find', Array) #10 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\PageFinder), 'find', Array) #11 /var/www/html/wire/core/PagesLoader.php(424): ProcessWire\Wire->__call('find', Array) #12 /var/www/html/wire/core/Pages.php(290): ProcessWire\PagesLoader->find('include=unpubli...', Array) #13 /var/www/html/wire/core/Wire.php(419): ProcessWire\Pages->___find('include=unpubli...', Array) #14 /var/www/html/wire/core/WireHooks.php(968): ProcessWire\Wire->_callMethod('___find', Array) #15 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Pages), 'find', Array) #16 /var/www/html/wire/core/PagesLoader.php(2032): ProcessWire\Wire->__call('find', Array) #17 /var/www/html/wire/core/Pages.php(245): ProcessWire\PagesLoader->count('include=unpubli...', Array) #18 /var/www/html/wire/modules/PagePermissions.module(1083): ProcessWire\Pages->count('include=unpubli...') #19 /var/www/html/wire/core/WireHooks.php(1094): ProcessWire\PagePermissions->moveable(Object(ProcessWire\HookEvent)) #20 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\DefaultPage), 'moveable', Array) #21 /var/www/html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/panels/RequestInfoPanel.php(573): ProcessWire\Wire->__call('moveable', Array) #22 /var/www/html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.10.x/src/Tracy/Bar/Bar.php(143): RequestInfoPanel->getPanel() #23 /var/www/html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.10.x/src/Tracy/Bar/Bar.php(115): Tracy\Bar->renderPanels('-ajax:e7cdf9f77...') #24 /var/www/html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.10.x/src/Tracy/Bar/Bar.php(78): Tracy\Bar->renderPartial('ajax', '-ajax:e7cdf9f77...') #25 /var/www/html/site/modules/TracyDebugger/tracy-2.10.x/src/Tracy/Debugger/DevelopmentStrategy.php(123): Tracy\Bar->render(Object(Tracy\DeferredContent)) #26 /var/www/html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.10.x/src/Tracy/Debugger/Debugger.php(314): Tracy\DevelopmentStrategy->renderBar() #27 [internal function]: Tracy\Debugger::shutdownHandler() #28 {main}
×
×
  • Create New...