BenEskew.com Just another web developer's personal weblog.

17Aug/100

Use Facebook “Like” Widget in product.SimpleProduct.xml XMLPackage in AspDotNetStorefront

ASPDNSF Version: 9 (C# + MS SQL)

It's very easy to embed the Facebook "Like" widget into an XMLPackage (like the product pages for example) within AspDotNetStorefront. Simply add the following code to your XMLPackage:

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.yoursite.com%2F(!PAGEURL!)&layout=button_count& show_faces=false&width=50&action=like&font=arial&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:21px;" allowTransparency="true"></iframe>

Of course, you should adjust the iframe variables to your liking.

17Aug/100

Use Images as Add To Cart/Add To Wish List Buttons with AspDotNetStorefront

ASPDNSF Version: 9 (C# + MS SQL)

By default AspDotNetStorefront uses basic form buttons for the Add To Cart and Add To Wish List features in the design. If you'd like to use images as those buttons instead you will need to make some modifications.

First, make sure you have some good images to use and then upload/FTP them to the theme images directory "App_Themes/Your_Skin_Folder/images/". Now go to the AspDotNetStorefront back-end administration and go to "Configuration > Advanced > AppConfig Parameters" and find the config "AddToCart.AddToCartButton" and update it with the image you are going to use for the Add To Cart button. Then, find the config "AddToCart.AddToWishButton" and update it with the image you are going to use for the Add To Wish List button. Finally, find the config "AddToCart.UseImageButton" and change it to true. Your Add To Cart forms should now use your images as buttons.

7Aug/100

Display MSRP in product.SimpleProduct.xml XMLPackage in AspDotNetStorefront

ASPDNSF Version: 9 (C# + MS SQL)

By default in AspDotNetStorefront the MSRP for products is not displayed or used within the product.SimpleProduct.xml XMLPackage, so if you would like to use or display it you will need to make some fine-tuned adjustments.

The Quick and Dirty Way (not as efficient):

In your product.SimpleProduct.xml XMLPackage find the lines where database queries are being made, like:

...
<query name="Products" rowElementName="Product" runif="edit">
<sql>
<![CDATA[
exec dbo.aspdnsf_EditOrderProduct @ShoppingCartRecID, @CustomerLevelID
]]>
</sql>
<queryparam paramname="@ShoppingCartRecID" paramtype="request" requestparamname="CartRecID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
<queryparam paramname="@CustomerLevelID" paramtype="system" requestparamname="CustomerLevelID" sqlDataType="int" defvalue="0" validationpattern="" />
</query>
...

and add a new database query by adding the following after the last query:

<query name="Variant" rowElementName="Price" runif="showproduct">
<sql>
<![CDATA[
select MSRP from dbo.ProductVariant with(NOLOCK) where ProductID=@ProductID and IsDefault=1
]]>
</sql>
<queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
</query>

ex.

...
<query name="Products" rowElementName="Product" runif="edit">
<sql>
<![CDATA[
exec dbo.aspdnsf_EditOrderProduct @ShoppingCartRecID, @CustomerLevelID
]]>
</sql>
<queryparam paramname="@ShoppingCartRecID" paramtype="request" requestparamname="CartRecID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
<queryparam paramname="@CustomerLevelID" paramtype="system" requestparamname="CustomerLevelID" sqlDataType="int" defvalue="0" validationpattern="" />
</query>
<query name="Variant" rowElementName="Price" runif="showproduct">
<sql>
<![CDATA[
select MSRP from dbo.ProductVariant with(NOLOCK) where ProductID=@ProductID and IsDefault=1
]]>
</sql>
<queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
</query>

...

Now, in your XMLPackage wherever you'd like to display the MSRP, simply add the following:

<xsl:value-of select="aspdnsf:FormatCurrency(/root/Variant/Price/MSRP)" disable-output-escaping="yes" />

The Efficient Way (MS SQL):

Using SQL Management Studio, open up the stored procedure and locate near the bottom where it reads:

...
SELECT
p.*,
pv.VariantID, pv.name VariantName, pv.Price, pv.Description VariantDescription, isnull(pv.SalePrice, 0) SalePrice, isnull(SkuSuffix, '') SkuSuffix, pv.Dimensions, pv.Weight, isnull(pv.Points, 0) Points, pv.Inventory, pv.ImageFilenameOverride VariantImageFilenameOverride, pv.isdefault, pv.CustomerEntersPrice, isnull(pv.colors, '') Colors, isnull(pv.sizes, '') Sizes,
...

simply add the MSRP table call to the select statement, like:

...
SELECT
p.*,
pv.VariantID, pv.name VariantName, pv.Price, pv.MSRP, pv.Description VariantDescription, isnull(pv.SalePrice, 0) SalePrice, isnull(SkuSuffix, '') SkuSuffix, pv.Dimensions, pv.Weight, isnull(pv.Points, 0) Points, pv.Inventory, pv.ImageFilenameOverride VariantImageFilenameOverride, pv.isdefault, pv.CustomerEntersPrice, isnull(pv.colors, '') Colors, isnull(pv.sizes, '') Sizes,
...

Now, execute the statement.
Finally, in your XMLPackage where you'd like to display the MSRP simply add the following:

<xsl:value-of select="aspdnsf:FormatCurrency(MSRP)" disable-output-escaping="yes" />

Or, if you're calling it from outside of the Product template, use the full xpath, like:

<xsl:value-of select="aspdnsf:FormatCurrency(/root/Products/Product/MSRP)" disable-output-escaping="yes" />

7Aug/100

Display SKU in product.SimpleProduct.xml XMLPackage in AspDotNetStorefront

ASPDNSF Version: 9 (C# + MS SQL)

By default in AspDotNetStorefront the SKU for products is not displayed or used within the product.SimpleProduct.xml XMLPackage, so if you would like to use or display it you will need to make some fine-tuned adjustments.

First:
In your product.SimpleProduct.xml XMLPackage find the lines where the Product is being handled, namely the lines starting with:

...
<xsl:template match="Product">
<xsl:param name="pName" select="aspdnsf:GetMLValue(Name)"></xsl:param>

...
...

and add a new parameter call to the parameters by adding:

<xsl:param name="pSKU" select="aspdnsf:GetMLValue(SKU)"></xsl:param>

ex.

...
<xsl:template match="Product">
<xsl:param name="pName" select="aspdnsf:GetMLValue(Name)"></xsl:param>
<xsl:param name="pDescription" select="aspdnsf:GetMLValue(Description)"></xsl:param>
<xsl:param name="pSalesPromptName" select="aspdnsf:GetMLValue(SalesPromptName)"></xsl:param>
<xsl:param name="pSKU" select="aspdnsf:GetMLValue(SKU)"></xsl:param>

...
...

Now, in your XMLPackage wherever you'd like to display the SKU, simply add the following:

<xsl:value-of select="$pSKU" disable-output-escaping="yes"/>

Using this method you can call any field from the Product table including Variants, like if you simply wanted to get the ProductID so you can display it in the XMLPackage...

...set parameter for it:
<xsl:param name="pID" select="aspdnsf:GetMLValue(ProductID)"></xsl:param>

...use it:
...href="http://www.yoursite.com/EMailproduct.aspx?productid={$pID}"><img src="http://www.yoursite.com/App_Themes/Skin_1/images/Icon-Email.gif"...

3Aug/100

Make Breadcrumbs in AspDotNetStorefront template.master

ASPDNSF Version: 9 (C# + MS SQL)

If you've not gone through every nook and cranny of the AspDotNetStorefront manual chances are that you haven't figured out how to properly create "breadcrumbs" with your navigation.

No fear, Ben is here.

In your template.master skin file, located at "App_Templates/Your_Skin_Folder/template.master", simply add the following immediately after the opening id="content" DIV:


<div id="breadcrumbs">
<a href="http://www.yoursite.com/default.aspx">HOME</a> ::
<asp:Literal ID="SectionTitle" runat="server" Text='' />
</div>

ex.

...
<div id="content">
<!-- CONTENTS START -->
<div id="breadcrumbs">
<a href="http://www.yoursite.com/default.aspx">HOME</a> ::
<asp:Literal ID="SectionTitle" runat="server" Text='' />
</div>

<asp:ContentPlaceHolder ID="PageContent" runat="server">
</asp:ContentPlaceHolder>
<!-- CONTENTS END -->
</div>
...

Although, you don't absolutely NEED to add it within the content DIV, I just placed it there because it's the top-most element within the content column in the layout. Technically, you can add it anywhere you'd like within the template.master file.

15Nov/090

hitMan Visual Basic Source Code (AOL PWC)

(DISCLAIMER: The software attached is NOT legal to use but is legal to view and has educational value to those who would like to learn how to connect to remote servers using the HTTP protocol (and Winsock) through their Visual Basic applications for PC. During development stages of this application it was completely legal to make such software, but is not now. You have been warned.)

hitMan was an AOL/AIM password cracker which I had developed when I was learning how to program for Windows PC's and communicating with the AOL software. It was originally developed with the intent to display to other programmers how evolved I was getting and to convey how they should also be; follow your own path and don't be a follower. It was completely programmed using Visual Basic 6.

Within the source code you will discover how to connect to a remote server and send/retrieve data (communicate through proxies also). You will also learn how to manipulate other software (specifically the AOL software) using basic Windows manipulations. I'm sure you'll also learn way to much about using Visual Basic as a whole (my primary reason for releasing this source code), like window manipulations, Windows memory usage, shell calls, etc.

Remember, if you are to compile the source files and try to use this software you could be held accountable for whatever is to happen.

Download hitMan source code here. Winrar is required.

Filed under: General No Comments
15Nov/090

To Be Releasing All My Old VB Projects Soon

I've recently decided to let the world gasp in horror and amazement at all of my old source projects which I made using Visual Basic way back in the day when I was learning how to program on PC's.

This all includes my old AOL & AIM related projects (yep, including a famous "cracker" which I made for fun back then) because I believe they all hold educational value even today. I'm currently preparing a lot of the projects for you to easily download and whatnot so give me a bit of time. I will be releasing the main source code for hitMan later on today/tonight though. Stay tuned!

8Nov/090

PHP Tips and Help

For those of you who do not know me personally or formally, here goes a bit of helpful information.

I'm currently 30 years old and I've been learning and programming with PHP for a bit over 6 years. In these past six years I've basically taught myself the language using books, ebooks, and the Internet as references and resources...and boy have I learned a lot. I wouldn't say that even at this point I am at an "Advanced" level of understanding/experience with PHP. I'd rather say that I'm around the "Intermediate" level of understanding with it. I know the true possibilities of PHP mingling with the other technologies, so I believe my "intermediate" rating for myself is almost even pushing it.

Anyways, here's some PHP tips I've picked up along the way or learned the hard way through trial and error experience. :)

1. Single Quotes Are Faster Than Double Quotes (STRINGS)

Irregardless of whatever rumor you've heard, utilizing single quotes when concatenating strings is much quicker execution-wise compared to using double quotes because when double quotes are used the PHP parser parses the string looking for string names to parse before returning the string.

Slower:
echo "$name is its name.";

Faster:
echo $name.' is its name.';

2. Absolutely, Always Sanitize User Data (MySQL)

The user of your web application is never to be trusted. Absolutely make sure to sanitize ALL incoming data from the User before interacting with it and your web databases.
At the very least:

Utilize mysql(i)_real_escape_string (PHP4.3+)
mysql_real_escape_string (earlier versions use mysql_escape_string) makes sure to add slashes for required elements, also making sure to combat many SQL injection attempts. You could also use other functions like strip_tags which further help sanitize and limit abuse of your User data.

Be Sure to Use htmlspecialchars and htmlentities (STRINGS)
Be sure, when you print data which has been submitted by the User back to the screen that you properly sanitize that data using the PHP functions htmlspecialchars and/or htmlentities.

3. The Ternary Operator Is Your Friend

If you usually write a lot of if/else statements with very few lines of code or better yet one line of code, using the ternary operator can drastically help your application by shortening the lines of code down to one and also helping the readability of your code as a whole. Take the following example into consideration:

if($aString == '1'){
   $retVal = true;
}else{
   $retVal = false;
}

Wouldn't you rather use the following instead?

$retVal = ($aString == '1') ? true : false;

4. Regardless of their Rep, Don't Completely Follow Other Developers' Techniques

You could completely disregard even me with this tip, but you really shouldn't follow other developers coding techniques without studying them yourself at least. I've learned this one the hard way by utilizing (embarrassingly) short if/then and conditional statements for a year or so without completely studying the side-effects of using said statements. Always make sure your chosen coding techniques are efficient and agile.

This is just a short list of tips and help I have to offer you about PHP. In the future I will continue this series of posts with even more tips and help with PHP so stay tuned! :)

6Oct/090

JPL Announces Discovery of Largest Saturnian Ring

Today, NASA's Jet Propulsion Laboratory announced the discovery of the largest known ring system around Saturn, the second largest planet in our Solar System, and it's quite intriguing.

This new belt lies extremely far from the gas giant, beginning around 3.7 million miles (6 million kilometers) away from the planet and continues outward for roughly another 7.4 million miles (12 million kilometers). This ring is extremely thick as well, being 20 times the diameter of the planet. Phoebe, one of Saturn's farthest orbiting moons, circles within this newly found ring, and is likely the source of the rings material.

The information I have presented here is only a very little bit of the data collected from this new discovery. For more information please see the official press release.

Filed under: Astronomy, Science No Comments
6Oct/090

So You’re Developing a Web Application, aye?

When you first decide to create a website you're obviously hit with a first question...

"Should I use a pre-made content management system or does this website and/or concept need its own custom content management system?"

Depending on the type of website this question could be easily answered.

"Does this website need any further customizations than the chosen pre-made content management system can provide?"

The answer to the previous question could be no and then you could choose from a great number of varying pre-made CMS's like WordPress, Joomla, Nuke; just to name a very few, which will get you ready for content immediately.

But, what if you have a specific idea or concept that you want to put into action? Like something a bit more unique than a basic news-style or cookie-cutter web system. Well, then it starts getting a bit more complicated to execute your concepts.

One viable option is to install and modify multiple pre-made scripts which all do the varying tasks that you wish to have. I've seen this done contently with a few of my colleagues' projects. Although, I do not recommend this.

Another great option is to utilize development frameworks, like Zend framework for PHP and Ext JS for JavaScript. This option is great if you are limited to time and money, but can get quite cumbersome if you're also limited to knowledge and experience with these frameworks.

The best option in my opinion is to create everything custom yourself. It definitely takes much more time than other methods but the physical security of the structure of your application and the ease of future updates is better and easier to do in the long run, and is the best option for creating custom CMS's. One major reason to choose this method over a framework would be because usually your own code will be less-bulky and take less overall resources to run. But, of course this method by far relies heavily on the coding skills and habits of yourself or your developers, so always keep that in mind.

In future related articles I'll delve into the world of custom web application development, focusing primarily on custom code development, but I'll also be wading the waters of framework deployment and utilization of pre-made code libraries and their integration into your own web applications.

Stay tuned. :)