Stump the Panel » End Users and Information Workers

Green Tip Web Part

(6 posts)
  1. jlschu1
    Member

    Hello! I was wondering if anyone has ran across a "Green Tip" web part? Similar to a quote of the day.

    Posted 3 days ago #
  2. Jen - More specific please. What should a "Green Tip" do? -- Mark

    Posted 2 days ago #
  3. jlschu1
    Member

    I am wanting to offer a "Go Green" web part, a tip of the day on how to live eco-friendly. Something similar to your quote of the moment.

    Posted 12 hours ago #
  4. ah I've got you.. so instead of Quote of the day your just after a webpart that will randomlyy display a list item.. In the list you would have Green tips... Nice idea, I think that is something we could use as well...

    Let me have a play and see what I can come up with.. Maybe we could share Tips as well..

    Posted 12 hours ago #
  5. ok so try this out..

    -Create a new Custom list called "Green Tips".. and add a second column called content. (make this a multi-text rich text)
    -go to the page where you want your green tips to show..
    -Add a "Content Editor WebPart"
    -edit source and paste this in

    <DIV ID="GreenPlaceholder"></DIV>
    <script type="text/javascript">
    
    var ListID = "{22B56A50-AE74-4FFC-B0DC-1AD162078A98}";
    var ServerURL = "http://server";
    var SiteURL = "http://server/site";
    
    var URLprotocolURL = SiteURL + "/_vti_bin/owssvr.dll?Cmd=Display&XMLDATA=TRUE&List=" + ListID ;
    
    var xmlhttp=null;
    try {
    xmlhttp = new XMLHttpRequest();
    } catch(e) {
    try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
    try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
    alert("Your browser does not support XMLHTTP.");
    }
    }
    }
    
    xmlhttp.onreadystatechange=StateChange;
    
    xmlhttp.open("GET",URLprotocolURL,true);
    xmlhttp.send(null);
    
    function StateChange()
    {
    if (xmlhttp.readyState==4)
    {
    if (xmlhttp.status==200)
    {
    DisplayTip();
    }
    else
    {
    alert("Problem retrieving XML data");
    }
    }
    }
    
    function DisplayTip()
    {
    var xmlDoc = xmlhttp.responseXML;
    var ListItems = xmlDoc.getElementsByTagName("z:row") || xmlDoc.getElementsByTagNameNS("*","row") ;
    var SelectedItem = Math.floor(Math.random()* ListItems.length);
    var SelectedTipTitle = ListItems[SelectedItem].getAttribute("ows_LinkTitle");
    var SelectedTipContent = ListItems[SelectedItem].getAttribute("ows_Content");
    
    document.getElementById("GreenPlaceholder").innerHTML = '<center><b>' + SelectedTipTitle + '</b></center></p>' + SelectedTipContent;
    
    }
    </script>

    You'll see the bottom part of the script,, is were the displaying is done..

    var SelectedTipTitle = ListItems[SelectedItem].getAttribute("ows_LinkTitle");
    var SelectedTipContent = ListItems[SelectedItem].getAttribute("ows_Content");
    
    document.getElementById("GreenPlaceholder").innerHTML = '<center><b>' + SelectedTipTitle + '</b></center></p>' + SelectedTipContent;

    See pics for how my quickie turned out.. I'm going to look at maybe wrapping some graphics around it.. Now any coders may say you should do this in AJAX, and I say go right ahead :) I'm a cut and paste coder.. KUDOS goes out to Mike at my work and
    http://pathtosharepoint.wordpress.com/2008/12/18/random-quote for the original idea.

    http://www.aussieslivingsimply.com.au/images/Untitled%20picture22.png
    http://www.aussieslivingsimply.com.au/images/Untitled%20picture23.png
    http://www.aussieslivingsimply.com.au/images/Untitled%20picture24.png

    Posted 8 hours ago #
  6. oh and to find your LISTID

    Navigate to the SharePoint list using the browser.
    Select the Settings + List Settings menu command.
    Copy the Url from the browser address bar into Notepad. It will look something like:
    http://server/site/_layouts/listedit.aspx?List=%7B26534EF9%2DAB3A%2D46E0%2DAE56%2DEFF168BE562F%7D

    Delete everying before and including “List=”.
    Change “%7B” to “{”
    Change all “%2D” to “-“
    Chnage “%7D” to “}”
    You are now left with the Id:

    {26534EF9-AB3A-46E0-AE56-EFF168BE562F}

    Posted 8 hours ago #

RSS feed for this topic

Reply

You must log in to post.