marty.net 1001 Postcards Love Love Love Meep Meep ZenZodiac DailyQuotation

YOU ARE HERE:
Fun With Templates

HOME

CPSHOP|

|

|

EMAIL MARTY
  marty.net message board
  « Fun With Templates »
Welcome, Guest. Please Login or Register.
12/13/17 at 17:03:31
Home Help Search Login Register
   marty.net message board
   About cpshop
   Customization Help
   Fun With Templates
(Moderator: Marty)
Pages: 1 Reply Notify of replies Send the topic Print 
   Author  Topic: Fun With Templates  (Read 2046 times)
Wes
White Dragon
**

Posts: 15




   

WWW E-Mail
Fun With Templates
« on: 05/12/02 at 19:37:50 »
Reply with quote Modify message

So far, I've been very impressed with CPShop. Good work, Marty! (I just couldn't stand the way CafePress organizes its shops.)

Installation has been smooth so far, but I have a concern over working with templates. Right now, my site employs a series of SSI templates to create every page in the site. Their use looks something like this on a given page:


Code:
<!--#INCLUDE VIRTUAL="/template_top.html" -->

Page content.

<!--#INCLUDE VIRTUAL="/copyright.html" -->

<!--#INCLUDE VIRTUAL="/template_bottom.html" -->


Unfortunately, I can't create a similar document for cpshop to use a template since, of course, the SSIs won't get parsed.

Presently, the only thing I can figure to do is take all the templates, copy and paste their contents into a single document and put the <[content]> tag in for cpshop. But, that kind of defeats the purpose of having templates since, if I change something in my standard templates, I have to remember to go and change the cpshop template, too.

I'm not brilliant with Perl, otherwise I'd tell cpshop to include my template files around the [content]. Is there some clever workaround I'm not thinking of?

Thanks for the help.
Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: Fun With Templates
« Reply #1 on: 05/12/02 at 23:10:59 »
Reply with quote Modify message

Wes,

The cpshop.cgi file was made to be modified, so....

You might want to try something like creating the cpshop template, complete with your SSI tags, and then after this line in cpshop.cgi:


Code:
&gettemplate;


Add something like this:


Code:
while ($html =~ m|<\!--\#include virtual="/(.+)" -->|) {
   $file = $1;
   open(FILE,"/path/to/root/$file");
   { local $/; $filetext = <FILE>; }
   close(FILE);
   $html =~ s|<\!--\#include virtual="/$file" -->|$filetext|g;
}


I haven't tested it (I'm just kind've writing it of the top of my head), but that should emulate the SSI include calls.
« Last Edit: 05/12/02 at 23:12:26 by Marty » Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
Wes
White Dragon
**

Posts: 15




   

WWW E-Mail
Re: Fun With Templates
« Reply #2 on: 05/13/02 at 20:47:35 »
Reply with quote Modify message

Hey, Marty, this works great! You are a Perl guru.

I'll definitely spread the word about cpshop!
Logged
Michael
Guest

E-Mail
Re: Fun With Templates
« Reply #3 on: 11/26/02 at 15:16:47 »
Reply with quote Modify message

I have been having a similar issue. The site I am currently working on uses templates, but the entire application is built depending on what directory you are in and then what id is in the querystring. I am using IIS with ActivePerl.

I have everything working, and on the page that is supposed to include the cpshop.cgi, I have included cpshop via the script tag (attributes runat=server and language=perlscript) -- the problem is that once it loads cpshop, it looses its path scope and cannot find the cgi-bin path. I have modified the $script_dir variable in every way I could think of with no luck.

The page works fine when going to it directly in the browser via the cgi-bin. just not the include page.

What are my options?
Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: Fun With Templates
« Reply #4 on: 11/27/02 at 03:08:37 »
Reply with quote Modify message

The problem is that cpshop isn't meant to run as an include -- it's meant to run by reading templates, and parsing in its own content.

Theoretically, if the query string could be sent to the script, it's possible that you could duplicate the PHP system.  But I haven't worked out the way to do that as of yet.

The best thing to do right now is to duplicate the functionality of SSI through the script itself, and then use the script directly.  

Of course, if you can come up with a method of getting the script included into a page effectively, I'd love to hear it.
« Last Edit: 11/27/02 at 03:09:22 by Marty » Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
Michael
Guest

E-Mail
Re: Fun With Templates
« Reply #5 on: 11/27/02 at 12:43:40 »
Reply with quote Modify message

Thanks! I took a look at the PHP system, and made a modification to my code, and am almost there in terms of getting this to work.

basically I now use the script tag (with the language attribute set to PerlScript), and point it to a PerlScript page.


Code:
$sQS      = $Server->urlencode($Request->ServerVariables('QUERY_STRING')->Item());
$sURL      = `[physical path to cpshop.cgi] [asp file url] [cpshop.cgi url] $sQS`;
$Response->Write($sURL);


From what I can tell being somewhat familiar with PHP and Perl, PerlScript is a cross between Perl, and ASP, using the built in IIS objects, but the Perl syntax?

What gets written into the top of the page (before all of the HTML gets inserted via SSI and ASP -- I guess the PerlScript goes first) is the following:

The system cannot find the path specified.
The system cannot find the path specified.

(it gets written twice, as you see above)

Are you familiar enough with PerlScript to see what is going on? I have double checked the path and the URLs, and cannot see anything wrong.
Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: Fun With Templates
« Reply #6 on: 11/27/02 at 17:41:13 »
Reply with quote Modify message

For the $script_dir variable, have you tried entering the absolute path to your cpshop directory?

Something like:

$script_dir = "D:/Inetpub/wwwroot/mysite/www/cgi-bin/store/";
Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
markwood
Green Dragon
*

Gender: male
Posts: 10




    crzmm11

WWW E-Mail
Re: Fun With Templates
« Reply #7 on: 01/07/03 at 22:41:27 »
Reply with quote Modify message

I'm trying to make a template in ASP and running into some problems.
My template looks like this:

Code:
%>
<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="inc_sha256.asp"-->
<!--#INCLUDE FILE="inc_header.asp" -->
<P align=center><[content]></P>
<%
WriteFooter
Response.End
%>


I've tried putting this:

Code:
while ($html =~ m|<\!--\#include file="/(.+)" -->|) {
  $file = $1;
  open(FILE,"/path/to/root/$file");
  { local $/; $filetext = <FILE>; }
  close(FILE);
  $html =~ s|<\!--\#include file="/$file" -->|$filetext|g;
}
into the cpshop.cgi but it didn't seem to help. I've never worked with PERL and any help would be greatly appreciated.
Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: Fun With Templates
« Reply #8 on: 01/07/03 at 23:27:56 »
Reply with quote Modify message

Wow, lots of problems here.

First of all, ASP is processed by the server.  Your template is processed by cpshop, NOT the server.  So an ASP file isn't going to work as a template.

The code I wrote there was intended to function as a workaround for server-side includes, but it won't circumvent the need for your server to process the ASP code, which won't happen if cpshop is using it as a template.

(Also, INCLUDE and FILE should be all lowercase (include and file), and the "/path/to/root/" part needs to be changed to the actual file location of your template file.  Though this is largely irrelevant, because of that ASP problem again.)

While it's possible I could write a whole host of hacks and workarounds to fix this, but considering that it would be hours and hours of work, I'm afraid it's probably a huge waste of time and effort.

I think the solution is going to have to be a standard HTML template.  I'd love to offer something better, but nothing really comes to mind.  ASP is a totally different language set unto itself, and it doesn't lend well to being incorporated into other languages.
Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
markwood
Green Dragon
*

Gender: male
Posts: 10




    crzmm11

WWW E-Mail
Re: Fun With Templates
« Reply #9 on: 01/07/03 at 23:40:15 »
Reply with quote Modify message

Thanks for the Quick Reply!!

The whole site is written in ASP and every page gets the header, footer, and database connection info from included ASP pages.

what is my best option for getting a template that will work with cpshop but also have the same header & footer as the rest of site.
Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: Fun With Templates
« Reply #10 on: 01/08/03 at 10:51:32 »
Reply with quote Modify message

Okay, your best option is to download the new version.

I've just added support for remote templates.  So place your cpshop template on your server in a web-accessible directory, and then reference it as a URL on your admin screen, i.e. http://www.mysite.com/templates/cpshop_template.asp

By default, the page will be cached, but to avoid caching, use a "nocache" protocol in your URL:

nocache://www.mysite.com/templates/cpshop_template.asp

This should fix a bunch of workarounds, and because the template is referenced as a webpage instead of a file, all your ASP calls will work just fine.
« Last Edit: 01/08/03 at 10:53:01 by Marty » Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
markwood
Green Dragon
*

Gender: male
Posts: 10




    crzmm11

WWW E-Mail
Re: Fun With Templates
« Reply #11 on: 01/08/03 at 13:04:43 »
Reply with quote Modify message

Thanks Marty!!  

This works great!
Logged
Pages: 1 Reply Notify of replies Send the topic Print 
Jump to:


marty.net message board (http://www.marty.net/cgi/marty/board/messageboard)

Powered by YaBB 1 Gold - Release (Yet Another Bulletin Board)
Copyright © 2000-2001, X-Null. All Rights Reserved.