Jump to content

webhoes

Members
  • Content Count

    205
  • Joined

  • Last visited

Community Reputation

82 Excellent

About webhoes

  • Rank
    Sr. Member

Profile Information

  • Gender
    Male
  • Location
    Netherlands

Recent Profile Visitors

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

  1. @flydev, thanks works perfectly!
  2. Hello, I want to add an item to the user navigation menu. In the picture below I added it (My studbooks) in the core files. It is hookable, but I can't get the hook to work. Ready.php // /* to figure out */ $this->addHookAfter('AdminThemeFramework::getUserNavArray', function(HookEvent $event) { // Get the object the event occurred on, if needed $AdminThemeFramework = $event->object; $AdminThemeFramework = $navArray(); // An 'after' hook can retrieve and/or modify the return value $return = $event->return; /* Your code here, perhaps modifying the return value */ $navArray[] = array( 'url' => '/my-studbooks/', 'title' => $this->_('My studbooks'), 'target' => '_top', 'icon' => 'eye', ); // Populate back return value, if you have modified it $event->return = $return; }); What should I change to get it working from ready.php
  3. @MarkE, Thanks! This is a total different I was looking at and mine doesn't work. I will play with this and see if I can get it to work in my setup.
  4. Interesting. Are you willing to share you module? I have not been able to get a secure setup myself. The pageload in my case is my security setup. I check for referenced users from a parent page or parent parent page. This is really time consuming.
  5. I made a similar something, but it increased the pageload by 3 seconds. This is too much. Do you give the user temporarily page-edits upon granted request of that page?
  6. @MarkE, did you get this working without giving user page-edit rights?
  7. Hello, I am working on a site where multiple users have one ore more pages (studbook). These pages can contain children (animal) and animal can have a child (transfer). I created an admin before the PW admin. Here users can see their the pages the have their users_created_id. I use the feel module for editing. But if someone right clicks the edit button, they end up in the PW admin and can see everything (not allowed). So I created a module to redirect everybody but superuser from the admin templates (except if page id == 10, the edit template). This sort of makes is secure, but if a user knows the id of the page they can still type /processwire/page/edit/?id=xxxx and see that page. I have been working some days around this, but no solid solution came up. I do have the formbuilder module available if this can help. I also thought of making a role for every studbook. That would mean 35 roles and 35 studbook templates. Also animal and transfer templates need to be duplicated per studbook otherwise a user will still be able to see others. What other options are there to make it so people can only see their studbook and their child pages? Nice to have would be that to or more selected users can see and or edit that studbook. Preferbly all without page-edit rights so I can block everyone from the PW admin.
  8. @renobird, have you re-considered releasing the code for your ticket system or partly. Basicly the part that creates new tickets from emails and sends updates is the most important and difficult.
  9. Thanks @jmartsch and @bernhard I have updated the module with your improvements. Works very smooth...
  10. Damnnn... Or you name your module properly instead of having .php as extension. I could not find it among the modules, but I was confused with some other hooks that are not modules (like in ready.php) that just do their thing. Luckily, it works now.
  11. Could not get something working with those changes. After some more searches I came up with this, close to the examples but also still not working. public function init() { // add a hook after the $pages->save, to issue a notice every time a page is saved $this->pages->addHookBefore('save', $this, 'updateProduct'); } /** * Example1 hooks into the pages->save method and displays a notice every time a page is saved * * @param HookEvent $event * */ public function updateProduct($event) { /** @var Page $page */ $page = $event->object; //$page = $event->arguments('page'); if($page->template != 'product') return; $fields = $page->fields; $price = $fields->get('pad_price'); $rrp = $fields->get('pad_rrp'); $discount = $rrp - $price; $percentage = $discount/$rrp * 100; $page->of(false); $page->set('pad_discount', $percentage); $this->message('test'); }
  12. Hello, I have made a module, but I can't get it to work. I have 2 fields with price (price and rrp). On save I want to calculate the difference in percentage and save it to the discount field. It does not update the field. What am I doing wrong? class UpdateDiscount extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Custom discount updater', 'version' => 1, 'summary' => 'Auto update percentage based on prices.', 'singular' => true, 'autoload' => true, 'icon' => 'money', ); } public function init() { // add a hook after the $pages->save, to issue a notice every time a page is saved $this->pages->addHookAfter('save', $this, 'updateProduct'); } /** * Example1 hooks into the pages->save method and displays a notice every time a page is saved * * @param HookEvent $event * */ public function updateProduct($event) { /** @var Page $page*/ $page = $event->arguments[0]; if($page->template != 'product') return; $price = $page->pad_price; $rrp = $page->pad_rrp; $discount = $rrp - $price; $percentage = $discount/$rrp * 100; $page->setAndSave('pad_discount', $percentage); } }
  13. I tried this for a site, but the new button is still visible. The template studbook can have a child with template animal. I have resticted a per page right edit rights for the studbook. On that page you can use the tab to add a new animal. But all people can see the tree and now with every studbook there is a option for new. If this is not visible, only people with the right page rights you can add a child from the page... I am using the current dev version of pw. $this->addHookAfter('ProcessPageListActions::getActions', null, function(HookEvent $event) { $p = $event->arguments[0]; $actions = $event->return; if($p->template->name == 'studbook') { unset($actions['new']); } $event->return = $actions; });
  14. I did test this some time ago. To make this work I would have to make a user specific branch upon registering and dynamicaly give that user rights to that particular branch. that branch would contain all data for that user different child pages. I think that would be difficult to achieve and maintain.
  15. Interesting stuff... But what is defined as one branch? Is that one of the first childs of Home? If so, how would you deal with multiple branches that should all be treated equally? User may only see and edit childs of those branches he created himself? And to make it a little more complicated, some of those pages also contain child pages to which only the creating user should have access.
×
×
  • Create New...