Showing posts with label Dynamic Web CMS. Show all posts
Showing posts with label Dynamic Web CMS. Show all posts

Friday, December 19, 2008

How to rename a Dynamicweb Stylesheet

In Dynamicweb CMS you have so-called "Stylesheets" which are used as containers for various page/site related settings: Layout, navigation etc. You cannot by default rename them - but if you are lucky to have access to the SQL database in which your soloution is store you can use these sql queries below to rename your stylesheets:

  1. Find the information about the excisting stylesheets:
    select * from StylesheetStylesheet where StylesheetStylesheetParentID = 0

    You will get information like this:
    StylesheetStylesheetID [Integer]
    StylesheetStylesheetParentID [Integer]
    StylesheetStylesheetNodename [String]
  2. To rename a given Stylesheet, use the above information to generate your sql query, for instance:
    UPDATE StylesheetStylesheet SET StylesheetStylesheetNodename = 'My new name'WHERE (StylesheetStylesheetID = '4')

Friday, December 12, 2008

DwTemplateTags in XSLT templates

Well, to find out which template tags are availiable when working with XSLT templates in Dynamicweb CMS you need to insert this:

<xsl:text disable-output-escaping="yes"><![CDATA[<!--@DwTemplateTags-->]]></xsl:text>

Tuesday, September 30, 2008

Adding general handling fee in Dynamicweb eCommerce

I had the challange resently to add a default handling fee to a eCommerce soloution implemented using Dynamicweb eCommerce. After struggling a while with it I found a soloution. I created a negative sales discount on the amount which every customer would have to pay if the total amount was no more than a given amount.

So you simply create a discount - a "Total Sales Price Discount" on a given NEGATIVE amount of money. You also define a rule which takes care of the limit given in your case, say: "The customer should spend more than 1000€, before the handling fee will be zero".

It is perhaps not a very logical way - but it works! :-)

Tuesday, August 5, 2008

Anything in the basket?

If you have a Dynamicweb Web soloution with eCommerce you may want to inform the visitor/customer about the number of products in the basket. One logical place to add this information would be on the PAGE template - and yes, it's that simpel!

A very simpel example would be to add:

In basket: <!--@Ecom:Order.OrderLines.TotalQuantity--> products

Unfortunally if there is nothing in the basket Dynamicweb will just leave the tag unpassed, so your HTML code will not contain "0" if nothing is in the basket.

To solve this situation you will need to write some javascript. I Suggest that you put the basket information inside - say - a DIV with a specifik ID ("GlobalBasket" for instance) and then set the CSS Display to "none". The javascript code should then toggle the CSS Display attribute if nessesary.

Here is a simple example:

<div id="GlobalBasket" style="display: none">
<b>In basket: <!--@Ecom:Order.OrderLines.TotalQuantity--> products</b>
</div>
<div id="GlobalBasketEmpty" style="display: none">
<b>Basket is empty</b>
</div>
<script type="text/javascript">
var iQuantity = parseInt('<!--@Ecom:Order.OrderLines.TotalQuantity-->');
if (iQuantity>0 || !isNaN(iQuantity)) {
document.getElementById('GlobalBasket').style.display = 'block'; // Or Inline
} else {
document.getElementById('GlobalBasketEmpty').style.display = 'block'; // Or Inline
}
</script>


I have added a "GlobalBasketEmpty" DIV to this example - it will be show in case of the basket is empty.

Thursday, July 3, 2008

Visit my BLOG at Dynamicweb

From time to time I am writing "articles" on a blog at my job @ Dynamicweb A/S. You might find them interesting - so visit my blog @ Dynamicweb.

Thursday, May 15, 2008

Documentation of Dynamicweb CMS

Here are some important places for finding documentation for Dynamicweb CMS:
A portal of information about Dynamicweb (and Syncron VIA):
http://documentation.dynamicweb.dk/

The system - running examples of use and how-tos:
http://demo.dynamicweb.dk/

Back-end online manual:
http://manual.net.dynamicweb.dk/

Templates online manual:
http://templates.dynamicweb.dk/

Tuesday, May 13, 2008

Change layout (stylesheet) using querysting "StyleID" in Dynamicweb CMS

It is possibel to change the Dynamicweb CMS stylesheet on a page using a querystring "StyleID".

You simply add the "StyleID=123", where 123 is the ID of your stylesheet. To find that number you login to your CMS soloution, choose "Stylesheet" and move the mouse over the stylesheet. In the window status bar you can see the id.

Tuesday, April 8, 2008

Filtering in module DatabasePublisher

If you are using the module DatabasePublisher in Dynamicweb CMS, it is possibel to make dynamic filtering of data. The syntax is based around 3 querystring params.

Take this example: filterName=myCol&filterCondition=>=&filterValue=12

filterName = The name of the column
filterCondition = The condition to use (normal <, >, =, like...)
filterValue = The value to use in the filter.

The above example would make DatabasePublisher generate a where statement:
"where myCol>=12"

You may repeat a column more than once! If for instance you wish the value to be greater that 12 but less than 25:
filterName=myCol&filterCondition=>=&filterValue=12&filterName=myCol&filterCondition=<&filterValue=25

Wednesday, March 26, 2008

How to empty a card in Dynamicweb Ecommerce

You can empty the card using any URL inside your site, just extend the URL with these params: CartCmd=emptycart

Monday, March 17, 2008

Save the XML navigation data

When working with XSLT based menues in Dynamicweb you will need to see the actual XML document which your XSLT works with - you can extend the URL with: "SaveXml=True" and a XML document will be saved in "Templates\Navigation". A dynamic name will be applied - for example: "TestNavigationData137.xml".

You may read about this here: http://www.dynamicweb.dk/Developer-forum-25346.aspx?action=ShowThread&ThreadID=163

Thursday, March 13, 2008

Show tables in a database

If you want to know which tables are defined in a (MS) database you can enter this SQL query:

select name from sysobjects where xtype = 'U'
order by name

Friday, February 8, 2008

eval function in any browser!

Working a lot in frontend environment you sometimes have to do "eval()" in javascript. That function is not standard for all browsers.

Firefox for one does not support it! No problem! Here is a simple script you can put in the top of you page. It will ensure that a working eval function is present!

Try it out! - Enter code and press "eval"





<script language="javascript" type="text/javascript">
<!--
if (typeof(eval)=='undefined') {
eval = new Function(s, '_dynamicCode = new Function(s);_dynamicCode()')
}
// -->
</script>

isValidEmail(sEmail)

How many times have you wished that some build-in checks existed in the Regular Expression object? One on the ones which I use often is a check if an e-mail address is valid - so here you are! You may use it as you like! :-)




function isValidEmail(sEmail)
{
var pattern = "^[a-zA-Z0-9._+&*# -]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$"
var regex = new RegExp(pattern, 'ig');
return regex.test(sEmail);
}

Tuesday, November 27, 2007

How to: Demask a masked e-mail address in Dynamic Web

In Dynamic Web CMS you can choose that all e-mail adresses will be "masked". If you from a javascript wish to get the "demasked" version of such a value you can use this function:


function getDemaskedEMail(sEmail)
{
if (sEmail.substr(0, 2)=='&#' && sEmail.substr(sEmail.length-1, 1)==';')
{
sEmail = ';'+sEmail+'&#';
sEmail = sEmail.split(';&#');
var ss = '';
for(var i=0; i<sEmail.length; i++)
{
if (sEmail[i]!='') {
ss+=String.fromCharCode(sEmail[i])
}
}
sEmail = ss;
}
return sEmail;
}

Monday, November 26, 2007

How to: Show more than one group i Dynamicweb ECommerce

If you want to display more than one group in Dynamicweb ECommerce you should put a ECom module "varekatalog" on a paragraph. You need not choose in backend which group you wish to display - that can be done in the querystring or the post data you send to the URL.

If you wish to display "GROUP20" you will use an URL alike this:
http://sth.net.dynamicweb.dk/Default.aspx?ID=8&GroupID=GROUP13

If you wish to display more than one group - use this syntax:
http://sth.net.dynamicweb.dk/Default.aspx?ID=8&GroupID=GROUP13,GROUP14

Monday, November 19, 2007

How to make a file download link in Dynamic Web

Sometimes you want the user to be able to just download a file you point to from your Dynamic Web CMS homepage. What you need to do is simple:
  • Prefix your filepath with:
    /Admin/Public/DWSDownload.aspx?File=

  • If your file is here:
    /Files/files/myFile.txt

  • Resulting URL:
    /Admin/Public/DWSDownload.aspx?File=/Files/files/myFile.txt

If the file path is written using Javascript you should
escape()
the file path.

Wednesday, November 14, 2007

Return the XML input document

This XSLT document will return a copy of the input, usefull if you do not know the structure of the XML which you need to transform:


<?xml version="1.0" encoding="UTF-8"?>
<?xml:namespace prefix = xsl /><xsl:stylesheet fo="http://www.w3.org/1999/XSL/Format" xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output declaration="yes" encoding="utf-8" indent="yes" method="html">
<xsl:template match="/">
<xsl:apply-templates select="*@*node()comment()processing-instruction()">
</xsl:template>
<xsl:template match="*@*node()comment()processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="*@*node()comment()processing-instruction()">
</xsl:copy>
</xsl:template>
</xsl:stylesheet></p>
</xsl:apply-templates></xsl:apply-templates></xsl:output>

Wednesday, October 31, 2007

Handy VS2005 macro for Dynamic Web

This VB macro is a handy utility for use in Microsoft Visual Studio 2005 when editing Dynamic Web Templates. It til insert a remark at the begining of the template which says in which directory the template is placed, and the name of it.




It also inserts a not active <!--@DwTemplateTags-->, a tag which at the time where the template is rendered, will show you which template tags are availible, and their values.





  • Copy'n'paste the code below into a file named (for instance) "DwUtils.vb"

  • Save it and import it into VS2005.



Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module DwUtils


Sub prepareTemplate()
Dim doc As Document
Dim desc As String
Dim sName As String
Dim sPath As String
Dim i As Integer
Dim temp As Array


doc = DTE.ActiveDocument
sName = doc.Name
sPath = doc.Path
temp = sPath.Split("\")
desc = ""
For i = temp.Length - 3 To temp.Length - 1
desc = desc & "/" & temp(i)
Next
sName = desc & sName

Dim textSelection As TextSelection

textSelection = DTE.ActiveDocument.Selection
textSelection.GotoLine(1)
textSelection.Insert("" & vbCrLf)


textSelection.EndOfDocument()
textSelection.Insert(vbCrLf & "")
End Sub
End Module

Friday, August 17, 2007

How to change Quantity on a orderline in Dynamicweb ECom

You should create an URL which contains:

URL: The page which contains the shoppingcard
CartCmd: 'orderline' - tells Dynamicweb that you want to alter an orderline
quantity: The quantity you wish to add(!), so to go from 10 to 2 set it to -8 (!)
key: The orderlineID - get from DW templatetag:

Example:
http://www.myshop.dk/default.aspx?id=4131&CartCmd=orderline&quantity=10&key=OL2148

Monday, January 22, 2007

RegExp validation of zip codes

Sometimes when sites are multi language you need some Javascript to validate ZIP codes for several countries. Here are some regular expression objects which you chan use:

var oRegExp_NoValidation = /.*/ig;
var oRegExp_DDDD = /^\d{4}$/ig;
var oRegExp_DDDDD = /^\d{5}$/ig;
var oRegExp_DDDDDD = /^\d{6}$/ig;
var oRegExp_Uk = /[A-Z][A-Z]?[0-9][A-Z0-9]? ?[0-9][ABDEFGHJLNPQRSTUWXYZ]{2}/ig
var oRegExp_DDDD_AA = /^\d{4}.[A-Z]{2}$/ig;
var oRegExp_DDDD_DDD = /^\d{4}-\d{3}$/ig;


I then create an object for the countries which I need to validate ZIP code for:

// countryCode:[regExpToUse, bLooseValidation]
// bLooseValidation => "not sure if postcode should confirm 100% to validator" :-(
var countryCodeRegExpRelation = {
dk:[oRegExp_DDDD, false],
be:[oRegExp_DDDD, false],
uk:[oRegExp_Uk, true],
fr:[oRegExp_DDDDD, false],
nl:[oRegExp_DDDD_AA, false],
it:[oRegExp_DDDDD, false],
lu:[oRegExp_DDDD, false],
po:[oRegExp_DDDD_DDD, false],
ch:[oRegExp_DDDD, false],
es:[oRegExp_DDDDD, false],
de:[oRegExp_DDDDD, false],
at:[oRegExp_DDDD, false],
cn:[oRegExp_DDDDDD, true],
us:[oRegExp_NoValidation, true],
UNKNOWN:[oRegExp_NoValidation, true]
}


Each country becomes a property of the object "countryCodeRegExpRelation", and it also has a definition stateing if it should be "strict". To get the RegExp for a ZIP code in say Polen, you should use the RexExp in the property: "countryCodeRegExpRelation.po[0]".

You might use this code to validateZIPCode:

function validateZIPCode(sCountryPrefix, sZIPCode) {
var oRegExp = countryCodeRegExpRelation[sCountryPrefix][0];
if (sZIPCode.match(oRegExp)!=null) {
return true
} else {
alert('ZIP code not valid!');
return false;
}