Adding own URL strings to pages
Posted
#3596
(In Topic #686)

Standard member

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…
{+START,IF,{$EQ,{$_GET,yippie},kaiyay}}
This text only shows if a user is at ?page=yourpage&yippie=kaiyay
{+END}
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?
Posted

Site director

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 ?.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Posted

Site director

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}
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
1 guest and 0 members have just viewed this.