Jump to content

Mackski

Members
  • Posts

    139
  • Joined

  • Last visited

Recent Profile Visitors

3,611 profile views

Mackski's Achievements

Sr. Member

Sr. Member (5/6)

29

Reputation

3

Community Answers

  1. Just installed the module with a fresh PW install and have a fatal error: $menu = $this->modules->get('MarkupMenuBuilder'); $this->navigation = $menu->render('main');
  2. getForPage() is used on an actual repeater item? The repeater is empty. if i print_r($page->repeater); i can see the page parent in the selectors: parent_id=11686 This is ID is what I'm trying to retrieve. ProcessWire\RepeaterPageArray Object ( [hooks] => Array ( [PageArray::render] => MarkupPageArray->renderPageArray() in MarkupPageArray.module [PageArray::renderPager] => MarkupPageArray->renderPager() in MarkupPageArray.module ) [count] => 0 [total] => 0 [start] => 0 [limit] => 0 [selectors] => parent_id=11686, templates_id=104, sort=sort ) [SOLVED] As simple as: $parent_id = $pages->get('name=for-page'.$page->id);
  3. I'm trying to move repeater items, simply change the parent id of each repeater item but I'm struggling to retrieve the actual ID of the repeater on the target page. (Not the field id, the repeater_page_id) If the repeater on the target page is empty; What i need is: $target_repeater_parent = $target_page->repeater_field->id; So I can: foreach($source_page->repeater_field as $item) { $item->parent = $target_repeater_parent; $item->save(); } What am I missing here?
  4. You're right, It just wasn't obvious at the time, now that I create another menu it's fine, i must have been smoking something.. 🚬🍀 Thanks for this great module!!
  5. Using this module for the first time, menu created and saved but does not render. Looks like by default it's saved as un-published. I was expecting to find publish settings as part of the menu settings, however the only way to publish it is via the page tree: Admin > Setup > Menu Builder > *Menu* Is this intentional? I think from a usability perspective being able to publish the menu as you create it would be helpful. The only way I could get menu builder to render items was update line 218, MarkupMenuBuilder to: For some unknown reason, PW doesnt skip language. // skip inactive language page @note: PW will do this automatically for 'include_children' if(!$p->viewable($language) && $language) continue;
  6. How do I get a reference to the repeater page, instead of the page the repeater is on? $page->id returns the parent or containing page, rather than the repeater id. [SOLVED] $value = $this->hasPage->data['some_field'];
  7. I have a strange problem with repeaters, the markup for sort order is rendered correctly, as is the repeater list and markup: eg: <input id="sort_repeater73338" class="InputfieldRepeaterSort" name="sort_repeater73338" value="0" type="hidden"> <input id="sort_repeater73322" class="InputfieldRepeaterSort" name="sort_repeater73322" value="1" type="hidden"> After saving, there is no change in the sort order in the DB. Every repeater with the same parent has the same sort order, no matter what. This happens at the time of created via the API, I am explicitly setting the sort order here: $rep = $p->draw_nomination_repeater->getNew(); $rep->page_link = $array['id']; $rep->sort = $x++; $p->draw_nomination_repeater->add($rep); $p->of(false); $p->save(); Could the sort change not be detected when creating multiple repeaters via the API? if($page->isChanged('sort')) { // $this->message("Sort changed for field {$this->field} page {$page->id}", Notice::debug); $sortChanged = true; }
  8. Thanks for your help @Zeka I managed to get both hooks working after a bit of debugging. $this->addHookAfter("ProcessField::buildEditFormBasics", function(HookEvent $event) { $f = $event->object->getField(); if($f->hasFieldtype !== false) { $field = wire('modules')->get('InputfieldTextarea'); $field->attr('name', 'helpTipContent'); $field->attr('value', $f->helpTipContent); $field->collapsed = $f->helpTipContent ? false : true; $field->label = __('Help tip content'); $field->description = __('Enter the help tip content that will appear in the tool tip.'); $event->return->append($field); } }); // inject our markup fields into the form right after the source elements $this->addHookAfter('ProcessPageEdit::buildForm', function($event) { $form = $event->return; $page = $this->process->getPage(); foreach($form->fields as $f) { $content = $f->helpTipContent; if($content) { $_field = $form->get($f->name); if($_field->id) { // add hidden field with tooltip content $field = wire('modules')->get('InputfieldMarkup'); $field->attr('name', 'toolTipContent'); $field->attr('value', $content); $field->skipLabel = true; $form->insertAfter($field, $_field); } } } });
  9. I've modified the hooks to add the field to every inputField. // first hook to add field (works as expected) $this->addHookAfter("ProcessField::buildEditFormBasics", function(HookEvent $event) { $f = $event->object->getField(); if($f->hasFieldtype !== false) { $field = wire('modules')->get('InputfieldTextarea'); $field->attr('name', 'helpTipContent'); $field->attr('value', $f->helpTipContent); $field->collapsed = $f->helpTipContent ? false : true; $field->label = __('Help tip content'); $field->description = __('Enter the help tip content that will appear in the tool tip.'); $event->return->append($field); } }); // second hook to render $this->addHookBefore("Inputfield::renderReadyHook", function($event) I still cant find the helpTipContent field in the second method, maybe I'm hooking into the wrong place?
  10. @ZekaDefiantly not working for me, im stumped now.
  11. Thanks Zeka, my next issue is I've created a custom textarea against a field, and value is saved, but I cannot return the value at render time. I've been modeling a bit of code from: https://processwire.com/talk/topic/9857-page-field-edit-links/ I cannot seem to replicate the rendering of saved values, here is my code: // this works, and saves values against a custom field $this->addHookAfter("InputfieldPage::getConfigInputfields", function($event) { $f = $event->object; if($f->hasFieldtype !== false) { $field = wire('modules')->get('InputfieldTextarea'); $field->attr('name', 'helpTipContent'); $field->attr('value', $f->helpTipContent); $field->collapsed = $f->helpTipContent ? false : true; $field->label = __('Help tip content'); $field->description = __('Enter the help tip content that will appear in the tool tip.'); $event->return->append($field); } }); // at render time $this->addHookAfter("InputfieldPage::renderReadyHook", function($event) { $object = $event->object; d($object); }); // $object does not include my new field, helpTipContent.
  12. Struggling with this, trying to obtain a list of fields under a specific tab in admin. $this->addHookAfter("ProcessPageEdit::buildForm", $this, 'hookField'); public function hookField(HookEvent $event) { $form = $event->return; $fieldset = $form->find("id=ProcessPageEditContent"); $fields = $fieldset->fields; foreach($fields as $f) { echo $f->name.'<BR>'; } } This only outputs all fields from all templates, not the fields from the specific page & table I'm editing.
  13. If I'm adding a custom field I also take it that I'll need to create a schema etc to store the values? Is there a way to adding abitry fields to a page in admin similar to notes, description fields without defining a schema?
  14. Thanks Benhard for this module, small modification i've updated the save() function to allow various output types as stated: https://mpdf.github.io/reference/mpdf-functions/output.html /* ########## output ########## */ /** * save output to: local file ($dest = "FILE") download ($dest = "DOWNLOAD") inline to browser (default - $dest = "INLINE") */ public function save($filename = 'output.pdf', $dest = "INLINE") { if(!$filename) $filename = 'output.pdf'; if($dest == "FILE") $filename = $this->getAbsolute($filename); // save to disk $this->mpdf->Output($filename, constant('\Mpdf\Output\Destination::'.$dest)); } // stream to browser $pdf->save(); $pdf->save('filename.pdf') $pdf->save('filename.pdf,'INLINE); // force download $pdf->save('myfile.pdf','DOWNLOAD'); // save locally $pdf->save('myfileserver.pdf','FILE');
×
×
  • Create New...