Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Get the current page url in perl


I find similar commands in libraries like WWW :: Mechanize, LWP :: Simple, URI etc. but I cannot use these libraries in ssi.

How can I get url text with perl in ssi.

I want to do;

my $url == includes(), indexOf() etc.
if ($url == "localhost") {
else {

asked Aug 12, 2020 by sadettin.aktar (125 points)
It looks like you may be trying to have different code run between live survey and test survey.  Is that correct?  If so, I think we could achieve that without knowing the URL and without additional libraries.
Yes, separating the local and the real. This is required for perl because according to my distinction I will run other code blocks that I wrote in perl.

1 Answer

+1 vote
There isn't a function in the software explicitly made for this purpose, but we may be able to use one of the other functions as a workaround.  Try this example:

[% Begin Unverified Perl
if (GRAPHICSPATH() eq '../../graphics/') {
    return 'Test survey';
else {
    return 'Live survey';
End Unverified %]
answered Aug 13, 2020 by Zachary Platinum Sawtooth Software, Inc. (171,950 points)
Well, I will have an additional question. Actually, we mostly use lighthouse but how can we make the same code compatible with ssi 8 versions (sample version = 8.48)?
In 8.4.8, the GraphicsPath function returns "/[STUDY NAME]/graphics/" in test survey and "/[REMOTE PATH]/graphics/" or "/graphics/" in live surveys.  As long as your remote path is different than your study name or you have no remote path at all, you should be able to use this.
Thank you so much  Zachary. It was exactly the solution we were looking for.