Search

Hey guys. I need help solving of few things.

Question 1

For the review section, instead of having URLs like {$root}/reviews/movies/some-long-url-entry-title-here I have {$root}/reviews/movies/{$id} where the ID is the ID of the movie entry. My problem is that if someone manually enters an ID of a review entry that does not exist, it shows all the comments from each individual review entry where the full review entry should be. Is there a way to check if the ID is valid for that section? Or is there way to forward to a page not found when this happens?

Question 2

I have noticed that when I submit a comment, everything in the textarea’s remain there. But when I refresh the page just after I submitted a comment, it resubmits the same comment over again so that there are two copies of the same comment. How do I fix this?

Question 3

Regarding external JIT image manipulation, is this correct format? {$root}/image/1/150/0/1/img3.flickr.com/path/to/some/long/url/here.jpg

I’m asking because I am importing my image feed from visualizeus.com.In the XML, It gives the complete URL of the image. Assuming I read the JIT image docs right, I need to exclude the http:// from the external image URL. How would I do this?

I have two other issues with pagination and duplicate tag lists, but Ill hold on those until I can fix these first.

Any help would be appreciated.

Question 1

My problem is that if someone manually enters an ID of a review entry that does not exist, it shows all the comments from each individual review entry where the full review entry should be. Is there a way to check if the ID is valid for that section? Or is there way to forward to a page not found when this happens?

I presume you have a Data Source that is named something like “Movie” or “Get Move by ID” filtering System ID on {$id}. If the ID is of an entry that doesn’t exist, the Data Source should not return any entries at all. Do you mean that it returns all entries when there is no ID at all? This is by-design: if a parameter in a filter evaluates to nothing (i.e. it has no value) then that filter is ignored. You should therefore use a filter of something like:

{$id:0}

This says “use {$id} but if it doesn’t exist, use 0”, which obviously won’t find any entries (no entry has an ID of 0).

There is also a checkbox in the Data Source you can tick to redirect to a 404 page if no entries are found.

Question 2

It sounds like you have a textarea in a form that submits via an Event. You will probably have some XSLT which puts the submitted value back into the textarea (getting it from the posted-values part of the Event XML) so that if the form submission fails, the user doesn’t lose the textarea contents. It’s good practice to hide the form on successful submission, or redirect to a thank-you page altogether, which would get around this problem.

Question 3

Regarding external JIT image manipulation, is this correct format? {$root}/image/1/150/0/1/img3.flickr.com/path/to/some/long/url/here.jpg

You tell me — does it correctly resize the external image?

Assuming I read the JIT image docs right, I need to exclude the http:// from the external image URL. How would I do this?

That is correct. In XSLT you can do something like:

substring-after('http://img3.flickr.com/path/to/some/long/url/here.jpg','http://')

It’s good practice to hide the form on successful submission, or redirect to a thank-you page altogether, which would get around this problem.

@Nick: Are you sure that reloading the thank-you page will not re-send the POST data (thus creating another entry)? I experience this in Safari at least.

If you use the redirect hidden form field then this should do a “hard” redirect to an entirely new URL, losing POST data.

I presume you have a Data Source that is named something like “Movie” or “Get Move by ID” filtering System ID on {$id}. If the ID is of an entry that doesn’t exist, the Data Source should not return any entries at all. Do you mean that it returns all entries when there is no ID at all? This is by-design: if a parameter in a filter evaluates to nothing (i.e. it has no value) then that filter is ignored.

The data source does not show the the full movie review entry if it does not exist (which it supposed to do). If, for example, I put in the address bar reviews/movies/228 (228 being the ID of an entry which does not exist), it still returns a page with all the comments on it (since the comments are supposed to be filtered by the full movie review entry) but it doesn’t display the full movie review since it doesn’t exist.

What I am trying to figure out is if there is a way for the movie review datasource to check that the movie review entry id is valid one. If its not, then it should give me an error or redirect back to the movie review index.

Do you understand this? I’m having trouble describing it. Maybe I should put screen shots or a quick video of what im talking about?

As for comments, I fixed it with a redirect (back to the same page).

As for JIT image manipulation, Its does not show the image since the external image path has http:// in it. I’m just trying to figure out how to strip that part out. How would I use the code you showed me? My XSLT is

<xsl:for-each select="rss/channel/item>
<img src="{$root}/image/1/150/0/1/{media:content/@url}"/>
</xsl:for-each>

The @url part gives me http://img3.flickr.com/blah/blah.jpg . Would I attach substring-after('...') right after the @url? I’m not sure how to go about this.

You have to pass two arguments (strings) to the substring-after function.

<xsl:for-each select="rss/channel/item>
    <img src="{$root}/image/1/150/0/1/{substring-after(media:content/@url, 'http://')}"/>
</xsl:for-each>

Do you use Data Source Chaining for your comments? Then you will likely use a $ds-review parameter or similar to filter your comments by a Select Box Link field. The same technique as Nick described earlier applies here, too. Just append 0 as a fallback value: {$ds-review:0}.

@Nick:

If you use the redirect hidden form field then this should do a “hard” redirect to an entirely new URL, losing POST data.

Thanks! I never realized this.

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