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

Register.com
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.

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

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. :)

23Sep/090

HTML 5…The End All Be All…Almost

The evolution of the HyperText Markup Language has definitely been a long one and now is finally coming to a crossroads where it will be putting out of business many other technologies developed in the past to handle HTML's inadequacies. The new version of HTML is almost ready for professional trials and to say the least I'm pretty excited about it...and I'm sure many others are as well.

To start, the HTML5 syntax is no longer based on SGML (the kind-of parent of the older HTML versions), but will be backwards compatible of course. Second, an obvious change is the complete drop of purely visual elements, like the "font" and "center" elements, along with new element additions to handle basic layout presentation, like "nav" and "footer". Also, the addition of elements like "audio" and "video" will make it easier than ever to embed those types of objects into your HTML pages.

One major improvement to the language is the addition of Scalable Vector Graphics. With SVG you can literally add graphical elements into a web page with ease using simple element tags with their various attributes and values. This alone is a HUGE improvement compared to what is needed in order to accomplish things like this at present using older versions of HTML and XHTML. (Presently you need to utilize and embed other technologies and/or code libraries like Flash, MS Silverlight, dojox.gfx, or Java to accomplish this.)

Another awesome addition is the use of APIs. The APIs will include everything from utilizing offline storage databases to embedded document editing.

One other major improvement in my eyes which I'd like to mention is the error handling abilities within the new specification. The HTML5 specification gives detailed rules for lexing and parsing, with the intent that different compliant browsers will produce the same result in the case of incorrect syntax. What does that mean? No more jacked up looking web pages because of non-compliant code embedded within them. You will be able to safely update your pages without the entire world laughing at your non-compliant code jacking up your pages.

Enough rambling from me, here's an awesome HTML5 introduction video produced by Brad Neuberg from Google Developer Programs:

 
Further reading:

HTML5 Specification Overview (DEV)
HTML5 Specification Working Draft
HTML5 on Wiki

13Sep/090

Use Ext JS Without Paying for the Bandwidth!

Ever since Ext JS has become so popular amongst other web developers there has been a huge influx of interested developers. One of these such interests has evolved into a huge help to the Ext JS community as a whole. On November 18, 2008 Abraham Elias of Ext success posted an article titled Ext CDN - Custom Builds, Compression, and Fast Performance. Ever since it's been easier than ever to include the amazing Ext JS libraries to your projects and websites.

The company CacheFly has graciously stepped forward to contribute their valuable resources to the Ext JS project. Thank you CacheFly.

9Sep/090

Ext JS…The Better JS/UI Library

I have to absolutely agree with recent technology reviews stating that the Ext JS library is amongst the best user interface/ajax libraries available today. I originally found out about the library immediately after its initial creation...when the original YUI library for it was introduced to the open source community. In mid-2005 to early 2006 "Ext" came to fruition as a few really cool "widgets" placed wherever you would like on the web if you had a server for yourself somewhere. Now, Ext JS has evolved into a very large JavaScript User Interface library consisting of everything from basic "AJAX" functionality to features as large as completely customizable User Interface widgets and Adobe AIR integration.

But, we're misleading you. By classifying Ext JS as a "User Interface" library we've been leading you to believe that it is such. Well, it definitely is not. It's so much more than just a user interface library. For example, you can use other user interface libraries with Ext JS, like Scriptaculous and jQuery, using a really easy to use Ext adapter. I urge you to discover more information about Ext JS.

In the near future I'll be writing much more about this new fangled Ext JS library (3.0); tutorials, news, etc. In the past I've written a few introductory tutorials which have been getting a bit of notice and have helped a few people get their bearings with Ext JS and its Forms. For more information about Ext JS please see their website here.

16Jun/070

Remove The “Extended Network” Text From Your Myspace Profile

So I figured out how to remove the text that says "Name is in your extended network." recently and now I'll post it here for you. NOTE: This just removes the text, not the whole table. Just simply place this code anywhere in your profile:

<style="text/css">span.blacktext12 {
visibility:visible !important;
background-color:transparent;
font-size:0px; letter-spacing:-0.5px;
width:435px; height:75px; display:block !important; }
span.blacktext12 img {display:none;}</style>

Filed under: CSS, MySpace Codes No Comments
16Jun/070

Remove The “Add Comment” Link In Your Myspace Profile

Well, for some reason or another I'm sure some of you would rather not let people leave comments or not be able to find the link to add a comment in your Myspace profile. Well, if that's so then I have a piece of code that may be of use to you. But please realize that a diligent ''Myspacer'' may still find a way to add their comments. Just simply place the following code anywhere in your profile:

<style type="text/css">td.text td.text td td a, .redlink, td.text td.text td b a {visibility:visible!important;}
td.text td.text td a {visibility:hidden;}</style><a href="http://www.beneskew.com" target="_blank"><img src="http://www.beneskew.com/img/myspace2.jpg" alt="Myspace Codes & Stuff" style="position:absolute; left:0px; top: 0px; z-index:9;" border="0" /></a>

Filed under: CSS, MySpace Codes No Comments