Jump to content

toni

Members
  • Posts

    60
  • Joined

  • Last visited

Everything posted by toni

  1. Hi Andreas, Thank you so much! This was exactly the answer I hoped to hear! Best, Toni
  2. Hi Community, I hope this very basic hasn't been asked before. As with processwires repeater fields Wordpress has the option to add unlimited content items to an article. The difference is, with processwire repeater field authors can add a defined set of inputs fields. For example ten headline and body items. With Wordpress I can do the same (see screenshot below), but the User can choose which content/input type should be added. So instead of adding a bunch of headline and body fields, authors are free to choose for example a headline followed by an image gallery followed by an article Text followed by an image description … Is it possible to do something similar with processwire repeaters (or an other field type) that allows authors to "build" their needed content structure (without creating a new template that definies the exact fields)? Thanks for your help, Toni
  3. @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.
  4. 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!!
  5. 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
  6. 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'; }); } ...
  7. 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
  8. Ah nice, thanks Zeka. This clears things up!
  9. 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
  10. @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?
  11. mhhhh I've now just required_once class MarkupPwpswpGalleryFlex which solved it. But strange where this suddenly came from.
  12. 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!
  13. @kongondo peng! indeed! just whitelisted your mail ;)) I will try what you suggest and come back. Thanks!
  14. @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
  15. @Pierre-Luc Even if this issue is from 2015. Did you give Postgres/Postgis a try? What did you end up with?
  16. great anser @MoritzLost . Thanks! I will give it a try!
  17. Hi! I've a nested page tree looking like: I know like to pull articles of "aktuell = $page" by there sort order: $articles = $pages->find("has_parent=$page, template=event, limit=50, sort=sort, hide_in_programm=0") The strange thing is the page over13 – which – reflections on … which is sorted over this house is not a… home appears sorted under the later in $articles. In other words parent articles are not sorted over their children (while sorting of their childs is correct) and parent articles are in different order as in backend. My guess is I do experience a result what the docs warn for: But note that if the results have multiple parents, the resulting order isn't likely to be that useful. https://processwire.com/docs/selectors/#sort I think one way to work around this is to check each child of the ultimate parent "aktuell" for children and if they exist continue the loop. As this would require heavy changes to my templates my question is: Is there another way to pull out all parent and children of "aktuell" in correct order and one shot? Thanks for your help, Toni
  18. Dear @adrian sorry for noise. With some rubber duck debugging ... it was a typo. Shame on me ;(
  19. hi @adrian. mhhh yep this is what I did so there must be something else wrong ?
  20. Hi, I have persons using template person. I have events linking to persons using a template event. By now on a person detail page I'm looking for events like: $page->references() and in my loop I'm checking if the item has template "event" {if $item->template == "event"} smarty ? Is it possible to do this in one step? ~ ->references('template=event') I must admit I do not really got the idea of $field. Thanks!
  21. super great! thanks a lot for your help @adrian!
  22. Hi all, I'm trying to get children of a page not matter if hidden or not. This is how I do: $media_tags = $pages->get("template=fundus-index,include=all")->children("sort=title"); The children I'm looking for name 'Video,Bilder,Audio, Text' (as screenshot attached shows). The moment I uncheck the 'hidden' attribute of let's say video it's showing in my search. Can one kindly shade light into what I am doing wrong with ->get() thanks!
×
×
  • Create New...