Jump to content

LostKobrakai

PW-Moderators
  • Posts

    4,956
  • Joined

  • Last visited

  • Days Won

    100

Everything posted by LostKobrakai

  1. You can add pages via the "new" action on the pages in the page tree. The "add new" page/button are only shortcuts for pages to be created in predefined locations.
  2. The only difference between a module and a normal php class (besides the content) is the file extension and that classname and filename do need to match.
  3. Is module 2 autoloaded and started before you trigger register in module 1?
  4. There are various different maps api's, so it might not be the one for the javascript map. On topic: You can store the key in any place you can exclude from source control, which is readable by php. The most common ones are probably .env files/ENV variables, or a config-something.php, which you include in your main config.php.
  5. I think this might not be a bug, but even intended. It seems pages are returned without output formatting being enabled, which results in the behaviour you're seeing. Iirc bootstrapping processwire will do the same, but I'm not 100% certain on that. If you want your field settings to be respected call ->setOutputFormatting(true) on the page obj.
  6. As you've already found nico's textformatter you could also use a:not(.external) to get all internal links.
  7. ProcessWire's core permission system currently falls short as soon as permissions need to be dynamic, e.g. if a user is part of a team or something like that. Basically everywhere were you cannot create a static role or permission per case. The dynamic roles module does help a bit, as you can dynamically assign those roles, but it's still one dynamic role per team (to stay with the above example). The optimal case would be to be able to have a single dynamic role, which would work like this: "If user is part of a team XY then give access to pages owned by team XY", where XY would be dynamically adjusted and not static.
  8. Keep in mind that the find() in your example is only in-memory filtering. It cannot find additional pages.
  9. The images field by default does return a list of images and you cannot call size() on a list, but only on a single image. By using the settings of the field you can alter that behavior to only return a single image directly.
  10. @diogo That's not true, it won't work without curly braces, but it does with them. class Greeter{ public function greet() { return 'Hi!'; } } $greeter = new Greeter; echo "Trigger greeter: {$greeter->greet()}"; // Trigger greeter: Hi! @bbeer If you're not sure what you can do with a field, just var_dump($page->field) and it'll tell you what type the field does return. Only objects can give you the possibility to further customize the output via $page->field() or $page->field->someMethod(). A Datetime field will only return an integer or string.
  11. May I ask, where you got this code? $event->zeit is neither a function, nor a object you could call methods on. It's either a timestamp (integer) or a formatted string. I'm using this hook in my ready.php to have something a bit like you wanted to use: $wire->addHook("Page::getDate", function(HookEvent $event){ $page = $event->object; $fieldName = $event->arguments(0); $dateFormat = $event->arguments(1); $empty = $event->arguments(2) ?: ''; $field = $page->fields->get($fieldName); if(($field instanceof Field && $field->type == "FieldtypeDatetime") || $fieldName == "created" || $fieldName == "modified"){ $function = strpos($dateFormat, "%") !== false ? 'strftime' : 'date'; $raw = $page->getUnformatted($fieldName); return $event->return = $raw ? $function($dateFormat, $raw) : $empty; } }); It allows you to use this on datetime fields, no matter of the field settings: // date() syntax // => 04.02.2016 $page->getDate('zeit', 'd.m.Y'); // strftime syntax // => 4 Februar 2016 $page->getDate('zeit', '%e %B %Y'); // empty field value // => Nicht terminiert. $page->getDate('empty_zeit', '%e %B %Y', 'Nicht terminiert.'); // invalid field // => null $page->getDate('ziet', 'd.m.Y');
  12. Yeah the initial superusers id is hardcoded in the config, so you can't accidentally remove your own access rights.
  13. The Modules section does only show up for superusers no matter what you do. Setup will only show those modules, where you explicitly gave the admin role a permission for (otherwise it's hidden). And Access depends on if admin does have the 'user-admin' permission.
  14. $wire->addHook('Page::getLanguageJson', function(HookEvent $event) { $field = $event->arguments(0); $json = []; foreach($page->getLanguages() as $lang){ $json["$lang->id"] = $page->getLanguageValue($lang, $field); } $event->return = json_encode($json); });
  15. Languages are not necessarily stored as json structure, but you can build it yourself using the functions you can see here under Language: https://processwire.com/api/ref/page/
  16. Do you use $page->viewable() somewhere? It'll be false when using my method.
  17. Rename your post.php to _post.php and instead of $post->render() use wireRenderFile("_post", ['page' => $post]). This way processwire doesn't automatically recognise that post does have a template file and therefore throws a 404 for those pages.
  18. But it's a trouble you won't find a way around when trying to containerize/horizontally scale just about anything. You need to centralize logs, you need to centralize (server-side) sessions or don't use them. If it's worth depends on how big your need actually is to scale horizontally over multiple machines.
  19. I think the cache wouldn't need to necessarily live outside the container, for logs I'd rather hook WireLog / Wire::trackExceptions and sending messages to a 3rd party service instead of trying to shoehorn external paths onto $config. Sessions could simply be SessionHandlerDB or a redis session handler via php conf.
  20. I'd imagine it should work like this: $this->add(array( // Text field: greeting array( 'name' => 'greeting', // name of field 'type' => 'text', // type of field (any Inputfield module name) 'label' => $this->_('Hello Greeting'), // field label 'description' => $this->_('What would you like to say to people using this module?'), 'required' => true, 'value' => $this->_('A very happy hello world to you.'), // default value ), // Radio buttons: greetingType array( 'name' => 'fs', 'type' => 'fieldset', 'children' => array( array( 'name' => 'greeting', // name of field 'type' => 'text', // type of field (any Inputfield module name) 'label' => $this->_('Hello Greeting'), // field label 'description' => $this->_('What would you like to say to people using this module?'), 'required' => true, 'value' => $this->_('A very happy hello world to you.'), // default value ), ) ) ));
  21. I think this is only possible with ListerPro, where each lister is configurable.
  22. I'd expect some kind of memory leak in the compiler code, which is (at least partly) managed by the WireFileTools class. Maybe it's trying to hard to exclude your no-longer existing path you want to exclude.
  23. Then what about installing https://github.com/somatonic/ClearCacheAdmin and using that after you finished editing templates.
×
×
  • Create New...