Jump to content

pwFoo

Members
  • Content Count

    694
  • Joined

  • Last visited

Community Reputation

287 Excellent

About pwFoo

  • Rank
    Hero Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

6,989 profile views
  1. Hi @stikki, thanks for take a look into it. Additional / instead of GUI field selection I use a array to filter the fields to convert / output. At the moment I have some other topics and can't work & play with PW. My code seems to work for my needs and I like the multidimensional filter array to filter sub-pages and wirearray / pagearray / image fields too. So if you could implement it a nice and easy way it would be fine. I like to have one module for one job and not some similar modules
  2. UPDATE I can't test self signed certificate to work because WireHttp don't respect given connection port? The following url: https://127.0.0.1:10000/api/... Will return that error message: 2: fsockopen(): unable to connect to ssl://127.0.0.1:443 (Operation timed out), 110: Operation timed out Looks like port 10000 is changed to default https port 443 by WireHttp? php curl is installed and also tried to force it with option 'use' (if it falls back to another method). Need it solved or drop WireHttp for that use
  3. I won't enable UrlSegments for each template, but have a autoload module with should react based on path / urlSegments. Don't like the way to do it with query string. So allow one urlSegment by name (string) would be nice without the need to activate urlSegments at all.
  4. How to enable urlSegments runtime instead of persistent in template settings? And where to be loaded before the current page returns a 404 error? https://processwire.com/docs/front-end/how-to-use-url-segments/#how-do-you-enable-url-segments
  5. Hi, I try to convert a rest api client to WireHttp and seaching for the option? verify=false // curl --insecure, self signed certificates Haven't found such a option in api documentation or source code (quick search...). Are self signed certificates supported by WireHttp?
  6. Hi @gmclelland, strange... Image isn't broken here, but I changed the post a short time later because I fixed it... The changes are gone, just the "solved" tag is there. Problem was that the page was moved to trash and so parent wasn't home ("/") anymore. So different permissions and trashable == false was "fine". I moved the page back and all looks good.
  7. Thanks! Tested the permissions, but have a problem with permissions or understanding how it works. "page-create" is activated for "basic-page". Don't know if needed... just activated to test... My role has the following permissions set. Tried to add a page to home ("/") with template ""basic-page". Do some permission check before... Page owner: test Current user: test Current user roles: guest, writer Current user permissions: page-view, page-edit // --> missing allowed permissions "page-edit-created, page-edit-trash-created" Addable (parent): 0 // --> 1 (allowed to add child to "/") Addable (child to page): 0 // --> OK, add to parent should work, not add children to that page Editable: 1 // --> OK, but by page-edit or as should page-edit-created??? Trashable: 0 // --> 1 (allowed by page-edit-trash-created) Deleteable: 0 // --> OK, just allowed to trash the page... User test has role "writer" (screenshot with permissions), is page owner(!). Added expected values to the permission check output above. Checked by addable(), editable(), trashable() and deleteable() methods.
  8. Hi, I try to add page-edit-own and page-delete-own permissions, but it's strange... If a add the custom permissions it looks like both are children of page-edit respectively page-delete. I played with added / revoked permissions, but I can't get it work, that a user of a role just can delete own content. First the user can't delete any content and now the user can delete own and foreign pages Is there a tutorial to learn more about the PW permissions? Or do I have to rename the permissions to page-own-edit and page-own-delete to be independent from page-edit and page-delete?
  9. Module method name create() was the problem... Changed to add() to have the same naming than permissions page-* and it works fine!
  10. I tried to add a new page with $pages->add() with a custom method inside of a module. It looks like the method is called each page load (as should) and also if the backend page tree is loaded / refreshed (bug??)? public function create($template, $parent, Array $data = array(), $name = false) { $name = wire('sanitizer')->pageName($name ? $name : $data['title']); $obj = wire('pages')->add($template, $parent, $name, $data); return $obj; } called inside of home page ("/"): $api->create('basic-page', '/', array('title' => 'ApiCreatedTest1')); Works fine. Load it twice (create duplicate page) results in an error. But without "/" requested the page gets created if I view the backend?! Checked it by delete the page, check the page tree again and it looks fine. But if I reload the backend page the page appears again. So backend page tree load executes the home page ("/") and create the page? Is it a bug or I'm missing anything...?
  11. I do some tests with custom code because I need a simple way to set (recursive) fields to view for different page types and fields. public function ___WireToArray($obj, $filter = array()) { $values = array(); foreach ($obj AS $item) { $array = array(); foreach ($filter AS $key => $val) { if (is_array($val)) { $array[$key] = WireToArray($item->$key, $val); } else { $string = (string)$item->$val; $array[$val] = strpos($string, '|') ? explode('|', $string) : $string; } } $values[] = $array; } return $values; } I built a module which used that way: $userFilter = array('id', 'name', 'email', 'roles' => array('id', 'name')); $pages->find('template=user')->toJSON($userFilter, JSON_PRETTY_PRINT) Output [ { "id": "40", "name": "guest", "email": "", "roles": [ { "id": "37", "name": "guest" } ] }, { "id": "41", "name": "admin", "email": "andre.hoeg@gmail.com", "roles": [ { "id": "37", "name": "guest" }, { "id": "38", "name": "superuser" } ] } ] Example with images $wa = $pages->find('template=basic-page'); $filter = array( 'id', 'name', 'images' => array('url', 'width', 'height'), 'files' => array('url', 'name', 'filesize'), 'pageref', ); Output [ { "id": "1016", "name": "test1", "images": [ { "url": "\/site\/assets\/files\/1016\/dscn2585.jpg", "width": "4608", "height": "3456" }, { "url": "\/site\/assets\/files\/1016\/dscn2823.jpg", "width": "4608", "height": "3456" } ], "files": [ { "url": "\/site\/assets\/files\/1016\/aufstellung_und_taktische_aufgaben.pdf", "name": "aufstellung_und_taktische_aufgaben.pdf", "filesize": "68628" }, { "url": "\/site\/assets\/files\/1016\/1und1_leistungsbeschreibung_mobilfunk.pdf", "name": "1und1_leistungsbeschreibung_mobilfunk.pdf", "filesize": "207816" } ], "pageref": [ "1017", "27" ] }, { "id": "1017", "name": "test2", "images": [ { "url": "\/site\/assets\/files\/1017\/dscn2813.jpg", "width": "4608", "height": "3456" } ], "files": [], "pageref": "" } ] Because Pageimages and Pagefiles are based on WireArray it's possible to get just images as JSON $img = $page->images; $imgFilter = array('url', 'name', 'filesize', 'width'); $img->toJSON($imgFilter); Output [ { "url": "\/site\/assets\/files\/1016\/dscn2585.jpg", "name": "dscn2585.jpg", "filesize": "4085826", "width": "4608" }, { "url": "\/site\/assets\/files\/1016\/dscn2823.jpg", "name": "dscn2823.jpg", "filesize": "3225062", "width": "4608" } ]
  12. I think I'll move the requests to a module with a own "/api" page working with urlSegments. Page template just perform a "normal" page load (PW template = controller, separated view). Module use urlSegments to route requests as needed.
  13. Yes, similar to that. PW template could bei used AS controller / return json, but requests for HTML / views should be redirected to another file (for example "./site/template/views/*"). But I don't know how to separate both. Easiest way should be urlSegments, but another way would be nice. Both requests could be ajax.
  14. I try to separate the requests for a template file (html) and the data / json and searching for a way to do it without enable url segments for each template (or enable by hook / api runtime). I'll build a autoload module and the request routing should be done there to send a template / view / html file OR execute the "controller" (page / PW template file) without the need of a switch case / if else inside of the page template file... Any idea how to do it? UrlSegments would work with for example first segment "template" or "view" to request the html file, but would be nice to do it without the use of segments (maybe needed for other things and default disabled). Any PW API way to do it by request content type, urlSegment / QueryString or anything else hook? Or a special "api" page which use urlSegments, load the page given by urlSegment and verify request type (html or json) by compare page path with (loaded page path)?
  15. Thank's, I'll test and compare the three hooks
×
×
  • Create New...