apeisa Posted November 22, 2013 Share Posted November 22, 2013 I think the latter would be preferred method to go (language specified in the request, otherwise default returned). Link to comment Share on other sites More sharing options...
bcartier Posted November 22, 2013 Share Posted November 22, 2013 I see what you mean apeisa, but in some cases, you might want to get all the data in a single call, no? Link to comment Share on other sites More sharing options...
apeisa Posted November 22, 2013 Share Posted November 22, 2013 I see that as an edge case. I would prefer serving default lang as a default. Serving all languages as a one might be preferable in some cases, but then why not use some switch there &allLang=1 Link to comment Share on other sites More sharing options...
bcartier Posted November 22, 2013 Share Posted November 22, 2013 Good point - it's closer to how PW is handling languages that way. I like the idea of a lang=all for my edge case though ;-) 1 Link to comment Share on other sites More sharing options...
ryan Posted November 24, 2013 Author Share Posted November 24, 2013 I haven't tried it, but you might be able to get this module to output in different languages by combining it with the LanguageSupportPageNames module. Link to comment Share on other sites More sharing options...
landitus Posted November 25, 2013 Share Posted November 25, 2013 I'm trying out the module to use it as a web-service for a mobile app. I'm querying pages that have images and attachments and the returning JSON output lists the "basename" but no URL or any other way to find the asset. Is there something missing? Should I need to query something else? Link to comment Share on other sites More sharing options...
celfred Posted November 25, 2013 Share Posted November 25, 2013 I had the same issue and hard-coded the url pointing to the asset file (using the id and basename fields)... Actually, it seemed like a workaround to me. Getting a url from the module would be much better, but I couldn't firgure out how to do that :-( Link to comment Share on other sites More sharing options...
dragan Posted November 25, 2013 Share Posted November 25, 2013 Is there somebody with experience with the multilanguage fields in modules ? I tried to give the language as a GET var and chaging the user object language var, but no success I recently wrote a tiny little frontend template script for querying a product catalogue, to get JSON results back (i.e. not a module - have just discovered the module and this forum thread today). It's supposed to feed an iOS app, sooner or later. As expected from working with PW, it was all easy and straightforward. Since my site in querstion is also using multilang features (4 languages, PW 2.3.2 version), I simply query german language data via domain.com/de/API/?foo=bar?etc.etc. and french data with domain.com/fr/API/?foo=bar?etc.etc. But it would be relatively easy to output all four languages with the same "web service" URL, if really needed. I guess something like this should be all that's needed: $user->language = $languages->get("en"); // the following selector query will return english $user->language = $languages->get("fr"); // the following selector query will return french $user->language = $languages->get("default"); // the following selector query will return default lang. And if you only want to use ONE service page URL, and decide to just get ONE language back, simply use another GET param (〈=en) and a switch / if-else statement in your code. 1 Link to comment Share on other sites More sharing options...
dragan Posted November 25, 2013 Share Posted November 25, 2013 I'm trying out the module to use it as a web-service for a mobile app. I'm querying pages that have images and attachments and the returning JSON output lists the "basename" but no URL or any other way to find the asset. Is there something missing? Should I need to query something else? Have a look at the $config stuff here: http://cheatsheet.processwire.com/ (e.g. $config->httpHost) Link to comment Share on other sites More sharing options...
ryan Posted November 30, 2013 Author Share Posted November 30, 2013 I had the same issue and hard-coded the url pointing to the asset file (using the id and basename fields)... Actually, it seemed like a workaround to me. Getting a url from the module would be much better, but I couldn't firgure out how to do that :-( I didn't realize this aspect of the file fields output. I've put this on my to-do list for the next version of the module (actually for ProcessPageSearch, which is what this module uses). 2 Link to comment Share on other sites More sharing options...
bcartier Posted February 24, 2014 Share Posted February 24, 2014 Hi Ryan, I'm trying to use various operators in Pages Web Service, but some of the operators do not seem to be working. ^= Contains the exact word or phrase at the beginning of the field The key-value pairs using this operator are completely ignored. The [selector] part of the response only includes other key-value pairs. request: ?template=industries&title^=Tire&debug=1 response: [selector] => template=industries, limit=50 ...I tried with '%=' and it works fine: request: ?template=industries&title%=Tire&debug=1 response: [selector] => template=industries, title%=Tire, limit=50 ...also with *= works fine: request: ?template=industries&title*=Tire&debug=1 response: [selector] => template=industries, title*=Tire, limit=50 and, of course '=' works: request: ?template=industries&title=Tire Manufacturing&debug=1 response: [selector] => template=industries, title=Tire Manufacturing, limit=50 $= Contains the exact word or phrase at the end of the field The key-value pairs using this operator are completely ignored. The [selector] part of the response only includes other key-value pairs. (as above) ~= Contains all the words Always throws an error because that field name is not searchable . The ‘~’ symbol is converted to ‘_’, is considered part of the field name and not treated as an operator. request: ?template=industries&title~=Tire&debug=1 response (error): Field 'title_' is not allowed in queries ... I tried disabling the sanitizing of the field name before the error is displayed (line 189), and it then shows the error with the field name being title~ request: ?template=industries&title~=Tire&debug=1 response (error): Field 'title~' is not allowed in queries I tried looking through the module, but I'm not seeing the cause of the problem. Any help would be greatly appreciated! Thanks, -Brent Link to comment Share on other sites More sharing options...
verdeandrea Posted February 25, 2014 Share Posted February 25, 2014 Hy guys, i'm using Page Web Service module and everything is fine. I'm querying for a template that has a repeater page field in it. I get json results with the array node for the repeater field. Every child of this array has these fields from the page: - id - name - parent_id - path - template - title Is there a way to get other fields from that page? Thanks....i hope my english is clear enough. EDIT: I've the same problem with the image field. I get the basename of the image but i don't get the path, so i don't know how top put it in my page. Link to comment Share on other sites More sharing options...
Luis Posted April 27, 2014 Share Posted April 27, 2014 If you use jQuery, you could try a little workaround to display your images. Not a very elegant way, but should work for small projects. I started with a little php function to get my newsposts and generate the markup: function getNewsfeed(){ $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://example.com/service-pages/?template=news&sort=-modified&limit=5' )); $result = curl_exec($curl); curl_close($curl); $data = ''; $result = json_decode($result, true); if($result){ foreach($result[matches] as $news){ $data .='<div class="js-newsfeedentry s-newsfeedentry">'; $data .='<h3>'.$news[title].'<small class="pull-right text-muted" style="padding-top:5px">Posted : '.date("d.m.Y - H:i",$news[created]).'</small></h3>'; $data .= $news[text]; $data .='<hr />'; $data .='</div>'; } } return $data; } as you can see, I wrap the entire newspost into a div with the class "js-newsfeed". Now we iterate over all images inside this div and manipulate the img src, to match the correct url from the web-service. Inside our document ready function we grab all news images and correct the src: /* fix urls for newsfeed img */ var newsfeedimg = $('.js-newsfeed img'); newsfeedimg.each(function(){ var newimgsrc = 'http://example.com'+$(this).attr('src'); $(this).attr('src',newimgsrc); }); et voila, working images. Remember that this isn´t a very good solution because you iterate over every image in your newspost via JavaScript and you shouldn´t do this on a project with many images. 1 Link to comment Share on other sites More sharing options...
peterfoeng Posted May 15, 2014 Share Posted May 15, 2014 Hi everyone, I try to test this module and it seems it does not work when I try the examples in the service-pages page that comes with this module. I have made sure that the template field is included in the config but it comes up with this error: Error: Template 'basic-page' is not allowed in queries Not quiet sure what settings I did miss here. Here is the screenshot: Appreciate any help to solve this issue Cheers Link to comment Share on other sites More sharing options...
adrian Posted May 16, 2014 Share Posted May 16, 2014 Did you make sure that basic-pages was selected as an available template in the module config settings? Take a look at the screenshot here: http://modules.processwire.com/modules/service-pages/ 2 Link to comment Share on other sites More sharing options...
jacmaes Posted June 15, 2014 Share Posted June 15, 2014 This module works great when I'm logged in as a superuser, when when logged out, I get the following error instead of viewing the JSON output: Error: Exception: You do not have permission to execute this module - ProcessPageSearch (in /home/[...]/public_html/wire/core/Modules.php line 458) This error message was shown because you are using the command line API. Error has been logged. I'm on 2.4.3. Link to comment Share on other sites More sharing options...
adrian Posted June 15, 2014 Share Posted June 15, 2014 Hi jacmaes, I have tracked down the issue. It is definitely a bug that should be reported to Ryan on Github. There are newly added checks for module permissions around line#457 of Modules.php (https://github.com/ryancramerdesign/ProcessWire/commit/2c0762d1f346a3f01171b4f65fa97242f17fd916#diff-995c5c9ce48d4bff459f52363c6e190eR457) The module that is blocking your access is actually ProcessPageSearch, which required page-edit permissions, which of course a guest user doesn't have. If you temporarily remove the permission check, or change the ProcessPageSearch permissions to page-view, it works again (obviously this is not the appropriate solution . Once that hack is in place though, there is one other new bug: {"errors":["Field 'it' is not allowed in queries"]} This can be fixed easily by adding this line to ServicePages.module inside the loop starting at line#174 foreach($k as $name) { if($name=="it") continue; //add this line Let us know if you want us to submit an issue of Github, or if you have taken care of it. 1 Link to comment Share on other sites More sharing options...
jacmaes Posted June 15, 2014 Share Posted June 15, 2014 Thanks Adrian for looking into it and tracking down the bug. As efficient as always! You've saved me many times before. I will try your hack while Ryan gets a chance to fix this. And yes, I would appreciate it if you could open a bug report on GitHub as I'm certain that you will explain it a lot better than I possibly could. 1 Link to comment Share on other sites More sharing options...
adrian Posted June 16, 2014 Share Posted June 16, 2014 Github issue opened: https://github.com/ryancramerdesign/ProcessWire/issues/520 1 Link to comment Share on other sites More sharing options...
ryan Posted June 21, 2014 Author Share Posted June 21, 2014 Thanks guys, I have fixed that issue by adding a new getModule($key, $options) method to the Modules class that lets you retrieve a module with $options. In this case an option called 'noPermissionCheck'. The ServicePages module has been updated to use the new method (when available). Adrian, I wasn't seeing the "it" GET variable. That is a GET variable used internally by PW, but it gets removed before the request starts. So if you are seeing an "it" variable then you probably shouldn't be. At least I'm not seeing it here. I did go ahead and add that as something for ServicePages to ignore though, per your suggestion. 1 Link to comment Share on other sites More sharing options...
adrian Posted June 21, 2014 Share Posted June 21, 2014 Thanks for the fix Ryan - the noPermisionCheck should come in quite handy in other situations too As for the "it" GET variable. If I go to: http://pwtest.dev/service-pages/?name=about with the following for debugging: print_r($k);echo $_GET['it']; foreach($k as $name) { //if($name=="it") continue; I get: Array ( [0] => it ) <br /> <b>Notice</b>: Undefined index: it in <b>/Users/ajones/Sites/pwtest/site/modules/ServicePages/ServicePages.module</b> on line <b>175</b><br /> Array ( [0] => name ) <br /> <b>Notice</b>: Undefined index: it in <b>/Users/ajones/Sites/pwtest/site/modules/ServicePages/ServicePages.module</b> on line <b>175</b><br /> {"errors":["Field 'it' is not allowed in queries"]} so $_GET['it'] doesn't exist, but it is part of the $k array. Link to comment Share on other sites More sharing options...
renobird Posted July 14, 2014 Share Posted July 14, 2014 I need to generate a selector like this: template=user, roles=faculty, roles=music Where the result is users with the "faculty" role AND the "music" role. Is that possible? I tried: ?template=user&roles=faculty&roles=music but only the last roles query seems to be included in the selector. Link to comment Share on other sites More sharing options...
Christian Posted July 18, 2014 Share Posted July 18, 2014 We are currently using Service Pages to pull data and serve it on our front end. We can also remove null values by iterating to each fields and prepare new set of data with the formatted data we need. All is fine as of now, but it seems that a performance issue could occured if all available fields must return before formatting it. Is there any option to remove null fields via settings? Link to comment Share on other sites More sharing options...
nikoka Posted September 11, 2014 Share Posted September 11, 2014 Hi guys, hadn't tried this before, seems to be working great, just a couple of questions: My query works as it should, but there's bunch of fields that include letters like Å, Ä and Ö and these letters are encoded, a title like "Riihimäki" is encoded to "Riihim\u00c5boki", how can I avoid this and just have the values as is? Further on, the path value (a relative path) is added by default, any chance of overriding or adding to it, so I could get the absolute/full path for each page? Link to comment Share on other sites More sharing options...
mrjasongorman Posted September 11, 2014 Share Posted September 11, 2014 I'm having a problem with the Web Service API. if i use a browser to hit the url http://localhost:8888/api/?id=1437 for example, it returns fine, with 1 match in the matches array. However if i use CURL or hit the url from within PHP it returns but the matches array is empty. Any help would be great. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now