Jump to content

toni

Members
  • Posts

    49
  • Joined

  • Last visited

Recent Profile Visitors

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

toni's Achievements

Jr. Member

Jr. Member (3/6)

18

Reputation

  1. @wbmnfktr thanks for starting this topic, very interesting! After reading all replies I think I get your point. I mostly develop with Django (Python) where DRF gives a powerful standardized API centered around models. Still, as you said, while working with other systems I always miss processwire for it's flexibility ;) From what I understood other systems include a REST API out of the box (more or less) where processwire "forces you to write some lines of codes" … and I guess that is the strength of processwire. It does not force you into a one fits all solution. My two cents: For an upcoming project I tested different solutions. With AppApi indeed I got resonable results in not 2 but 15 minutes. With JWT included, nice! (thanks @Sebi) For smaller needs URL hooks … for bigger needs –without auth– PageQueryBoss … –with auth– appAPI, is my way to go. But yes +1 for a core integrated solution that publishs pages based on standards . Doing so it would even be easy to get a clear, understandable and standardized API Documentation.
  2. Hi @Sebi thanks for your reply. I've thought about it again. The website where I'm working on will be fully headless. The URLs mappings are then handled by a vuejs frontend. So in this case it does not matter much if it's controlled by a var or URL segement (Forgot about this when asking :roll_eyes:). The requirements of the site are still a bit unclear but it looks I do not need the c-u-d of C-R-U-D. This is why I most likely will just build a small API with the new URL Hooks. This is how I would handle the language there (Quick and dirty example): $this->wire()->addHook('/{lang}/api/books', function($event) { $books = $this->pages->find("template=books"); $response_arr = []; foreach ($books as $book){ $current_page = []; $current_page['title'] = $book->getLanguageValue($event->lang, 'title'); $current_page['author'] = $book->getLanguageValue($event->lang, 'author'); // ... array_push($res, $current_page); } header('Content-Type: application/json; charset=utf-8'); echo json_encode( $response_arr ); }); But it's great to have your Extension available in case there is some "heavier" API to build ;)) @Jukka Nice to hear!!
  3. thank you so much @kongondo now it is clear!
  4. Ok got thanks a lot to both of you, I've tested with the autoload bool but did not know that it does not work with backend modules. Am I right that backend modules are defined by extending Process where 'satelite autoload modules' extend Module? Thanks a lot for your patience and help! – T
  5. Wow this is fantastic! @kongondo May I ask, do you know of an example where I can see how to correctly set a hook like I've tried within the init method but it does not what I would expect: class ProcessMyModule extends Process { public function init() { $wire->addHook('/hello/world', function($event) { return 'Hello World'; }); } ...
  6. Hi, sorry if this might be a super easy one but I couldn't find and answer in https://github.com/processwire/processwire/blob/master/wire/core/Process.php In a custom backend module I can just return html that gets rendered. How would I create a json endpoint that can be used from other pages of my module? This is what I've tried public function ___executejson() { return json_encode(array("a"=>"b")); } And from I an other page in frontend fetch('http://localhost/pw-dev/processwire/test-list/json') .then(response => response.json()) .then(commits => console.log(commits)); Obviously this is the wrong way. Thanks a lot for your hints Toni
  7. Ah nice, thanks Zeka. This clears things up!
  8. Hi experts, as my module is growing, I'm looking for ways to split up my code. I've seen instead of returning markup from the main module AppApi has excluded those to a views folder. https://github.com/Sebiworld/AppApi/tree/main/views Can someone explain how this is wired together, how each __execute* knows what to render? Thanks a lot for your help – Toni
  9. @sebi @Jukka Sorry I cannot help with pro cache. But caching with memcache or even flat files might be a start? This is not tested at all but just to outline the idea: public static function getUser($data) { $data = AppApiHelper::checkAndSanitizeRequiredParameters($data, ['id|int']); $response = new \StdClass(); $user = wire('users')->get($data->id); if(!$user->id) throw new \Exception('User not found', 404); $response->id = $user->id; $response->name = $user->name; // cache in a file $cache_file_name = hash('sha256', $data->id); $cache_path = "cache_path/$cache_file_name"; if(!is_file($cache_path)){ // the cache file does not exist let's add it file_put_contents( $cache_path, json_encode($response) ); } else { // the cache exists, let's read it and return the data $response = file_get_contents($cache_path); return $response; } // the cache does not exist let's return it form the std class return $response; } Of course it would be MUCH better to use ProCache or memcache. @sebi Have you tested multilanguage? I wonder what would be the best option. A) To have namend routes like /api/test/ /apit/en/test that map to the same function, which checks for the /en/ part or B) handle the language switch by a get ver /api/test/ /apit/test?lang=en that controlls the language?
  10. mhhhh I've now just required_once class MarkupPwpswpGalleryFlex which solved it. But strange where this suddenly came from.
  11. Hi all, I'm fighting with a strange problem. On a processwire installation I've tried to install https://processwire.com/modules/process-redirects/ which ended in a json error. A refresh quitted with an error 500. Even after deleting the redirects module via FTP the error 500 persisted. After enabling debug in settings following output is shown: Strange as the Gallery module worked for years without problems. What I do not understand is why the class cannot be found. it is there 😕 This is how it's called in `MarkupPwpswpGalleryLegacy.module` `class MarkupPwpswpGalleryFlex extends MarkupPwpswpGallery implements Module {` and on the same level in `MarkupPwpswpGallery.module` `class MarkupPwpswpGallery extends WireData implements Module {` My guess is it has something todo with the php 7.0 version the server runs with and namespaces (did not change between module installations). To get rid of this nasty situation I've just tried to reinstall the gallery but this one fails as requirement 7.0 >= 5.6PHP is not met (why? 7 is bigger as 5.6?) Anyways any tipp to get it running again is much appreciated!
  12. @kongondo peng! indeed! just whitelisted your mail ;)) I will try what you suggest and come back. Thanks!
  13. @kongondo I’ve just bought media manager and installed it on a fresh pw instance. Unfortunately an upload does not appear (small logo image) and no error is thrown. https://www.dropbox.com/s/xhwie4vert5li5b/mm.mov?dl=0 The User is a super user. Any idea what could go wrong? Thanks, Toni
  14. @Pierre-Luc Even if this issue is from 2015. Did you give Postgres/Postgis a try? What did you end up with?
×
×
  • Create New...