Welcome, Guest ( Customer Panel | Login )




 All Forums
 VPCart Forum
 Customization
 ASP code within template file / no prices without
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

perinius
Starting Member

USA
47 Posts

Posted - November 17 2004 :  17:14:29  Show Profile  Reply with Quote
When I enter ASP code into the tmp files it doesn't work. I have also tried entering it as an include which doesn't work. Is there any way to make the asp work within the template file?

My main objective is to make an if/else that checks to see if they logged in and if they have not do not show the price or buy buttons. I tried to make this work with the catalog only mode but this doesn't seem to apply when you use the template files for the display.
Any advice would be appreciated.


devshb
Senior Member

United Kingdom
1904 Posts

Posted - November 17 2004 :  17:33:19  Show Profile  Visit devshb's Homepage  Reply with Quote
the template files aren't processed like normal asp files; they're just read by the code and then outputted as html; the special codes [cname], [formatcurrency cprice] etc are processed during the reading/writing process and the relevant html is outputted; all that's done by shopfileio.asp.

what you'd need to do would be to create an extra template special-field code in shopfileio.asp and then use that in the template files.

Simon Barnaby
Developer
[email protected]
www.BigYellowZone.com
Web Design, Online Marketing and VPASP addons
Go to Top of Page

perinius
Starting Member

USA
47 Posts

Posted - November 17 2004 :  18:56:04  Show Profile  Reply with Quote
Thank you for the help.
If I wanted to create the function below within the template file, would this work or would I need to declare the formatcurrency within the shopfileio? Not to sure how the shop file IO works?

<% Dim price
price= (Request.cookies("prc"))
If Price = "yes" Then%>
SCD Price:[formatcurrency cprice]
<%Else%>
<a href=login.asp>Login for Price</a>
<%End If%>

Thanks again.


Go to Top of Page

greatphoto
VP-CART Super User

USA
304 Posts

Posted - November 18 2004 :  07:04:14  Show Profile  Reply with Quote
This is a great discussion! The idea is good and Simon's suggestion is elegant.

Perinius, Simon might provide you with more detail, but I'll give a quick response for you to get you moving a good direction.

You don't define formatcurrency in shopfileio.asp since its already defined there. Instead, define your own keyword in there. There are multiple options on where to do this, but after a quick glance, I think the best place might be in Sub DoSpecialFormating which starts on line 468 in the shopfileio.asp version 5.5. Make your own keyword like "loginshowprice" and add it to the case statement.

A variation of the code you pasted goes under that case. You'll need to reverse the sense of your "<% %>" ASP code delimiters since you are already in an ASP code section while in shopfileio.asp. Also, substitute "value = shopformatcurrency(value,getconfig("xdecimalpoint"))" for your "[formatcurrency cprice]"

In your template, just call your new formatting option using [loginshowprice cprice].

I know this description is a bit rough, and I'm sure there is a little more you'll need to do to get it right, but its all I have time for right now, and I think it gets you going in a good direction.

Go to Top of Page

devshb
Senior Member

United Kingdom
1904 Posts

Posted - November 18 2004 :  08:04:58  Show Profile  Visit devshb's Homepage  Reply with Quote
As per greatphoto's comments, we also are just a bit too busy to give full details here at the moment (as it's quite a detailed thing to do an needs to be done very carefully), but we will post explanations/help on this subject on our own forum and post a link to it here later on.

I don't want to go into more detail at this stage, but suffice to say "watch this space" for all those of you who want to create your own template-fields and corresponding underlying logic; I'll be posting again later today/tonight.

Simon Barnaby
Developer
[email protected]
www.BigYellowZone.com
Web Design, Online Marketing and VPASP addons
Go to Top of Page

devshb
Senior Member

United Kingdom
1904 Posts

Posted - November 20 2004 :  18:03:14  Show Profile  Visit devshb's Homepage  Reply with Quote
ok; we've now got our little addon ready for sale which relates to creating extra logic in your templates....

http://bigyellowzone.com/shopexd.asp?id=42


Lots of people have been wanting to create their own logic to implement inside their templates. For example, in the order confirmation emails people want to show the country name for the order's country code.

Or they might want to add an "if" statement to display different values in different instances.

There's a million uses for this, but what it basically allows you to do is to create as many additional special template-fields as you want in files that are separated-off from shopfileio.asp and which are really easy to create/change/maintain.

Example functions are supplied so you can see how it works, and it also includes the "template-field addons" for showing country-name and state-names in the templates.

The idea is that we'll be selling lots of these little "template-fields" addons for different aspects, but that people can use the basic addon to create/change ones of their own too.

The "create your own template-fields" addon is the link above (byz033), and we'll be selling other "template-field" addons as time goes on, for the moment you just get the country and state addons for free with the main addon.

It comes with full step by step instructions of how to install it and how to create your own functions/fields.

It's hard to explain, but those who've been wanting this kind of extra flexibility can now do all these things by following some simple steps; we use this for almost every site customisation that we do; it's fantastically useful.

To give you an example, if you want to show the country name in an order email then instead of using:
[ocountry]
you'd use:
[BYZ_CN_COUNTRYNAME ocountry]

and the functions are split-off into a separate file:
byz_template_codes_functions_countries.asp

you can create as many of these files/functions as you want, and they're very easily created; just follow the instructions and examples.

In the example/problem of the first post, you'd, say, create an extra function called:

MYSPECIALPRICE

and call it using
[MYSPECIALPRICE cprice]

in the template.

Sadly we haven't had the time to apply the latest versions of these to our own site, but we have done for lots of other sites and they've proved themselves as working really well and being nice and easy to change and add to. The version that's for sale through our site is the latest version, it's just that we're not using it ourselves yet (too busy adding it to other people's sites!)

If you buy this, you'll be able to download the main zip file from our site, and we'll send you any additional zips afterwards (we'll be automating that process soon, but for the moment the additional zips will just be manually emailed to you).

Also, all the functions/examples have been created in a way that you can call these in templates
eg: [BYZ_CN_COUNTRYNAME ocountry]
*and* in VBScript
eg: Response.Write BYZ_VB_CN_COUNTRYNAME(mycountrycodevariable)

In theory this should work for any vpasp version, although we've only tried it so far in 4.5/5/5.5.

Always backup your files before changing them, and email me if you come across any problems; we're always happy to help.

It comes with our country-name and state-name template fields thrown in for free.

As always, any comments/feedback are always more than welcome. If anyone's got any constructive suggestions we're very happy to hear them as this is the first time it's been given out to the general public instead of just individual clients.

If anyone has any problems/questions, please feel free to email me direct.


Simon Barnaby
Developer
[email protected]
www.BigYellowZone.com
Web Design, Online Marketing and VPASP addons

Edited by - devshb on November 21 2004 05:05:46
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000
0 Item(s)
$0.00