Search

this is still a fork right, it's not included in the official Git repo?

Sorry, when I meant fork I meant branch. I've merged the frontendpage branch into the master branch, so the master is now the most up to date.

Re: filter, good to know the docs are wrong and I'm not crazy :)

I removed the sort param but cannot get order=rand to work. I've put back the caching to 1 minute but results remain the same (getting 2 entries out of 4). The same 2 entries in the same order…

What caching are you using? Does it work when caching is disabled? Do you definitely have more than two possible matching entries?

Nick, I meant the 'Update cached result every n Min.' setting in the Api DS editor.

I'm quite sure that I have more than 2 possible matching entries. My guess is that the random ordering works but it is some kind of caching issue. Is there a way to disable caching completely? I have disabled my browser cache, I am not using a caching extension.

UPDATE It appears the random ordering is working! I've reloaded the page after some time and now I get a different result. Seems the caching was quite persistent…

One other thing I noticed, that might have to do with your latest work concerning the class.frontendpage.php is that with every reload of my page a couple of error lines are written to the main error log:

30 March 2011 11:37 > UNKNOWN: The page you requested does not exist in file /my/site/symphony/lib/toolkit/class.frontendpage.php on line 303

The page renders fine (apart from the random issues) but my guess is that there's something not quite right…

Just to be complete I'll mention that, at the moment, I'm also having some permission issues with accessing JIT images on my 'global' site (although I've added the domain to the Trusted sites).

For debugging it'd be easiest to use the REST API URLs directly on your master site, rather than through the Dynamic XML data sources (which are cached) on your localised sites.

I'll look into the error log, thanks.

@Nick do you have any idea what that error could be? The site/API runs fine but the error is filling up my main error log :)

Hi Nick. Sorry to bother you again but I am really enjoying the REST API. It's wonderful.

I was wondering if it would be possible to have a little more complex filters.

E.g. I currently need to filter a Person section on a country field (i.e. all People from Holland). The trouble is, in my Page I have a parameter $iso-3166-code (/people/$iso-code/) but the Country Section attached (by SBL) to the Person section actually 'outputs' the Country name, not it's iso-code…

I would love to be able to do something like …&filter[country/iso-3166-code/@handle]=nl… (XPATH) or …&filter[country.iso-3166-code]=nl… (DOT) etc. This is probably pushing it but no harm in asking, right?

Another way would, obviously, be to construct/add/inject a parameter. The only thing I can think of would be a custom DS…

Thanks!

PS: any idea about that 303 error as described above?

I'm afraid that is beyond the REST API's implementation. What you're talking about is the ability to write XPath expressions in the URL field of a Dynamic XML Data Source, which is firmly in the Symphony core.

If I understand you correctly, you have a page:

/people/:country

Which look like:

/people/nl/

Your People section is linked to a Country section (Select Box Link) but the linked value is "Netherlands" and not "nl"?

If you store both the abbreviation ("nl") and the full name ("Netherlands") in the Country section, then filter the section on the Abbreviation text field using the URL Parameter value nl, to return just the one country entry. Set the country full name as the Parameter Output, so you should end up with a parameter $ds-country with a value "Netherlands".

You might then be able to use this in your dynamic XML data source URL:

http://domain.com/.../?filter[country]={$ds-country}

I'm not sure if this works though. I know you can use "core" parameters such as {$root} in the URL, but I don't know if output parameters from other data sources work.

But if I'm understanding this correct, this is certainly a Symphony question and not REST API.

PS: any idea about that 303 error as described above?

Not sure. What version of Symphony and REST API do you have? Do you definitely have a Symphony page set up as the "index" type?

Hi Nick, thanks.

Set the country full name as the Parameter OutputParameter Output

Yeah, that would be neat. Except that both my People and Country Sections live on the other site and I use the REST API to fetch both :) The Dynamic XML (for People in this case) does not allow for a ds-output param :-/

Re: the error I do have a (home) page set with index type. It really does seem to relate to the Rest API extension (awesome as that is).

I just ran into a bug/error of which I'm not completely sure it is related to the REST API extension. Nick, if this belongs in another thread I'm sorry to bother you.

The issue is with the sort param in a Dynamic DS (REST API). I am trying to sort a section on a Subsection Managed field ('country'):

http://site.dev/symphony/api/entries/foo?auth-token=1234ab&filter[visible]=Yes&fields=name,country,type&sort=country&order=asc&language-code=nl

When I do Symphony throws the following error:

MySQL Error (1054): Unknown column 'ed.value' in 'order clause' in query "SELECT SQL_CACHE `e`.id, `e`.section_id, e.`author_id`, UNIX_TIMESTAMP(e.`creation_date`) AS `creation_date` FROM `sym_entries` AS `e` LEFT JOIN `sym_entries_data_70` AS t70_1 ON (e.id = t70_1.entry_id) LEFT OUTER JOIN `sym_entries_data_69` AS `ed` ON (`e`.`id` = `ed`.`entry_id`) WHERE 1 AND `e`.`section_id` = '8' AND (t70_1.value IN ('Yes')) ORDER BY `ed`.`value` ASC LIMIT 0, 20"

Sorting on another field works fine. Is this a SSM issue or an issue with the REST API? I feel it could have something todo with this bug.

Yep this won't be anything to do with the REST API, since all this extension does is create a data source with the parameters you supply in the URL, and returns the XML.

Nick,

This question is slightly related to your API extension. Recently, I updated the mass upload utility, but in order to add the entries I posted to a custom page I made, which essentially duplicates the functionality in content.publish.php (actionNew()); you can see it here if you wish.

In your extension, from what I can tell, you create a custom event to deal with the POSTing, then load the custom event, process it, and send the output to wherever.

I've never really thought about doing it this way, but is it really that simple? I could create a custom event, load it on my API page, process it and parse the output?

I did it for maintainability and compatibility — we're all comfortable with the syntax of posting to an event, so I just use a normal event that is customised to have a dynamic section ID, nothing more. It's that simple! REST API works just like a frontend page, so it has a DS and event attached to it.

I could create a custom event, load it on my API page, process it and parse the output?

Not sure what you mean by "my API page" — you can't attach more events/data sources to the REST API itself. Are you talking about using this method in the backend? If so, it might just work. I've never tried executing an event within the context of an AdministrationPage rather than FrontendPage but I can see no reason for it not to work. You should be able to include the class (your custom event) and call its load() method.

By "my API page" I meant the page I created for the mass upload extension. But yes, I was using this in the backend because I had to POST to something in the backend to create an entry.

Indeed, it does work in an AdministrationPage. I was able to use an already created event, and just push the POST data through there, and voila, I no longer have to duplicate the Symphony Core. It was as simple as creating a custom event, and $event = new Event_Mass_Upload_Utility_Entry(Frontend::instance(), array()); $event->load(); I will also be using your XMLtoArray class to make it easier to parse :) I didn't want to require this API extension to use the Mass Upload extension because it'd be a headache for most people I'd assume.

Thanks a ton Nick!

I can't get the extension to work! I copied the files to the extensions dir. and enabled it from the System > Extensions page in Symphony.

When i try to access this address:

http://localhost:8888/symphony-2/symphony/api/authors

it changes to that:

http://localhost:8888/symphony-2/symphony-2/extensions/rest_api/handler.php/?url=/authors

And i see a 404 error page. Even when using the auth_token (i enabled the remote login)

http://localhost:8888/symphony-2/symphony/api/authors/?auth-token=123XXX

it turns: http://localhost:8888/symphony-2/symphony-2/extensions/rest_api/handler.php/?url=/authors/&auth-token=123XXX

Could you pastie the contents of your .htaccess file please?

Hmm, perhaps my code that adds the lines to the htaccess doesn't like Symphony being in a sub folder. Maybe change the REST API line to:

RewriteRule ^symphony/api(/(.*/?))?$ extensions/rest_api/handler.php?url=$1&%{QUERY_STRING}  [NC,L]

i.e. remove symphony-2/.

Edit: looks like when I post the line into the forum it removes some slashes. Try this:

http://pastie.org/1976997

Thanks Nick! It works :D

Great stuff! This is a bug with my code that creates htaccess rules then. Noted.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details