Jump to content

esspea

Members
  • Posts

    56
  • Joined

  • Last visited

Everything posted by esspea

  1. Well this turned out to be a simple one. The notice message disappears when: $config->debug = true; is set to false.
  2. Yes, in this case I'm calling the grandparent. Is there a better way? To be clear: The hook works, there's no problem there. The question is: why is this variable being called from a page that does not contain the form the hook applies to?
  3. Yes it's possible, here is the whole hook, line 62 is indicated with (62): $wire->addHookBefore('FormBuilderProcessor::renderReady', function($event) { $form = $event->arguments(0); if($form->name != 'kosning') return; // form name $field = $form->getChildByName('atkvaedi'); // get form field if(!$field) return; $parent = wire('page')->parent; //connect to parent page (62) $gestgjafi = $parent->parent->gestgjafi; $pages = $parent->get('thatttakandi_a_hatid'); //Get field values from parent page $sidur = explode('|', $pages); if(is_array($sidur)) { $newOptions = []; foreach ($sidur as $basID) { $page = wire('pages')->get($basID); if($page) { $children = $page->children(); foreach ($children as $child) { $optionValue = $child->title . ' (' . $page->title . ')'; $newOptions[$child->id] = $optionValue; } } } // Exclude the option with a value of $gestgjafi foreach ($newOptions as $key => $value) { if (strpos($value, $gestgjafi->title) !== false) { unset($newOptions[$key]); } } // Sort the remaining options by title in ascending order asort($newOptions); $field->options = $newOptions; } });
  4. Hi all, I have a strange notice appearing on my front page: Notice: Trying to get property 'variable' of non-object in /site/ready.php on line 62 The hook in ready.php is calling a $page->parent->object and obviously does not find it when on the front page, but the hook should only load when a specific form is loaded and it has a if this form else return statement. So why does this appear and how can I prevent it? Best regards.
  5. Thanks, I have recently started doing just that.
  6. Hello all, After I have posted some question or other I sometimes get an email asking me to "Help others by going to the topic and use the 'Mark as Solution’ button on the post with the best answer" I have looked and looked but never have I found this button, is there a trick or is it really missing? Best regards.best answerhe 'Mark as Solution’ button on the post with the best answergoing to the topic and use the 'Mark as Solution’ button on the post with the best answer
  7. I asked chatGPT for advice and after a few rounds of gradually more specific questions, I got this working. Here is the resulting hook: $wire->addHookBefore('FormBuilderProcessor::renderReady', function($event) { $form = $event->arguments(0); $field = $form->getChildByName('formfield'); // get form field in this case a radio page array if(!$field) return; $parent = wire('page')->parent; //connect to parent page //echo $parent; //Returns the correct page $pages = $parent->get('parent_field'); //Get field values from parent page $sidur = explode('|', $pages); //echo $pages; //Returns the correct selected pages if(is_array($sidur)) { $newOptions = []; foreach ($sidur as $basID) { $page = wire('pages')->get($basID); if($page) { $newOptions[$page->id] = $page->title; } } usort($newOptions, function($a, $b) { return strcmp($a, $b); }); $field->options = $newOptions; } });
  8. Hello, I have a form, a simple radio button list of items populated by page list. I have a field, a checklist page list with the same pages (but not the same field) What I want to do is have the radio button list only display items checked in the checklist. I hope this makes sense 🙂 Now I have this hook, but it does not work: $wire->addHookBefore('FormBuilderProcessor::renderReady', function($event) { $form = $event->arguments(0); $field = $form->getChildByName('formfield'); // get form field in this case a radio page array if(!$field) return; $parent = wire('page')->parent; //connect to parent page, that contains the checklist //echo $parent; //Returns the correct page $pages = $parent->get('parent_field'); //Get checked field values from parent page $sidur = explode(',', $pages); //turns the "get list" into array if(is_array($sidur)) { foreach ($sidur as $basID) { $field->removeOption($basID); } } }); Nothing is removed. Where does it go wrong? Thanks!
  9. Thank you very much, bernhard, it works like a charm 🙂
  10. Hello all, So, from within a hook I can: Directly call a cookie variable by: $_COOKIE['varname'] and I can directly call server data by: $_SERVER['REMOTE_ADDR'] but $_SESSION['varname'] does not work, and neither does $session->get('varname'). How can I call a session variable from within a hook? Best regards, Snorri
  11. You were right from the beginning, virtualgadjo. The problem was permissions to the main.css file. I had it set to 744 but not 755. Now it all looks nice again and I have had a good and thorough learning curve and am not the slightest bit embarrassed ? Best thanks and regards, Snorri
  12. Here is the link to the main.css file: <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates;?>styles/main.css" /> looks OK to me. If I open "view page source" and click the link to the css file I get a 403, but as far as I can find out the folder and file permissions are in order, 744 for folders and 644 for files. Ive done hard refresh but what is a "module refresh"?
  13. Thank you virtualgadjo, I will check this out. I'd like to add that this is a fresh install, I have made no changes at all. Regards, Snorri
  14. Hello everyone, I've recently changed ISP and now when I set up a new site, the page appears and everything is there and everything works but there is only html, there seems to be no CSS. Can anyone point me in the right direction please? Here is how it looks:
  15. Thank you Bill and Mark, you've been most helpfull.
  16. Hello, As my first project I chose to create a recipe page. Not really inventing the wheel, I know, but It's a fun project and there are a few learning points. Now I have set up the database and I can create recipes and they look ok so that's kinda sorted. What I want to do next is categorizing. The "recipe" template has a page reference field called category where each recipe can get categorized by more than one category and I want to be able to sort the recipes by category. I've been fiddling about with find() but not really gotten it to work properly, can someone please give me a little push, an idea to get me on the right track. Thank you, Snorri
  17. Well, now it works. It seems it might have been a browser cache thing. Sorry to trouble you all, especially you Ivan. This is a beginners thread after all ?
  18. Hi Ivan, thank you for your reply. That's the thing, the install.php has been removed and if I press the "Get started" button, which links to install.php, I get að 404 error. I looked through permissions and they look OK and all the pages seem to be there. The problem seems only to affect the home page. Regards, Snorri
  19. Hello, I'm new to PW and I'm having a problem installing. I'm installing PW, as I have done a few times before. I use git to get PW and then I go to the install page and go through the install process and everything looks good untill the end when I click "go to page" it brings me back to the initial welcome page. Not the default front page. I have tried more than once and more than one installation profiles. Always the same result. What am I doing wrong? I might add that everything else works, the admin area and all other pages, it's just the front page that doesn't Thanks, Snorri
×
×
  • Create New...