Add preview template feature (v. 2.8x)

To preview a template on your site, you can create a new page through the storeadmin area (storeadmin -> Web Site -> Pages -> Add New Page) and add that template to the new page by selecting it in the 'Optional Theme' field.

If you'd like to create a preview function without having to add a new page, and which allows you to preview any page, you can make the following adjustments:

  1. Open the openinfo.php file in the /enc/ folder.

  2. Add the code:

    // PREVIEW THEMES
    if (isset($_GET['previewtheme']))
    {
    	if (file_exists(SB_HOME_PATH . '/template/' . $_GET['previewtheme'] . '.htm'))
    	{
    		$changetheme = $_GET['previewtheme'] . '.htm';
    		$themename = $changetheme;
    	}
    }

    just before the code:

    if (isset($_REQUEST['themename']) OR empty($themename))
    die("Theme Not Found");
  3. If you use static page links, in your main .htaccess file in your public html directory (the same one that holds the stconfig.php file), add [L,QSA] to the end of each rewrite rule. For instance, instead of:

    RewriteRule category/new(.*).htm$  catalog.php?new=yes&page=$1

    use:

    RewriteRule category/new(.*).htm$  catalog.php?new=yes&page=$1 [L,QSA]
  4. Now you can go to any page in your system, and add

    ?previewtheme=Template_Name

    to the end of the page, where Template_Name is the name of your template without the .htm extension.

    examples:
    http://yourwebsite/wholesale.php?previewtheme=Pink_Dreams
    will show the Pink_Dreams.htm template on the wholesale.php page.
    http://yourwebsite/category_20/Some-Category.htm?previewtheme=Seaside_Escape
    will show the Seaside_Escape.htm template on the catalog.php page that displays Some Category.

    Note that the template preview will not follow the link. You can only view the template on the current page.