Jump to content

owzim

PW-Moderators
  • Posts

    490
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by owzim

  1. This is how I've done it, hooks to the rescue. Clean.

    $this->addHookProperty('Language::code', function(HookEvent $event) {
        $lang = $event->object;
        $event->return = $lang->name === 'default' ? 'en' : $lang->name;
    });

    So now you can access it as a property of languages.

    $user->language->code;
    • Like 5
  2. On 1/3/2018 at 3:30 PM, bernhard said:

    hi @owzim i want to include your module in my kickstart module and found this issue on the uikit admin theme (full width font size input), would be great to get a fix for it :) thanks

    ace.thumb.png.f5c687d29961d964bf7677baef5d219c.png

    Hi, unfortunately I currently have little resources for that. You are welcome to open a PR though.

  3. 3 minutes ago, abdus said:

    If you want to use $page->render(), then $page has to have a template file, but if a page is viewable (i.e. has a template file) you won't get 404 error. I'm not sure you can have both.

    If you want to use same template file for multiple templates, then you can set it so in template settings > File tab

    The rendering ($page->render()) is taken care of elsewhere.

  4. Just now, Robin S said:

    Instead of the hook, wouldn't it be better to set this as the "Alternate template filename" only on the templates you need it for? 

    That is also an option I thought about, but this is for a module I am creating and I don't want users of that module to jump through those hoops.

  5. Thanks,

    ProcessPageView::pageNotFound is definitely the right spot, I came up with this method, don't know if it has any access rights implications:

    public function hook_ProcessPageView_pageNotFound(HookEvent $event)
    {
        $page = $event->arguments('page');
    
        $page->template->filename = 'path/to/existing/file';
    
        if ($page->viewable()) {
            $event->return = $page->render();
            $event->replace = true;
        }
    }

    Page render actually outputs something, because I hook into it. But just not with a template file.

  6. Hi, I ran into this issue a while back and remember fixing it but haven't pushed to master. I will have to look into it. I think it might work on the dev branch, not sure though.

    Edit: yup it's fixed on the dev branch. I use it on a production site, but I appreciate any quick testing in your environments, so that I can merge it into master, if no further issues arise.

    Thanks for reporting!

    • Like 1
  7. Thanks for the update @Mike Rockett. After the update: without trailing delimiters (foo;bar) I get:

    ProcessJumplinks: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '-0001-11-30 00:00:00' for column 'date_start' at row 1

    With trailing delimiters (foo;bar;;) I get:

    Notice: Undefined index: date_end
    ProcessJumplinks: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '-0001-11-30 00:00:00' for column 'date_start' at row 1

    This only happens if I input more than one line. If it's only one line, it works. If it's only one line, both values separated by the delimiter land in the source field, destination stays empty.

    Is there a reason, why you rolled your own CSV parser instead of using str_getcsv?

  8. Hi @Mike Rockett, I can't get the CSV import on 1.5.46 to work:

    Tried:

    foo,bar
    baz,qux
    
    foo;bar
    baz;qux
    
    foo,bar,,
    baz,qux,,
    
    foo;bar;;
    baz;qux;;

    In the cases without trailing delimiters I get:

    Notice: Undefined index: source
    Notice: Undefined index: destination
    ProcessJumplinks: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '-0001-11-30 00:00:00' for column 'date_start' at row 1

    With trailing delimiters, the jumplinks are created but source is empty and destination is a string: page:1.

    I made sure, no empty lines are present.

  9. Thanks @Mike Rockett, the implicit option with {all} will suffice.

    I haven't dug too deep into all the options, but it would be great if mapping could be done without collections:

    source: project?id={someCustomField}
    dest:
    projects/{someCustomField}

    So that someCustomField would be a field of projects/ child pages, like $pages->get('/projects/')->children('someCustomField={value}');

    This way one could simply migrate the ids of the old site over.

    source: project?id={oldID}
    dest:
    projects/{oldID}

    $pages->get('/projects/')->children('oldID={id}');

     

  10. Hi @Mike Rockett, this module is awesome, thanks!

    I have this collection thing going on:

    example source: project?id=1&foo=bar

    So I set it up like this:
    source: project?id={id}&foo=bar
    dest: projects/{id|projects}

    Works!

    But, when &foo=bar is omitted this does not work:
    project?id=1

    How to make anything after id optional, I tried brackets, but it does not work.

    source: project?id={id}[anything here, but optional]

    Thanks!

  11. I have this string of options:

    option1|Option 1
    option2|Option 2
    option3|Option 3

    I add the options string like mentioned before:

    $manager = new \ProcessWire\SelectableOptionManager();
    $manager->setOptionsString($field, $options, true);

    The result is this:

    Screen Shot 2017-01-04 at 13.37.52.png

    If I add it with IDs

    1=option1|Option 1
    2=option2|Option 2
    3=option3|Option 3

    The result is this:

    Screen Shot 2017-01-04 at 13.40.45.png

    In both cases within the field settings detail tab, everything looks OK, and the preview shows the expected output:

    Screen Shot 2017-01-04 at 14.15.45.png

     

    Also: Changing the override argument to false, does not affect this behavior.

    In the database, everything looks fine:

    Screen Shot 2017-01-04 at 14.33.01.png

     

    Debugging $inputfield->options in FieldtypeOptions:getInputfield, the options array looks fine as it should: Three items with an id, value and title.

    This is VERY weird:

    If I replace the return value in FieldtypeOptions:getInputfield

    // original
    return $inputfield;
    
    // replace
    $fs = $this->modules->get('InputfieldFieldset');
    $fs->add($inputfield);
    return $fs;

    I get the correct output, in the given Fieldset:

    Screen Shot 2017-01-04 at 14.50.04.png

    This suggests that the misbehavior is happening somewhere else?

     

    If I create it via admin, everything works as expected, only the titles show.

    Any help? Thanks!

     

  12. This is what the editor sees:

    Screen Shot 2016-12-17 at 23.55.35.png

     

    This is what I see:

    Screen Shot 2016-12-17 at 23.55.48.png

     

    There just one thing different about Standort (Location) and Veranstaltung (Event) compared to Bezirk (District):

    Both can be in multiple places within the site structure, so that one has to select a parent before creating (this is where only I get to):

    Screen Shot 2016-12-17 at 23.57.52.png

    i.e. all locations have Calendars, which hold the Events.

    Access management is set to No to all of these.

    ProcessWire 2.7.2

    Thanks!

     

     

  13. Hi,

    I tried to disable it in my site/modules/InputfieldCKEditor/config-body.js

    CKEDITOR.editorConfig = function( config ) {
        config.plugins.image = 0;
        config.plugins.pwimage = 0;
        console.log('CKEDITOR.editorConfig executed');
    };

    I made sure that the function is executed by that console.log call, but the image button is still there.

    Screen Shot 2016-12-17 at 16.29.12.png

    Thanks!

     

    Edit:

    Removing the plugin like suggested here, doesn't do it either:

    CKEDITOR.editorConfig = function( config ) {
        config.removePlugins = 'image,pwimage';
        // OR: config.removePlugins = 'pwimage';
        // OR: config.removePlugins = 'image';
    };
×
×
  • Create New...