marți, august 07, 2007

A Better HREF handing

After converting a list to XSLT dataview, I am having some problem with URLs inl lists, so I make it a little easy to use for editing XSLT.

To make this work, create a new list, and give it a fieldname of URL which is a link (href) type list object.

Here is a much better way to encode the a href tags:


<xsl:variable name="ThisURL" select="substring-before(@URL, ', ')" />
<xsl:variable name="ThisTitle" select="substring-after(@URL, ', ')" />
<xsl:if test="normalize-space($ThisTitle)!=''">
<div class="ms-vb2">
<A HREF="{$ThisURL}" title="{$ThisTitle}"><xsl:value-of select="$ThisTitle" /></A>
</div>
</xsl:if>


If you name the field something else like 'mylink' or something, just replace @URL in the code above with your fieldname.

Hope that help you.

joi, aprilie 26, 2007

HTML Encoder

hen using blogger, I sometimes have to put javascript into the blog post. In order to do this, I have to HTML encode it.

My favorite HTML encoder:

http://www.opinionatedgeek.com/DotNet/Tools/HTMLEncode/Encode.aspx

And just to be safe, here is my favorite URL encoder:

http://www.w3schools.com/tags/ref_urlencode.asp

Views Filtered by URL Parameter

These views are wonderful, however, when people bookmark them or stumble upon them without a URL parameter, they are nonsense.



So we use some javascript to let the user know that they have come into the page by mistake.




function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
alert('This page is for viewing a filtered report. Please return to this page with a valid filter.');
}
var IntRecordID = getQueryVariable("ID")


This will alert the user that they have come to the page without a Querystring variable and that they need to go back and rethink what they are trying to do.

miercuri, aprilie 25, 2007

Calculated Field: Quarters

The Company has a fiscal year that starts on June 1. I need a field in my list that shows what quarter and year this date falls in, so that I can sort/filter by that data instead. The Company Fiscal Quarters can be calculated.

Create a new field, calculated, and put this formula in:

=IF(MONTH([TheDate])<=6,YEAR([TheDate]),YEAR([TheDate])+1)&" Q 0"&MOD(CEILING(22+MONTH([TheDate])-5-1,3)/3,4)+1

If you are trying to do a different fiscal, change the 5 to whatever month is the last month of the quarter, and change the 6 to the first month of the quarter (november in this case):

=IF(MONTH([TheDate])<=11,YEAR([TheDate]),YEAR([TheDate])+1)&" Q 0"&MOD(CEILING(22+MONTH([TheDate])-10-1,3)/3,4)+1

You can modify it by removing the year, which will just give the quarter number (november in this case):
=MOD(CEILING(22+MONTH([TheDate])-10-1,3)/3,4)+1

And of course, you can create another field that will just give you the fiscal year (november in this case):
=IF(MONTH([TheDate])<=11,YEAR([TheDate]),YEAR([TheDate])+1)

Have Fun with this new information!

joi, aprilie 19, 2007

The Fallacy of Savings

On Sale: You can save a dollar a million times, but in the end you don't have a million dollars.

Despre mine

Timi-Ostravia, Republic of Czedvia, Bulgaria
I make web applications. The tools I use are many and far between. I have been maining to learn Ruby and Python, and Perl. These tools are all like Lego to me. They can all be make to build things and have their strengths and weakest.