Tuesday, December 8, 2009

Content query webparts and the HTML Formatting

So this entailed using the CQWP to render an approved article with an image and a 1000 character description.
I created the webpart and its able to pull the image but when it pulls the description it renders the HTML version as opposed to the innerText.
Create "div" tags around the description(value in the XSL) which you can refer to later
so the simple solution is to make the HTML equal to the innerText...

var myText = document.getElementById('div tage name')
myText.innerHTML = myText.innerText

Great it does what was intended and renders the HTML correctly...
BUT..and there is always a BUT..
this works fine in IE but firefox returns an "undefined"...
so back to the drawing board ... :(

so after banging my head ... i decided to check the firefox rendering engine which is GECKO...
now i learn that IE knows about innerText and firefox doesnt know abt it....
go figure this is supposed to be standardised ...
so here's my solution ....


so now i decide ...if the browser returns an undefined then it has to be firefox which i know i have to use "textContent" instead of "innerText"
And PRESTO ..... everybody WINS...

till next time ...

Wednesday, August 5, 2009

How to get the last element that was added to a SharePoint list

This is so simple yet I could not find anything on the net .... but lucky for you i'm smart like that ... J

So my scenario:

I needed to get the last item added a list which doesn't seem like a hard thing to do but the way in which I was doing it was not the most efficient. So what I was doing was running through the list with a FOR LOOP and finding the last element. Only problem with this is that the list will eventually get very big and this can affect performance.

So the other more efficient solution is converting the list to a data table and then just pulling the last element in the table ... doesn't that sound a whole lot simpler... so here is the code =>

SPList targetList = web.Lists["SomeList"];

DataTable dt = targetList.Items.GetDataTable();

string lastID = (dt.Rows[dt.Rows.Count-1]["ID"]).ToString();

ok so once you get the ID you can find the item in the list by=>

SPListItem item = l.Items.GetItemById(Convert.ToInt32(lastID));

I hope people find this useful

Till the next problem...

 

Tuesday, August 4, 2009

Bypassing the login.aspx (FBA) when a search result is clicked in Moss 2007

Problem statement

We had to create an intranet blog as well as an internet facing blog, both would have the same data. It would be treated like an "authoring" paradigm. Without going into too many details the FBA (Forms Based Authentication) was setup for the external site and windows authentication setup for the internal site compliments of Bramley.

Everything was cool until a problem popped up when the ANON user does a search and one of the search results is clicked. This then takes the user to the FBA login screen and wants the ANON user to log in before it will display the page. This becomes a major pain if users are asked every time they click on a search result to authenticate themselves.

It's such a simple change but took us a whole day and a half to figure out .... J

Go to your login.aspx page on the file server which can be found under the "layouts" folder in the 12 hive.

Add this code to the login.aspx

<script runat="server">

protected override void OnLoad(EventArgs e)

{

//returnWebUrl is the url of the search result that was clicked

string returnWebUrl= Server.UrlDecode(Request.QueryString["ReturnUrl"]);

//set the auth cookie and the redirect

FormsAuthentication.SetAuthCookie("anonymoususer", true);

Response.Redirect("http://sharepoint/"+returnWebUrl);

base.OnLoad(e);

}


</script>


And this should solve the problem of bypassing the FBA login.aspx screen when a search result item is clicked.

Thursday, July 23, 2009

How to set the THEME of a Mysite.

  1. Open the Mysite in SharePoint Designer.
  2. On the top menu go to "Site" => "Administration" => "Administration Home"

  3. Then you will be presented with the following screen:

    Then click on "Site Theme"

  4. Chose the theme and click apply:

Till next time.

Monday, June 22, 2009

Publishing Template(Export and Import) Problem

This is a problem i have been having..
scenario:
i created a site using the publishing site with workflow as the site template. We then exported this site using stsadm.exe(export function) and then importing (stsadm.exe). The problem starts now as the publishing workflow that should be there by default is doing some rather strange things.
first of all if you edit a page and then "Submit for Approval", you don't get the start approval screen.
look below at the picture.








so the solution that worked for me was to recreate the workflow on the "Pages" document library using a new "Task" list and a new "Workflow History" list and when you submit a page for approval you should get the "Start Approval" screen.PROBLEM SOLVED!!!!!!!!

Monday, June 15, 2009

iFilter v6.0 and Sharepoint

We had a problem with setting up *.pdf documents to be indexed in Sharepoint.
Everything worked fine in our Staging machine and just did not want to index the .pdf documents in PROD.

So this worked for me ...
1. Remote into the indexing machine (sufficent privillages will be required )
2. Stop the IIS Admin Service (services=>IIS Admin Service)
3. Run the setup for the iFilterv6.0(http://www.adobe.com/support/downloads/thankyou.jsp?ftpID=2611&fileID=2457)
4. Start the IIS Admin Service
5. Go to the following URL, http://www.adobe.com/misc/linking.html, and download the 17x17 icon image as “icpdf.gif”.
6. Go to every(assume more than 1 WFE) Web Front End Server, copy the image to the following location: "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Images".
Then go to C:\Program Files\Common Files\Microsoft Shared\Web server extensions\12\Template\Xml\ and open DOCICON.XML by adding the following entry

7. Now go to Central Admin site => your SSP => then click on Search Settings=>Click "File Types" =>then add "pdf" then click "OK" .
8. Stop and then start the Windows SharePoint Services Search service. To do this, follow these steps:a. Click Start, click Run, type cmd, and then click OK.
b. Stop the Windows SharePoint Services Search service. To do this, type net stop spsearch at the command prompt, and then press ENTER.
c. Start the Windows SharePoint Services Search service. To do this, type net start spsearch at the command prompt, and then press ENTER.
d. Type exit to exit the command prompt.
9. Add the following registry entry, and then set the registry entry value to pdf:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Applications\\Gather\Search\Extensions\ExtensionList\38
a. To do this, follow these steps: a. Click Start, click Run, type regedit, and then click OK.
b. Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Applications\GUID\Gather\Search\Extensions\ExtensionList
c. On the Edit menu, point to New, and then click String Value.
d. Type 38, and then press ENTER.
e. Right-click the registry entry that you created, and then click Modify.
f. In the Value data box, type pdf, and then click OK.
. Verify that the following two registry subkeys are present and that they contain the appropriate values.
Note these registry subkeys and the values that they contain are created when you installed the Adobe PDF IFilter on the server.
• HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Setup\ContentIndexCommon\Filters\Extension\.pdf
This registry subkey must contain the following registry entry:• Name: Default
Type: REG_MULTI_SZ
Data: {4C904448-74A9-11D0-AF6E-00C04FD8DC02}
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Setup\Filters\.pdf
This registry subkey must contain the following registry entries:
• Name: Default
Type: REG_SZ
Data: (value not set)
• Name: Extension
Type: REG_SZ
Data: pdf
• Name: FileTypeBucket
Type: REG_DWORD
Data: 0x00000001 (1)
• Name: MimeTypes
Type: REG_SZ
Data: application/pdf
10. If you already have a .pdf document on the site just edit one of its metadata properties so sharepoint knows that it should crawl it since its meta properties has changed.
11. do a full crawl on the content source(Central admin=>SSP=>Search Setting=>Content sources and crawl schedules=>click the drop down on the content source and then click "Start Full Crawl"
12. Wait till the crawl finishes and then search for the .pdf document.

Wednesday, May 20, 2009

Hi all...
just a little insight as to what i have done ... and what is to come ...
This BLOG will be a little insight into the expansive void know as Sharepoint and MY experiences with it.
All the tricks/tips i have found while trying to deploy a solution will be shown.

Till the next post...