Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

1 Neutral

About cehlo

  • Rank
    Jr. Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi folks, I am reaching you one more time for help with error I can´t solve. The setup is little more complicated, but I will try to introduce it in the best way. I have multiple user roles, one of them is role "member". These members have certain pages that they can edit, permission is granted during some automated process ( request for permission to edit, check if it is authorized, grant permission - via custom modules and hooks) but permission for editing is saved via module "PageEditPerUser". This pages which "member" can edit, have PageReference field, which is pointing on that user (Access - Users - Page of user) - field is called "dog_ownerSelect" and is used for loading personal data of owner = authorized user to page. Problem appears when the member is logged into processwire and he want to see pages which he can edit on live site. Return is only some error which does not seem have sense. On site traditionally error 500, because it is not superuser - output from tracydebugger error log is: [2019-11-03 10-30-56] PHP Notice: Undefined property: ProcessWire\User::$language in /nfsmnt/hosting1_1/b/5/b5ca8bf7-6179-408f-b688-09da79c8a644/daisy.sk/sub/hovawart/wire/core/PagesLoaderCache.php:236 @ https://hovawart.daisy.sk/databaza-chovu/chov/dajana-z-posonia/ When I added TracyDebugger permission to member, result: Call to a member function isDefault() on null. I am using $language in multiple places but that doesn't seem to be problem. I traced the error in file to using variable "dog_ownerSelect" in any way. <?php if(!$page->dog_ownerSelect){ } else { } ?> If there is this variable (which is pointing to user who is logged in) in any place in the file, it throws error I described. But this error occurs only if the user with role member is trying to look the page which he can edit. When you try to load page with guest or superuser or other member which doesn't have right to edit this page everything is going 100% smooth. Thank you for any suggestion where the error might be. Cheers Cehlo
  2. Thank you all. WillyC hit it. That was my one little mistake 🙂
  3. Hello, i just hit another problem. Maybe is very easy, but I can not find the place where I am having error. So I am doing some admin custom page - it shows requests from users for administrator. Administrator checks request and then should hit button approve or delete request. I am done this by creating table, and for each row in template I want to add also link with some data for GET. Problem is that table for some reason does not encode/render the link proper way - it only output html markup. (image 1, 2). Maybe I am missing something important? My relevant part of code below: <?php class ProcessRequests extends Process { public function init() { parent::init(); // required } public function ___execute() { $requests = new WireArray(); $match = $this->pages->find("template=request"); $requests->import($match); $requests->unique(); $requests->sort("-created"); $count = count($requests); if ($count) { $url = $this->config->urls->admin . 'page/edit/?id='; $table = $this->modules->get('MarkupAdminDataTable'); $table->setSortable(true); $table->setEncodeEntities(true); $table->headerRow(array( $this->_('#'), $this->_('Názov žiadosti'), $this->_('Typ žiadosti'), $this->_('Týka sa psa'), $this->_('Žiadosť podal'), $this->_('Vytvorená'), $this->_('Akcia'), )); foreach ($requests as $key => $u) { $mailer = $this->pages->get($u->request_mailer_id); $dog_ref = $this->pages->get($u->request_dog_reference->id); $table->row(array( $count - $key, $u->title => $url . $u->id, $u->request_type->title, $dog_ref->title => $url . $dog_ref->id, $mailer->name, date('Y.m.d - H:i', $u->created), "<a href=''>Schváliť</a>", )); } $out .= $table->render(); } else { $out .= "<p>" . $this->_("Well done, all dogs are edited.") . "</p>"; } return $out; } } Thanks for any replies :).
  4. The solution with module suggested by Adrian works perfectly, no more headaches. My problem was that the field dog-father and dog mother are fields Page Autocomplete, but with query selector, for dog_mother -> show only pages of template where dog_sex = female and for dog_father ->show only pages of template where dog_sex = male. So when I create new page via Autocomplete by hitting enter, it does not populate created page in field because, created page have no dog_sex setting saved, only title when doing it this way. Now I create all page in modal, dog_sex is required field so, problem solved.
  5. Yes, you understand perfectly 🙂 Thank you very much, you spare me from a long headache 😄 But in all cases how would be the correct way to return created page id with that hook? Is it even possible?
  6. Yes exactly, I want to create page with default title, but at same time populate value to one field in created page in relation with Page Reference field in which was new page created. My assumption is that I need to return value of page id created with this function ___processInputAddPages($input) /if that is possible/ and than add to created page desired value in relation with Page reference field. $wire->addHookAfter('InputfieldPage::processInputAddPages', function($event) { // Retrieve added page id - this is the hard part, I don't know how to do this // And than populate values to another field $field = $event->object; if($field->name == "dog_father"){ $page = $pages->get(???); //need for ID of created page $page->setAndSave('dog_sex', 1); } else if($field->name == "dog_mother"){ $page = $pages->get(???); //need for ID of created page $page->setAndSave('dog_sex', 2); } }); Or I am coming totally wrong on this? 😄
  7. Hello everyone, I am starting to creating some hooks, but I am little bit new to this part of Processwire so please help 🙂. My problem: I have multiple fields in one template - Page Reference - I activated autocomplete and also possibility of creating new pages from the fields. Is it possible to add additional values to newly created page via Page Reference field? For example: I know that the name of Page reference field is called for example car - I am searching with autocomplete for example for Mercedez, it is not created, so I know that newly created page via this field will have value in category field - cars,... I think I should addHookbefore to InputfieldPage::processInputAddPages, am I on the right track? Any assumptions? Thanks for help.
  8. OK, I finally get it working. I must admit that I don't know where the problem was. Solution with Page::listable, does not seem to work. I was using also Tracy debugger, bardump - return what I expected, but nothing changes on page. So I was doing little testing and searching and I come with this, which seems to work. 🙂 <?php namespace ProcessWire; $wire->addHookAfter('ProcessPageList::find', function(HookEvent $event) { if($this->user->isSuperuser()) return; $pages = $event->return; if($this->config->ajax){ foreach($pages as $p) { if($p->template == 'test') $pages->remove($p); } $event->return = $pages; } });
  9. Hmm. Error dissapered but I can't get it working, my template names are OK, but nothing changes. Some idea?,
  10. The AdminOnSteroids is just awesome, I didn't know something like this exists. But the other part of your solution does not seems to work the addHookAfter function throws this error: Call to a member function addHookAfter() on null. Some suggestions? ll
  11. Hello Robin, thank you for your answer! Yes I am aware of this, but I was looking if there is some solution to override this, or simply make empty page only for structure, which will not react to Processwire page tree, so only visual structure purpose. Dashboard is not a problem, I have already prepared stuff for this. Your solution looks very interesting and I will definitely look into it, and I think in each case I will implement this module also. But I was playing, searching, experimenting and here is what I found out like solution in my case: - I make new template root, which will have the root page - old home page: <?php echo $pages->get(1017)->render(); // render content from new Home page ?> Then I make new home page, and get to it homepage template. And to _head.php I just change navigation to exclude old home page title from nav - so basically use url from root and title from new home page. ( To eliminate issue with url after clicking on home - test.dev/home, expected: test.dev ). <?php homepage = $pages->get('/home/'); $children = $homepage->children(); echo "<li><a href='$urls->httpRoot'>$homepage->title</a></li>"; // Making first item in nav, overriding url issue foreach($children as $child) { if($child->id == $page->rootParent->id) { echo "<li class='current' aria-current='true'><span class='visually-hidden'>Current page: </span><a href='$child->url'>$child->title</a></li>"; } else { echo "<li><a href='$child->url'>$child->title</a></li>"; } } ?> So now it is working like charm, but I want to ask if this is optimal solution, if there are some disadvantages for this, maybe in SEO? I just found out that one problem will be url structure of child pages of home - it is not very charming like this - test.dev/home/about, etc.. Thank you.
  12. Hi, so I am starting my first bigger project in PW after some smaller. My actual challenge is to make website portal, internal managment of DB and Newsletter. My problem is the structure of pages tree. Normal: - Home - About - ... - Internal Db / hidden / - some basic data structure to manage, members of clubs and their info for example / - Newsletter / hidden / I am finding these little bit chaotic, or misleading for my client and not very good for my purpose. I also want to make admin home page dashboard, where client can choose only to manage website, internal Db or Newsletter. So my idea for better strucure is this: - WebPortal / empty page which only contains all above mentioned / - Website Home - About... - Internal Db - Newsletter I can't find solution for this matter here on Processwire website and my first tries always crashed on moving Home to child, and exclude it from nav etc... Maybe solution is Multisite Modul, but I don ' t need more domains so it is irrelevant. I just really love PW, hope I wil make it here! Cheers. Cehlo
  • Create New...