Jump to content

saleo

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by saleo

  1. Hello. I don't know if this is a bug or if I'm using a bad practice. I'm testing out latest pw 3.0.167.

    I'm used to write this whenever I need to create a new Page from api

    $p = new Page();
    $p->template = 'upload';
    $p->title = 'my new page';
    $p->parent = 1019;
    $p->save();

    The following code is quite similar, yet when used inside a custom page class is generating a nasty issue.

    $upload = new Page();
    $upload->template = 'upload';
    $upload->parent = wire()->pages->get("template=uploads");
    
    $upload->title = time() . '-' . $email;
    
    $upload->nome = $nome;
    $upload->cognome = $cognome;
    $upload->email = $email;
    
    
    $upload->addStatus(Page::statusUnpublished);
    $upload->save();

    After execution, the admin stops working with this exception

    Umm… Fatal Error: Uncaught Error: Call to a member function getPageClass() on string in wire/core/PagesLoader.php:945
    
    #0 wire/core/PagesLoader.php (421): PagesLoader->getById(Array, NULL)
    #1 wire/core/Pages.php (255): PagesLoader->find('parent_id=1019,...', Array)
    #2 wire/core/Wire.php (400): Pages->___find('parent_id=1019,...', Array)
    #3 wire/core/WireHooks.php (823): Wire->_callMethod('___find', Array)
    #4 wire/core/Wire.php (465): WireHooks->runHooks(Object(Pages), 'find', Array)
    #5 wire/core/Page.php (4577): Wire->__call('find', Array)
    #6 wire/core/PageTraversal.php (130): Page- (line 945 of wire/core/PagesLoader.php)
    
    This error message was shown because: you are logged in as a Superuser. Error has been logged.

    Looking in the database, I notice that the new created page has no template assigned

    1372333231_Schermata2020-10-02alle06_31_30.thumb.png.503b6dd6ed13a74dfc8f62dc98cf457e.png

    If I remove that row from the db, the admin resumes working nicely.

    Now if I change this

    $upload->template = 'upload';

    to this

    $upload->template = wire()->templates->get('upload');

    everything goes as expected. Any ideas?

    Thank you

    Leo

     

  2. Hello. Maybe this is a known limitation, but after a bit of research I couldn't find any information about this.

    I created two roles, "client" and "agent".

    I have added some custom fields to the user template, and I want to show some of them only if the user (the user that is edited, not the logged in user) has the "client" role assigned. So, in the user template I set the  "show this field only if" field to "roles=client", for those fields. Now, when I assign the role to the user, the fields are showing correctly (and they hide when I remove the role). But when I set a value and save the page, the fields are not saving any data. But if I change the condition to "roles!=agent" (or I totally remove it), the fields behave as usual, saving the data correctly.

    Is this a known limitation, or am I doing something wrong?

    Thank you!

×
×
  • Create New...