Jump to content

cehlo

Members
  • Content Count

    12
  • 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. Thank you all. WillyC hit it. That was my one little mistake 🙂
  2. 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 :).
  3. 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.
  4. 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?
  5. 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? 😄
  6. 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.
  7. 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; } });
  8. Hmm. Error dissapered but I can't get it working, my template names are OK, but nothing changes. Some idea?,
  9. 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
  10. 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.
  11. 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...