On Sale: You can save a dollar a million times, but in the end you don't have a million dollars.
joi, aprilie 19, 2007
miercuri, aprilie 18, 2007
Some better Javascript for Editforms
From this discussion group:
<script language="javascript">
<!--
document.forms('OWSForm').elements('urn:schemas-microsoft-com:office:office#
YOURFIELDNAMEHERE').disabled=true;
document.forms('OWSForm').elements('urn:schemas-microsoft-com:office:office#
YOUROTHERFIELDNAMEHERE').disabled=true;
//-->
</script>
One caveat: If the FIRST field on the form is disabled, you'll get an error about not being able to set the focus to it.
Etichete: Edit, FrontPage, JavaScript, List, SharePoint
luni, aprilie 16, 2007
How to make a blog with SP 2003
How to make a blog with SP 2003:
The basic idea is to use the historical/version control feature of the issues list to keep track of the blog and keep the comments information.
The Title, Due Date and Description are the main 'blog' parts. The title is the title, the description is the blog post, and the Due Date is the post date.
The Comments field is where the blog gets really interesting. What is actually happening is that when someone posts a blog entry, they are adding a new item to the list. When someone else (or the blogger) wants to 'add' a comment, they are not actually adding anything – they are EDITING the blog post item, and putting their own comments in!
The tricky part is working with permissions so that people do not have 'add' capabilities, nor do they have the capability to edit the title, description, or post date fields, and we only give them the ability to edit the comments field. Since SP already keeps track of versioning, each version is just another edit to the original post.
Some of the links include a 'source' query string variable. This is passed from some pages to other pages so that Share Point can pass the user back to the proper page whenever the user saves or deletes or adds or takes other actions. The value of the source variable when used in this tutorial is a URL-encoded URL pointing back to the default view page of the list you are using. You can copy and paste your URL into a tool here: http://www.w3schools.com/tags/ref_urlencode.asp which will IRL-encode your URL for you. As an example, my source is: http%3A%2F%2Fteams%2Fsites%2Fmysite%2FLists%2Fmyblog%2Fblogview%2Easpx
Making a template based on the new list:
There are many problems with making a new template from this new list. All of the modified pages will not point to the correct list or web part, and they will be broken. The broken elements will be:
- AddComment.aspx (points to the wrong list)
- EditForm.aspx (points to the wrong list)
- NewForm.aspx (points to the wrong list)
- BlogViewWComments.aspx.
The process:
- Create an Issues List.
- Rename the Due Date to 'Post Date', default is today/now.
- Create a new field called 'Blog', and make it a multi-text field, Required, display 15 lines, Allow rich, add to default view.
- Disable attachments.
- Change the permissions for the list:
- Web Designer: [REMOVE THIS]
- Contributor: View, Add, Edit
- All Users: View, Edit
- Blogger: Add, Edit, Delete, View
- Create a new view.
- Standard View
- Named "BlogViewWcomments"
- Public
- Fields: ID, Comment, Modified, Blog, modified By
- Sort by Modified Date, descending
- Filter: Show all items in this view.
- Group By: Title
- Leave the rest at default.
- Create two blog posts using NewForm.aspx. Create some comments for each post by editing the item and typing something into the comment field. Do this several times, and you will have several 'comments' for the post.
- Open BlogViewWcomments.aspx in FrontPage.
- Right-click the web-part, convert to XSLT.
- Layout the elements how you want them to appear in the final version:
- Remove the "Current" column If it's in there (Table à Select à Column, then Press the Delete Cells button).
- Select the text of one of the Blog cells, click 'Conditional Formatting, create, show content. Current = 'YES'.
- Select the first row, (Table à Select à Row), insert row below (Table à Insert à Rows or Columns)
- Drag the first comment text to the new row so that it is now underneath the blog post text.
- Remove the now empty "Comment" column (Table à Select à Column, then Press the Delete Cells button).
- Drag the first Modified By table (Click on the Modified By text once, then select the table it is in by clicking the TABLE tag just above your open document, sorry I don't know what that toolbar is called), cut it out and paste it into to the new row so that it is now underneath the blog post text, but above the comment text. I usually discard the presence information and just use the name text, but that is up to you.
- Remove the now empty "Modified By" column (Table à Select à Column, then Press the Delete Cells button).
- Drag the first Modified date text to the new row so that it is now positioned before the Modified By text.
- Remove the now empty "Modified" date column (Table à Select à Column, then Press the Delete Cells button).
- Put the Post Date field in. I put it in the group header, and took out the word 'Title' so that the header now reads: "+ [Date]: [Title]". Looks nice.
- Pretty the view up a bit by putting "On" and a space before the modified date, a space between the modified date and the name of the person who modified it, and then put "Said:" and a soft-return (Shift+Enter) after the "Said:". Convert the Modified Date to a Date/Time format that looks nice (right-click format item as à Date Time).
- Go into code view and place a DIV tag around the entire comments section (Modified by, Modified Date, comments) so that we can apply some conditional formatting.
- Go back into design view and select the DIV tag you just put in. Hide content when "Comment" is NULL.
- Go into code view and make it so that the conditional formatting applies to the entire TR tag, not just the DIV tag. Move the xsl:if statement from just before the DIV tag and place it just before the tr tag, and then take the /xsl:if tag and place it just after the /tr tag.
- Pretty it up even more by adding a line on top of the comment TD (change the td tag and put Style="Border-top: 1px solid #dddddd;"). Get rid of any frivolous columns (ID). Maybe indent the blog post from the title, and indent the comments from the blog post, add a graphic like a person with a talk bubble for each comment, or whatever.
- Change the document title. Change "<SharePoint:ListProperty Property="Title" runat="server" __Preview="BlogGeneric"/>" to "<SharePoint:ListProperty Property="Title" runat="server" __Preview="Blog View With Comments"/>".
- Select the last row of records, and insert a new row underneath. This will give you a row under each record. In the new row, join all of the columns together (if not already). In the new cell, insert a new table, with two rows and two columns, no border, no padding, no spacing, 100% wide. You might have to tweak it in code view so that the table sits in the correct location and is repeated for each record. Populate the table with links:
- Comments link: Make a link in the first cell of the table, and link to google or some other placeholder. Go into code view and change the link so that it is dynamic for the ID of the blog item: href="AddComment.aspx?ID={@ID}&source=[URLencoded URL of the BlogView.aspx page]"
- View All Comments link: Make a link in the second cell of the table, and link to google or some other placeholder. Go into code view and change the link so that it is dynamic for the ID of the blog item: href="BlogViewWcomments.aspx?Issue_ID={@IssueID}&source=[URLencoded URL of the BlogView.aspx page]"
- Join the two columns of the second row together. Alert Me link: Make a link in the second row of the table, and link to google or some other placeholder. This Alert Me link will provide an alert when someone comments on this SPECIFIC blog entry. Go into code view and change the link so that it is dynamic for the ID of the blog item: href="http://teams/sites/mysite/_layouts/1033/SubNew.aspx?List=%7B[LIST GUID GOES HERE]%7D&ID={@ID}&source=[URLencoded URL of the BlogView.aspx page]"
- Move the cursor down to the bottom of the list, and just outside of the web part zone, add a new table, with 1 row and 1 column. In the table, provide a link to get alerts for the blog, and to view all my comments.
- The alert link is the same as the previous alert link, without the ID query string variable: href="http://teams/sites/mysite/_layouts/1033/SubNew.aspx?List=%7B[LIST GUID GOES HERE]%7D&amp;amp;amp;amp;amp;source=[URLencoded URL of the BlogView.aspx page]"
- The My Comments link goes to MyItems.aspx.
- Save the file.
- Save the File as "BlogView.aspx"
- Close "BlogView.aspx"
- Open "BlogViewWcomments.aspx"
- In code view, find <ParameterBinding Name="filterParam" Location="Postback;Connection"/> and change it to <ParameterBinding Name="filterParam" Location="Postback;Connection;QueryString(Issue_ID)"/>.
- In design view, Change the filter: Issue ID = [Input Parameter]
- Make the alert/add/view links appear only once, because the user is only looking at one blog entry: In code view, remove the "add a comment/View all comments/Alert me" link table from the comments row, and move it into the row encased by the "<xsl:if test="normalize-space(@IsCurrent) = '1'">" tag.
- Open BlogView.aspx in FrontPage.
- Change the filter to Current = YES and PostDate Less than or Equal to [Current Date].
- Above the comment for each post, type "Latest Comment:" and put a soft-return at the end. Make it bold too while you're at it.
- Change the display name to Blog View. Change "<DisplayName xmlns="http://schemas.microsoft.com/WebPart/v2/DataView">BlogViewWcomments</DisplayName>" to "<DisplayName xmlns="http://schemas.microsoft.com/WebPart/v2/DataView">BlogView</DisplayName>".
- Change the document title. Change "<SharePoint:ListProperty Property="Title" runat="server" __Preview="BlogGeneric"/>" to "<SharePoint:ListProperty Property="Title" runat="server" __Preview="Blog View"/>".
- Default: Open site in FP, navigate to the lists folder (you can just go up a folder level from where you are now, if you are editing BlogView.aspx), then right-click the bloglist, select Properties. Go to the Supporting Files Tab. Make sure default view page is BlogView.aspx.
- Change the sorting and grouping so that it is:
- Post Date: Descending, not grouped
- Title Descending, Grouped
- Modified, Descending, not grouped
- Open EditForm.aspx in FrontPage.
- Save as "AddComment.aspx"
- Right-Click, customize Share Point List form.
- Hide all of the fields except the comments field. Do this by selecting the TD and adding Style="Display: none;" to the areas you want to hide.
- Add the JavaScript to delete the last comment from the comment field. See the end of this document for the code.
- Search for the text "onetidinfoblock3>Issue ID :" and replace it with "onetidinfoblock3>Blog Comment ID :".
- Search for the text "Issue History" and replace it with "Blog Comment History".
- Please note that you cannot go changing all of the occurrences of 'issue' with 'blog' because there are some functional 'issue' in the code.
- Open EditForm.aspx in FrontPage. Save it as "EditFormBackup.aspx"
- Open EditForm.aspx in FrontPage. Make all fields invisible, and make a note to 'contact the administrator to edit a blog post. Note: Workaround uses EditFormBackup.aspx or deleting a post and re-adding it. This is a security measure, albeit not very secure, from keeping people from editing blog posts.
- Default: Open site in FP, navigate to the lists folder (you can just go up a folder level from where you are now, if you are editing BlogView.aspx), then right-click the bloglist, select Properties. Go to the Supporting Files Tab. Make sure default edit page is AddComment.aspx.
- Open EditForm.aspx in FrontPage.
- Hide all of the fields except the Title, Blog, Post Date fields. Do this by selecting the TD and adding Style="Display: none;" to the areas you want to hide.
- Open NewForm.aspx in FrontPage.
- Hide all of the fields except the Title, Blog, Post Date fields. Do this by selecting the TD and adding Style="Display: none;" to the areas you want to hide.
- Open MyItems.aspx in FrontPage.
- In design view, Right-click the web part and change the filter. Instead of "Assigned To Equals [Current User]", change it to "Modified By Equals [Current User]"
- I like to change the GROUP BY to TITLE, but this is entirely up to you.
- Finishing Up: All pages.
- Open all pages and add a header: AddComment.aspx, DispForm.aspx, EditForm.aspx, NewForm.aspx, active.aspx, AllItems.aspx, BlogView.aspx, BlogViewWcomments.aspx, MyItems.aspx, find the "<placeholder…"
- With the pages open, go through and convert all of the views to xslt and remove the 'edit in datasheet' mode so that people cannot edit the blog entries.
- LAST STEP: Make any more changes you want, but each time you open/view/edit/save BlogView.aspx and BlogViewWcomments.aspx, you MUST re-check your dynamic links. Sometimes, FrontPage will substitute your dynamic links with static links, which breaks your alert, BlogViewWcomments link and your add comments link.
Header Text:
Use this as the header text, and replace the image and details for the blogger:
<table style="padding: 0; margin: 0; border: 0;">
<tr>
<td style="padding-left: 20px;text-align: left; font-face: Arial; font-size: 8pt; color: #dddddd; background-color: #ffffff;">
<p style="font-weight: bold;"><img border="0" src="person.jpg" width="78" height="89" align="left" hspace="2" vspace="2"><br />
<a href="BlogView.aspx" title="Click to return to Blog View" style="text-decoration: none;">Thoughts from our Blogger</a><br/><br/>
<a style="text-decoration: none;" title="Send email message to blogger." href="mailto:this.blogger@example.com?subject=Blog">Blogger Name</a><br>Blogger Title</p>
</td>
</tr>
</table>
JavaScript code to delete the last comment from the AddComment.aspx file:
<script>
<!--
for(i=0; i<document._ctl1.elements.length; i++)
{
if (document._ctl1.elements[i].name=='urn:schemas-microsoft-com:office:office#Comment')
{
document._ctl1.elements[i].value='';
}
}
//-->
</script>
Etichete: Blog, Issue, JavaScript, List, ParameterBinding, SharePoint, WSS
Despre mine
- Ophogus G. Marmphik
- 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.