Adding own URL strings to pages

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Chris Graham)
#3586 (In Topic #715)
Joe

Neat trick (and a small issue)

Not sure if this has been posted already, but I figured I'd share it.

You can add custom URL strings (like page=blah&yippie=kaiyay) to display additional information on Comcode pages that would not normally show without these strings being provided.

This could be useful if you were making a Comcode page about, let's say, product features or tutorials, and:
  • you don't want everything visible at the same time
  • you want to only show some information
  • you don't necessarily want to create child pages

However, I don't imagine it would useful for Composr users that utilize SEO-friendly URLs unless there's a way to implement the usage of this trick in conjunction with these types of URL's. (I haven't messed around with the friendly-URL setting on my site yet)

I'm doing something like this on my site, but instead I'm using it with a Javascript-enabled popup so that when a user clicks on a help icon, a popup displays showing only information pertaining to that specific topic.

All you do is surround each bit of information you want to "hide" from normal view on that page with some Tempcode, as follows…

You can add some more Tempcode to display an error (or include the 404 error page) if the page is accessed directly with no string or value given:

Code

{+START,IF,{$EQ,{$_GET,yippie},}}
  [include param=""]404[/include]
{+END}

However, there's a slight issue I've run into that I can't seem to figure out; maybe someone can chime in on this one:

If a user enters a value for your string that you haven't specified in the Comcode page, an error is shown:

The requested page gave no output

Can anyone tell me if there's a way to check for no output, using Tempcode, and also include the 404 page if no output is true?

Post

Posted
Rating:
#3587
All the URL schemes will actually support GET parameters. Just there'll be no 'page'/'type'/'id' GET parameters.

E.g. The URL I'm at now is:
https://compo.sr/forum/topicview/browse/deploying/adding-own-url-strings.htm?post_id=3596

topicview corresponds to page
browse corresponds to type
deploying/adding-own-url-string corresponds to id

But you can then see it can still tack any parameters on after ?.

Post

Posted
Rating:
#3588
Can anyone tell me if there's a way to check for no output, using Tempcode, and also include the 404 page if no output is true?

Ok, well this kind of stands to reason – there's no output, so Composr is saying so because that's unusual.

I doubt in your real scenario it would happen, as you're adding extra output, not all the output is conditional on parameters.

Regardless, you could do something like…

Code

{$SET,done_some_output,0}

{+START,IF,{$EQ,{$_GET,yippie},kaiyay}}
This text only shows if a user is at ?page=yourpage&yippie=kaiyay
{$SET,done_some_output,1}
{+END}

{+START,IF,{$NOT,{$GET,done_some_output}}}
  [include param=""]404[/include]
{+END}
0 guests and 0 members have recently viewed this.