Jump to content

Spica

Members
  • Posts

    122
  • Joined

  • Last visited

Posts posted by Spica

  1. Sorry, but dont get it to work. Tried this.

    	function saveButtonText(HookEvent $event) {
    			$form = $event->return;
    			$submitbutton = $form->get('submit_save_unpublished');
    			$submitbutton->attr('value', 'myButtonText');
    	}
    

    And actually I want to change only the text of the button. Realized that I am adressing the value, which should stay for the propper functionality of the form.

  2. How to change the buttons value. Have the hook,

    $this->addHookBefore('ProcessPageEdit::buildForm', $this, 'pButton');
    

    but dont find any hint how to adress the value of the button which is defined in line 387 in processPageEdit

    $submit2->attr('value', $this->_('Save + Keep Unpublished')); // Button: save unpublished
    
  3. Have created a permission page-publish and assigned to a role. In pageedit the role cannot publish anymore, but still gets the publish button and save + keep unpublished. Is that ment to be that way? How to just get a save button for that role, that does not publish?

  4. Nice solution.

    Ended up with this as a autoload module

    <?php
    
    class Helloworld extends WireData implements Module {
    
        public static function getModuleInfo() {
            return array(
                'title' => 'Hello World',
                'version' => 1,
                'singular' => true,
                'autoload' => true,
    			'summary' => 'Anpassungen',
    			'icon' => 'smile-o', 
                );
        }
    
        public function init() {
            $this->addHookBefore('ProcessPageEdit::buildForm', $this, 'hideSettingsTab');
        }
    
    
    	function hideSettingsTab(HookEvent $event) {
    		if($this->user->hasRole("presenter")) {
    			$page = $event->object->getPage();
    			$page->template->set('noSettings', 1);
    		}
    	}
    
    }
    
    • Like 6
  5. Yes. But this does set global permission to the module. I want a different admin page for different roles, that do not have access to e.g. the tree. I now build a whole admin theme where roles get different outputs, e.g. just get access to own pages. This is the only way I see at the moment.

  6. As I am quite new to PW I do not fully understand the permission concept. So I put just some Questions.

    1. How does page-edit-created permission work. Is it ment to give only creators edit permission to ther own pages? And how is it drawn to a role or template?

    2. How to withdraw pagebased the edit permission for users/creators, reflecting the page-edit-created permission?

    3. How do I customize rolebased the access to e.g the settings tab in page edit mode?

    4. Is there a way do differentiate page-edit and page-publish permission?

  7. I want to build a rolebased admin page.

    Actually I use a custom admin page to which the user is redirected after BE login, which is nice so far. So the user is put to something like processwire/page/rolebasedpage with a template myadmin.php.

    I want now, to replace the pageoutput for processwire/page instead. I tried this in admin.php

    if($this->user->hasRole("myrole")) {
    	require($config->paths->adminTemplates . 'controller.php'); 
    	return $this->page->render("myadmin.php");
    } else {
    	require($config->paths->adminTemplates . 'controller.php'); 
    }
    

    Is this a good way. And, as it does not work yet, how to do it right. Am I referencing the template uncorrect or is there a more fundamental misconception?

  8. Did something like

    $table->action(array(
    	'New' => $this->config->urls->admin . 'page/add/?parent_id=1021',
    ));
    

    Which is ok for me now.

    Originaly I wondered how to get the edit/view/new/edit template Buttons after a click on a line. Isn't it a build in and reusable function. Would be good to know for the future.

  9. Great.

    To use it in a AdminTemplate I had to change it to

    $table = $modules->get("MarkupAdminDataTable");
    
    $table->headerRow( ["Title", "ID", "Created", "User"] );
    
    foreach($pages->find("created_users_id=".$user->id) as $page){
      $data = array(
        // Values with a sting key are converter to a link: title => link
        $page->title => $config->urls->admin."page/edit/?id=".$page->id,
        $page->id,
        date("F j, Y", $page->created),
        $page->createdUser->name
      );
      $table->row($data);
    }
    
    // $table->footerRow( $someArray );
    
    echo $table->render();
    

    and ad a missing $

    Or would you recommend to use it as a modul over a custom admin template?

    And how to integrate the view/edit etc Buttons as in the tree view?

    • Like 1
  10. Just moved to Processwire. I wonder, how to customize the lister of the core with a customadminpage. Id like to filter a pagelist by creator-id. Lister does that job perfect. But what I need is a custom admin page with the list, but no lister configuration/dropdowns. So the user just gets a predefined list of certain pages.

    So far I managed two basic things in the custom admin template

    $pl = $this->modules->get("ProcessPageList");
    $pl->set('id',1001);
    echo $pl->execute();
    

    processes me a tree, but I cant figure out how to filter for creationid

            $items = $pages->find("created_users_id=".$user->id );
    
            $out = "<table width='100%'>";
            $out .= "<thead>";
                $out .= "<th>Title</th>";
                $out .= "<th>Date Created</th>";
                $out .= "<th>User</th>";
            $out .= "<thead>";
            $out .= "<tbody>";
    
            if ($items != ""){
    
                foreach ($items as $item) {
                    $out .= "<tr>";
                    $out .= "<td><a href=". $config->urls->admin . "page/edit/?id=" . $item->id .">" .$item->title . "</a></td>"; // title
                    $out .= "<td>" . date("F j, Y", $item->created) . "</td>"; // date created
                    $out .= "<td>" . $item->createdUser->name. "</td>"; // user that created
                    $out .= "</tr>";
                }
    
            } else {
                
                // empty pageArray message
                $out = "<tr><td>No pages matching your criteria were found.</td></tr>";
    
            }
    
            $out .= "</tbody>";
            $out .= "</table>";
            
            echo $out;
    

    This gives me nearly the list I want. But its generated with the pages object and a more static result list.

    What would you recommend, what is the best way to follow.

×
×
  • Create New...