When using FSI Pages link support to link to a specific product in your onlineshop, the user will return to the title page of your catalog. To prevent this from happening and to ease the user experience when linking to external sites from within FSI Pages, this tutorial will explain two methods how to achieve this.

Setting the related parameters

If your shop system does not use browser sessions, the easiest way is to set the parameter RememberLastViewedPage to true. If enabled, this parameter lets FSI Pages store the page number of the most recently viewed page on the user’s computer and displays this page on start up the next time the user views the same catalogue (image collection) again. Please note that the ForceInitialPage parameter will override this parameter if set.

There is a related parameter called RememberLastViewedPageExpireAfter which lets you set the expiry time in seconds. E.g. if you set the value f this parameter to 3600, the last viewed page will be stored for one hour. If the user visits the catalog after that hour has passed, he will start at the title again.

<?xml version="1.0" encoding="UTF-8"?>
<fsi_parameter>

      <!-- Other entries removed for demonstration purposes -->

      <Plugin Src="Pages">

            <!-- Other entries removed for demonstration purposes -->
            <RememberLastViewedPage value="true" />
            <RememberLastViewedPageExpireAfter value="3600" />
      </Plugin>

</fsi_parameter>

 

Modifying Link Values at Runtime

In some cases it might be necessary to replace parts of link URL values for links on the pages – for example when using session variables or if you use the same catalog in HTTP and HTTPS environments. Runtime link template replacement applies to links on pages as well as for “SaveURL” values used to specify external documents related to a page.
You can replace any part of these URLs using the FSI Pages parameters “LinkTemplates” and “LinkTemplateData“.
Use the FSI Pages parameter “LinkTemplateData” to specify a comma separated list of values you want FSI Pages to replace the keywords with. Usually you will provide the LinkTemplateData value by appending the parameter to the FSI Viewer query using server side script.

When specifying multiple LinkTemplates, the number and sequence of the corresponding LinkTemplateData values must match to achieve correct replacement. For example replacing the templates “[SESSION]” and “[DATE]” at runtime in all link URLs can be done like this:

<?xml version="1.0" encoding="UTF-8"?>
<fsi_parameter>

      <!-- Other entries removed for demonstration purposes -->

      <plugin src="pages" >
          <LinkTemplates value="[SESSION],[DATE]" />
      </plugin>

</fsi_parameter>

This configuration will let FSI Pages call URL “…/fsi.swf?LinkTemplateData=somesession,01.01.2006”

Please note that LinkTemplateData values have to be provided ?url-encoded if the values contain invalid HTML query characters like “?&/,”.

Besides using the LinkTemplates parameter to provide custom templates, you can use the following predefined LinkTemplates without providing the corresponding LinkTemplateData:

_FSI_CURRENTPAGE_” is a 1-based index of the current page (1,2,3,4…) “_FSI_CURRENTDOUBLEPAGE_” is a 1-based index of the current double page (1,2,4,6…)

For inner pages this value represents the index of the left page. For the front and back cover the value is the actual page index.

Passing a session variable from FSI Pages

When using session variables in your shop system, it is necessary to pass the session variable to the shop software when opening links from within FSI Pages, so the shopping cart contents do not get lost when the user looks at FSI Pages while shopping.

The easiest way to achieve this goal ist to link to the product ids in FSI Pages. Please refer to the Using links and sticky notes in a PDF and/or Linking a PDF with external data for a detailed description on how to do this.

Using the parameters DefaultLinkUrlPrefix and DefaultLinkUrlSuffix we build a JavaScript function that appends the session id to the URL being opened:

<?xml version="1.0" encoding="UTF-8"?>
<fsi_parameter>

      <!-- Other entries removed for demonstration purposes -->

      <Plugin Src="Pages">

            <!-- Other entries removed for demonstration purposes -->
            <DefaultLinkUrlPrefix value="openShop('" />
            <DefaultLinkUrlSufffix value="')" />
      </Plugin>

</fsi_parameter>

This configuration will let FSI Pages call the “openShop” method, handing the link target as the parameter (which is the product id in this example)

function openShop(productid) {

      window.location.href = "http://www.example.com/shop/item.php?id="+productid+"&session=<?php echo session_id(); ?>";

}

 

When the page containing the FSI Pages instance contains such a function definition, the related session id is echo’ed by PHP at the appropiate position in the URL being opened.

Considered the link in the PDF was ‘12345‘, FSI Pages / JavaScript will load the following URL:
http://www.example.com/shop/item.php?id=12345&session=[SomeSessionID]