Fieldset allways round corners

If you have you ever used fieldset in your web projects you will know that it looks different in every browser. BUMMER and if you try to style it it looses its round corners and highlights. Thats is so annoying. So i’ve decided to do something about it. Fielset now we wil all know your secrets. (c:
As far as I know, it’s impossible to solve this dilemma with CSS2 alone, so after some consideration I’ve decided to try with webkit and some other tricks as the last resort. And SUCCESS.. round corners in all browsers, I love it.
her’s what i’ve done.

To my CSS i’ve added following

FIELDSET
{
   padding:10px;
   border-color:Fuchsia;
   -moz-border-radius: 4px;
   border-radius: 4px; 
   -webkit-border-radius: 4px;
}

LEGEND
{
    text-transform:uppercase;
}

Round Fuchsia Corners, so pretty ,.. (c:

Advertisements

Wondering why there are no labels on richtext editor in umbraco ?

I must admit that it is wired that if you use richtext editor out of the box in Umbraco 4.5x you would be suprized to find that labels are missing on all rich-text editor fields. It tok me a while to realize that th problem was in the setup of the rich-text editor datatype,.. it was quite Dough moment when i realized it,.. (c: To setup,.. just go to the developer section and find and click on the datatype folder. Then scroll down and click on the “Richtext editor” datatype to change the settings. Look for “Show label” checkbox and check it ,.. thats it,.. and of course don’t forget to save (c:

How to push a button from serverside using ScriptManager and UpdatePanel control.

I was playing around with an idea that it could be fun to press client-side logoff button from the server-side. Like if you dont push the logoff button i will push it for you,.. noition..(c: To achive that i devised a way to “inject” javascript in to an UpdatePanel using ScriptManager.. so cool,.. it is kind of nougty i guess..
her’s how it’s done:
aspx

<asp:ScriptManager ID="scmAJAX" EnablePartialRendering="true" runat="server"/>
<asp:UpdatePanel ID="upnl_Mask" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:label ID="lbl_Mask" runat="server"></asp:label>
</ContentTemplate>
</asp:UpdatePanel>

aspx.cs

string jscript = @"$(window).ready(function (){ $("".btnLogoff INPUT"")[0].click();});";
ScriptManager.RegisterClientScriptBlock(lbl_Mask, lbl_Mask.GetType(), "youLoggedOffDoode", @"javascript:" + jscript, true);

lbl_Mask.StatusText = "You are termibated"; // sara Coner sead that
upnl_Mask.Update();

i am using JQuery in my javascript,. but i bet you could do something like this “document.getElementById(‘logoff_btn’).click()” to click the button,.. but then you have to get your asp:button ClienID,.. like this “document.getElementById(‘” + logoff_btn.ClientID + “‘).click()” .. the DOM ready event is a Whole other story..

SQL equivalent to Last()

We all love Linq in all its glory, but from time to time you have to write raw SQL queries (c: and it is fun to, don’t get me wrong, but it doest have the same range of ready to use functions as Linq.

This time i needed to find the last element from a table with at least trazillion rows, this is how i did it.

SELECT * FROM  tableName
WHERE   id = (SELECT MAX(id) FROM tableName)

You can posibly wrap it in to a CREATE FUNCTION, but this worked for me as it is,.. (c:

if you table doesn’t have an id with which hold the usable number you can do somthing like this

SELECT MAX(rownr) FROM (
SELECT ROW_NUMBER() OVER(ORDER BY customerText DESC) AS rownr
  FROM bbc) AS Q

the customerText is a name for any kind of column in your table ..

Releace of my own Umbraco based webpage.

For little bit more then the past month time I’ve been working on designing and developing my own webpage. For this task I’ve chosen Umbraco CMS engine, beacouse of it’s similarities with Sitecore, but allso because it is free to use. I’ve was pleasantly surprised on the helpfulness of the Umbraco community, and i like to contribute my knowledge to further Umbraco development by posting articles about it on my blog.

To differ my self from all the other mass-produced templated webpages outhere, I’ve designed and implemented my own look and feed for my webpage.
my webpage design
The main idea behind this webpage is to make a content driven webpage not a blog. I’ve written an article about how this webpage came to being and i am going to write further articles in the future on how i did it. More about the nuts and bolts of it all. (c: So sign up for an RSS feed, so you can keep up.

here are some highlights of the implementation.

  • youtube integration
  • Custom developed tag based article system
  • Lucene index search results
  • Tag and Related articles lists.
  • Umbraco based contact form(creates nodes in umbraco, so i can see a feed of all new items when logged in)

If you have any comment’s pleas tell me i wood like to hear your opinion.

Get YouTube video JSON Data using JQuery and Ajax

Earlier I’ve written an article on how t get Youtube data using JSON and it was a blast, but i had a litlle cosmetic drawback. You had to put script tags in your markup.   It works but it’s not pretty (c: . One of the easiest ways to load JSON data onto our website is to use the $.ajax(), which is a very useful JQuery method.  Her’s my way of doing it.

      $.ajax({
            type: "GET",
            url: "http://gdata.youtube.com/feeds/users/[USERNAME]/uploads?alt=json-in-script&format=5",//generateJSonPlayListCallBackUrl(),
            cache: false,
            dataType:'jsonp',
            success: function(data){
                showMyVideos(data);
          }
        });

I’ve taken the showMyVideos() from Google’s Json documentation article it’ will display a list of video titles from a given Youtube  users Chanel.  To use this code snippet just replace [USERNAME] with a Youtube user name, and put inside a JS file (c: Take notice of dataType:’jsonp’, thats the important bit. This allows us to retrieve youtube data back to our domain (c:

well thats it for to day,.. stay frosty people,..

How To make Search for Umbraco site with Lucene.Net, Examine and XSLT

Being able to search content in a website is probably the most common and most important feature of any website. And there are a millions ways to do this,.. so why use Lucene indexing or Eximine for that matter..   If you have been looking inside the umbraco bin directury you will notice a wary nice Lucene.Net.dll file. This is one of the reasons for why i chose  Lucene indexing, because it is already there (c:
Umbraco uses Lucene indexing to search it self, if you’ve ever wondered where those files hidden, they’re in the “/data/_systemUmbracoIndexDontDelete” folder.  There you’ll find at least one .cfs file, a deletable and segments file.

In my setup i wanted to separate my indexes from the ones Umbraco generates,  so -i chose  Examine to do the heavy lifting, of generating indexes on so on.  Examine has loads of useful features, i will not recite them all but you can read about them here. So I downloaded the demo site from the FarmCode.com to take a closer look at the Examine set up, and because i was curious.. (c:

After a quick run-thought the demo-site and its macros and other code,  i copied all the related DLL.

  • Lucene.Net.dll(lates version)
  • Examine.dll
  • UmbracoExamine.dll
  • UmbracoExamine.Contrib.dll

And completed the setup, which can be found here on the FarmCode.com site.

I’ve noticed that the UmbracoExamine.Contrib.dll han an XSLT extension, so i added  it to my xsltExtensions.config

<?xml version="1.0" encoding="utf-8" ?>
<XsltExtensions>
        <ext assembly="/bin/UmbracoExamine.Contrib" type="UmbracoExamine.Contrib.XsltExtensions" alias="examine" />
</XsltExtensions>

and wrote a small XSLT macro to test it.

<xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:examine="urn:examine"
        xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib"
        exclude-result-prefixes="msxml examine umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib ">
<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:param name="currentPage"/>
<xsl:template match="/">
  [[<xsl:value-of select="examine:Search('something')"/>]]
</xsl:template>

But it resulted in an “Error parsing XSLT file: \xslt\SearchPosts.xslt” error.. grrr,.. Nothing i did could make it good again,.. the XSLT code was pretty simple and the xsltExtensions.confiq was carrect.  As it tuns out the “UmbracoExamine.Contrib.dll” is not released yest (c:  thanx Lee

So in stead of getting frustrated and angry i’ve decided to write my own SearchExtension Class ,..  (c: Her is the busines end

//remember to add these (c:
//using Examine;
//using UmbracoExamine.SearchCriteria;
//using UmbracoExamine;
//using Examine.SearchCriteria;

public static XPathNodeIterator Search(string searchTerm, string field)
{
      return Search(searchTerm, field, "MySearcher");
}

public static XPathNodeIterator Search(string searchTerm, string field, string searchProvider)
{
//get query string search param & error check
if (string.IsNullOrEmpty(searchTerm)) return null;
var criteria = ExamineManager.Instance.CreateSearchCriteria(IndexType.Content, Examine.SearchCriteria.BooleanOperation.Or);

ISearchCriteria filter = criteria
   .Field("bodyText", searchTerm.Fuzzy().Value)
   .Or()
   .Field("menuTitle", searchTerm.Fuzzy().Value)
   .Compile();
XDocument node = new XDocument();
XElement content = new XElement("nodes");
//get the search results from the mysearch provider
foreach (SearchResult result in ExamineManager.Instance.SearchProviderCollection[searchProvider].Search(filter).AsEnumerable().Where(res => (res.Score * 10) > 2).OrderBy(res => res.Score))
{
   XElement element2 = new XElement("node");
   XAttribute attribute = new XAttribute("id", result.Id);
   XAttribute attribute2 = new XAttribute("score", result.Score);
   element2.Add(new object[] { attribute, attribute2 });
   foreach (KeyValuePair<string, string> pair in result.Fields)
   {
      XElement element3 = new XElement("data");
      XAttribute attribute3 = new XAttribute("alias", pair.Key);
      XCData data = new XCData(pair.Value);
      element3.Add(new object[] { attribute3, data });
      element2.Add(element3);
   }
content.Add(element2);
}
node.Add(content);
return node.CreateNavigator().Select("/");
}

After you have copied your DLL to umbracos bin dir and added it to the  xsltExtensions.config like describe above,.. It’s time to write the XSLT macro,.. this is my version (c:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:mySearch="urn:mySearch"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib"
exclude-result-prefixes="msxml mySearch umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="currentKeyWord" select="$currentPage/data[@alias='KeyWords']"></xsl:variable>

<xsl:template match="/">
   <xsl:variable name="searchResult" select="mySearch:Search(string($currentKeyWord),string('KeyWords'))" />
   <xsl:if test="count($searchResult/nodes/node) != 0">
      <ul>
      <xsl:for-each select="$searchResult/nodes/node">
         <xsl:sort order="descending" select="./data[@alias = 'updateDate']"/>
            <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
            <xsl:value-of select="./data[@alias = 'menuTitle']"/>
            </a>
            </li>
      </xsl:for-each>
      </ul>
   </xsl:if>
</xsl:template>

Notice that I am using ./data[@alias = ‘updateDate’] to probe for the fields stored in my LuceIndex.  Thats sums it up (c:

Happy coding..