Trying to get lists of variables on pages

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
kstevenson
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 47
Joined: Thu Jun 03, 2010 1:48 pm

Trying to get lists of variables on pages

Post by kstevenson » Mon Dec 06, 2010 9:57 am

I've been digging around trying to find a way to generate lists of variables that are available on a given page (or even better, find existing lists). I know, there are the notes and hints that the properties of the various objects (Store, Product, etc) area available to the Scriptlets and email templates but it would be really helpful for our new designer to actually have reference lists of what those properties are called (the exact spelling) and what all is available on a given page, e.g., $User.IsAnonymous, etc.

I tried to dump the $context based on the code in this article:
http://learndotcms.com/2010/07/why-cont ... literally/

Supposedly, $context is the the collection of it all:

Code: Select all

<fieldset>
    <legend>Page Context Debug ($!{context})</legend>
    <ul>
#foreach($key in $context.getKeys())
        <li><strong>$!{key} :</strong> $!{context.get($key)}</li>
#end
    </ul>
</fieldset>

This will print out a nice list of all the variables that are set and available to you in Velocity, everything from page variables, to content variables
But I don't get any results. If I change this to:

Code: Select all

<fieldset>
    <legend>Page Context Debug ($!{Product})</legend>
	   <ul>	
#foreach($prop in $Product.getKeys())
        <li><strong>$!{key} :</strong> $!{Product.get($key)}</li>
#end
    </ul>
</fieldset>
Then it does display "Page Context Debug (CommerceBuilder.Products.Product)", so the first line does see the correct object--it just seems like the getKeys doesn't return anything.

Does anybody have any insight on how to get this to work or what code generates listings of all the object properties on any given page?

As always, many thanks in advance for your help.
Karin Stevenson
CyberWolf, Inc.

kstevenson@cyberwolf.com
505-231-3130


kstevenson
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 47
Joined: Thu Jun 03, 2010 1:48 pm

Re: Trying to get lists of variables on pages

Post by kstevenson » Wed Dec 08, 2010 9:41 am

Thanks, Mazhar, I saw that one...

What that doesn't tell me are the property names for the individual objects, or collections, or scopes (or whatever you want to call them) that I need to call the actual variable. For example the "IsAnonymous" part in the $User object.

I've been working with our developer and he found a method for us to get this information dumped by extending the NVelocity code. It involves adding a couple of lines of code to the NVelocity engine code in CommerceBuilder to generate a context object when compiled in DEBUG. Needless to say, I can't put it here :-). But after I get it done I can share the reference document that I'll do for my web designer the next couple of weeks. I hope it will be helpful for other folks as well in this forum.

Thanks again!
Karin Stevenson
CyberWolf, Inc.

kstevenson@cyberwolf.com
505-231-3130

hautebox
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 26
Joined: Thu Nov 05, 2009 2:46 pm

Re: Trying to get lists of variables on pages

Post by hautebox » Mon Feb 20, 2012 10:50 pm

Mazhar,

I found that link equally useless... :-)

I too am needing the proper velocity syntax for variables like customer email, customer phone, etc.

I too have also run across the same general links with references to a handful of items...

Is there a place with the complete list?

I noticed Karin's result wasn't posted...

Thanks in advance...

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Trying to get lists of variables on pages

Post by jmestep » Tue Feb 21, 2012 7:00 am

Able discourages using the nVelocity variables on pages for performance reasons. They do use it in scriplet files, but most of the design changes we do are in css or conlib files. If you get Visual Web Developer from Microsoft (free) if you don't have Visual Studio, you can copy the Able store files to your local machine and then use intellisense or the object browser to find the properties. It can cause some problems if you try to use your live site files via ftp. Then you can copy the code into the live files when you are done. I think dreamweaver might display the properties also, but I'm not sure.
Below are images of what you can pick up in intellisense or the object browser. Most, if not all of the product, user, order variables are available in nVelocity if you have to go that route.
productobject.jpg
product.jpg
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

hautebox
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 26
Joined: Thu Nov 05, 2009 2:46 pm

Re: Trying to get lists of variables on pages

Post by hautebox » Tue Feb 21, 2012 9:52 pm

Judy.

Thanks for the informative note. Actually, yes, I had read about the performance issues.

My needs are somewhat simpler...

We are just wanting to add the customer email and phone number into some of the html email "templates". For example, in the packing slips, we want to have the email and phone print out on the slips for our folks in the warehouse. If for some reason, they needed to contact the customer, it would be right on the sheet.

I am on a server where we are ftp'ing.

I'm not familiar with the "advanced" level of coding you are referring to above.

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: Trying to get lists of variables on pages

Post by Logan Rhodehamel » Wed Feb 22, 2012 1:10 pm

The page does feel a little incomplete to me too. I added a new table to the page with a few sample properties. Actually, we publish a CHM file. This is a downloadable reference document that details all of the properties of these objects. It would be a helpful reference for a developer working with nVelocity scripting. It is also available on the wiki.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

hautebox
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 26
Joined: Thu Nov 05, 2009 2:46 pm

Re: Trying to get lists of variables on pages

Post by hautebox » Wed Feb 29, 2012 2:28 pm

Just a follow-up for folks interested in this thread. Mike over at AC is trying to get us a listing...

As a note to Judy's point she raised, most I have been in discussion with are just looking to modify the email templates - and not the "core code"...hence, performance theoretically won't be compromised.

For the variables that have been posted previously (such as here http://wiki.ablecommerce.com/index.php/ ... scriptlets )

Only a few have been previously listed. However, using the phone number as an example - the template is still throwing an error...

Code: Select all

<td class="Email"><div align="right"><strong>Email Address:</strong></div></td>
<td class="Email">${order.BillToEmail}</td>
</tr>
<tr>
<td class="Email"><div align="right"><strong>Phone:</strong></div></td>
<td class="Email">$User.PrimaryAddress.Phone</td>
</tr>
<tr>
<td class="Email" width="140"><div align="right"><strong>Order Number:</strong> </div></td>
<td class="Email" width="500"><p>$order.OrderNumber</p></td>
</tr>
<tr>
<td class="Email"><div align="right"><strong>Ordered on:</strong></div></td>
<td class="Email">$order.OrderDate.ToString("G")</td>
</tr>
<tr>
<td class="Email"><div align="right"><strong>Ordered by:</strong></div></td>
<td class="Email">$order.BillToFirstName $order.BillToLastName</td>
</tr>
Returns the following...(ie. no correct data)

************************************
Email Address: test@hauteboxmeals.com
Phone: $User.PrimaryAddress.Phone
Order Number: 17

Ordered on: 2/29/2012 1:52:16 PM

*******************************
I have tried with and without the brackets = {variable}

Any insights....Thanks in advance.

kstevenson
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 47
Joined: Thu Jun 03, 2010 1:48 pm

Re: Trying to get lists of variables on pages

Post by kstevenson » Wed Feb 29, 2012 2:44 pm

Have you tried <td class="Email">${order.BillToPhone}</td> ?

Seems like the one for the email is working, so logic would suggest that the order data for phonenumber is there as well. Seems like the user scope is not available where you are using it.
Karin Stevenson
CyberWolf, Inc.

kstevenson@cyberwolf.com
505-231-3130

hautebox
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 26
Joined: Thu Nov 05, 2009 2:46 pm

Re: Trying to get lists of variables on pages

Post by hautebox » Wed Feb 29, 2012 3:09 pm

Karin...

You are AWESOME...yes, that worked...

Interestingly enough...I tried previously, but i think it needs to contain the {variable} in brackets...Now it works...If you look at the email template code, some variables require it, others don't....

Independently, that would mean that the variable syntax posted on the wiki is not applicable to the email templates...??? Hopefully Mark can get that updated on the WIKI when he views this post...

http://wiki.ablecommerce.com/index.php/ ... scriptlets ---- references this incorrect syntax

CommerceBuilder.Users.User PrimaryAddress.Phone $User.PrimaryAddress.Phone

Thanks again...

kstevenson
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 47
Joined: Thu Jun 03, 2010 1:48 pm

Re: Trying to get lists of variables on pages

Post by kstevenson » Wed Feb 29, 2012 3:13 pm

Just a lucky guess.

the syntax is correct... it's just that not all data is available in all pages or pieces of the system. For example, you might not have product "scope" available on the home page. These are data groupings that are only available where they are needed. if you tried $User.PrimaryAddress.Phone on the home page after logging in, you'll get the right data.

Good luck!
Karin Stevenson
CyberWolf, Inc.

kstevenson@cyberwolf.com
505-231-3130

hautebox
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 26
Joined: Thu Nov 05, 2009 2:46 pm

Re: Trying to get lists of variables on pages

Post by hautebox » Wed Feb 29, 2012 4:13 pm

Karin.

I understand you explanation. That does seem, however, peculiar programming logic...

From the standpoint that the email template is somewhat "external" in terms of it pulling from a html (not in aspx), you would think that it is accessing the dBase directly...ie, and therefore able to call any field...but again, I'm not an expert in any of those areas.

I did express my thoughts to the AC tech rep. I also acknowledged that we understand "customizing" nVelocity opens up a can of support worms so-to-speak, but the level of current understanding on the forums is probably lacking...

Thanks again for the assistance.

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: Trying to get lists of variables on pages

Post by Logan Rhodehamel » Thu Mar 01, 2012 11:27 am

hautebox wrote: I have tried with and without the brackets = {variable}

Any insights....Thanks in advance.
I checked into this and discovered that wiki page is reporting old information. I didn't catch it when I made the examples. The $User parameter is no longer defined. It is always $customer. I've updated the wiki with corrected examples.

Basically what it boils down to is we pass along .NET object instances to the NVelocity engine for the store, order, user, etc. In your email template you can refer to these objects just as you would through a .NET programming language. You have access to all of properties that are defined on the object. A reference list is available in the compiled help where you can go explore the type of object and see what it offers.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: Trying to get lists of variables on pages

Post by Logan Rhodehamel » Thu Mar 01, 2012 11:30 am

I also don't like the warnings on this wiki page. They are specific to use within scriptlets for front end display, not so much in regards to emails. You definitely should feel free to use nvelocity script for the email processing. It is extremely well suited for this task. We also have the ability to use nvelocity script for displaying webpages to the browser. It's possible to make complex designs using NVelocity, but it offers less performance than if you created a custom user control or asp.net page.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

Post Reply