|
Home > Archive > Microsoft Content Management Server > May 2004 > programmatically accessing content
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
programmatically accessing content
|
|
| Michael 2004-05-14, 4:36 pm |
| I'm trying to write a program that crawls my site looking at each
posting to find a particular string.
I'm able to write a program that recurses through the channels and
postings, but I'm stuck on how to iterate through the placeholders
within the postings, and get their content. Also, certain postings are
not accessed by this recursive program, not sure why.
Does anyone have any suggestions or examples for this?
Thanks,
Michael Richman
My code is shown below, if that helps:
public class SearchContent : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SearchPostings("go260");
}
private void SearchPostings(String searchString)
{
CmsApplicationContext cms = new CmsApplicationContext();
cms.AuthenticateAsUser("WinNT://pge/mpr7","***");
HierarchyItem startItem = cms.Searches.GetByUrl("http:/pg/");
Channel startChannel = (Channel) startItem;
CrawlChannel(cms,startChannel);
}
private void CrawlChannel(CmsApplicationContext cmsContext, Channel
currChannel)
{
PostingCollection postings = currChannel.Postings;
foreach (Posting thisPosting in postings)
{
Response.Write("Channel: " + currChannel.Name + "-Posting:" +
thisPosting.Path + "<BR>");
foreach (PlaceHolder ph in thisPosting.Placeholders)
{
//This is where I don't know what to do.
}
}
ChannelCollection channels = currChannel.Channels;
foreach (Channel thisChannel in channels)
{
Response.Write("Channel: " + thisChannel.Name + "<BR>");
CrawlChannel(cmsContext,thisChannel);
}
}
| |
| Spencer Harbar [MVP] 2004-05-15, 2:35 pm |
| check out this sample
CMS String Searcher
Ever needed to search for a string in an entire CMS2002 site? We did... run
this console app on your CMS2002 sever and specific a specific string. It
will search through every Html & Xml placeholder in every posting in every
channel & subchannel in the site for the specified string and generate an
Html file for the report.
http://www.gotdotnet.com/Community/...8D-1E1F7073B307
--
hth
Spence
www.harbar.net/mcms/
"Michael" <mpr7@pge.com> wrote in message
news:e087d389.0405141159.467860ea@posting.google.com...
> I'm trying to write a program that crawls my site looking at each
> posting to find a particular string.
>
> I'm able to write a program that recurses through the channels and
> postings, but I'm stuck on how to iterate through the placeholders
> within the postings, and get their content. Also, certain postings are
> not accessed by this recursive program, not sure why.
>
> Does anyone have any suggestions or examples for this?
>
> Thanks,
>
> Michael Richman
>
> My code is shown below, if that helps:
>
> public class SearchContent : System.Web.UI.Page
> {
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SearchPostings("go260");
> }
>
> private void SearchPostings(String searchString)
> {
> CmsApplicationContext cms = new CmsApplicationContext();
> cms.AuthenticateAsUser("WinNT://pge/mpr7","***");
> HierarchyItem startItem = cms.Searches.GetByUrl("http:/pg/");
> Channel startChannel = (Channel) startItem;
> CrawlChannel(cms,startChannel);
> }
>
> private void CrawlChannel(CmsApplicationContext cmsContext, Channel
> currChannel)
> {
> PostingCollection postings = currChannel.Postings;
> foreach (Posting thisPosting in postings)
> {
> Response.Write("Channel: " + currChannel.Name + "-Posting:" +
> thisPosting.Path + "<BR>");
> foreach (PlaceHolder ph in thisPosting.Placeholders)
> {
> //This is where I don't know what to do.
> }
>
> }
> ChannelCollection channels = currChannel.Channels;
> foreach (Channel thisChannel in channels)
> {
> Response.Write("Channel: " + thisChannel.Name + "<BR>");
> CrawlChannel(cmsContext,thisChannel);
> }
>
> }
| |
| Tommy O 2004-05-19, 5:49 pm |
| To read the content of a placeholder you need to cast it to a
HtmlPlaceholder object (or XmlPlaceholder object)
For example:
HtmlPlaceholder ph =
(HtmlPlaceholder)posting.Placeholders["placeholdername"];
string s = ph.Html;
Tommy
"Michael" <mpr7@pge.com> wrote in message
news:e087d389.0405141159.467860ea@posting.google.com...
> I'm trying to write a program that crawls my site looking at each
> posting to find a particular string.
>
> I'm able to write a program that recurses through the channels and
> postings, but I'm stuck on how to iterate through the placeholders
> within the postings, and get their content. Also, certain postings are
> not accessed by this recursive program, not sure why.
>
> Does anyone have any suggestions or examples for this?
>
> Thanks,
>
> Michael Richman
>
> My code is shown below, if that helps:
>
> public class SearchContent : System.Web.UI.Page
> {
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SearchPostings("go260");
> }
>
> private void SearchPostings(String searchString)
> {
> CmsApplicationContext cms = new CmsApplicationContext();
> cms.AuthenticateAsUser("WinNT://pge/mpr7","***");
> HierarchyItem startItem = cms.Searches.GetByUrl("http:/pg/");
> Channel startChannel = (Channel) startItem;
> CrawlChannel(cms,startChannel);
> }
>
> private void CrawlChannel(CmsApplicationContext cmsContext, Channel
> currChannel)
> {
> PostingCollection postings = currChannel.Postings;
> foreach (Posting thisPosting in postings)
> {
> Response.Write("Channel: " + currChannel.Name + "-Posting:" +
> thisPosting.Path + "<BR>");
> foreach (PlaceHolder ph in thisPosting.Placeholders)
> {
> //This is where I don't know what to do.
> }
>
> }
> ChannelCollection channels = currChannel.Channels;
> foreach (Channel thisChannel in channels)
> {
> Response.Write("Channel: " + thisChannel.Name + "<BR>");
> CrawlChannel(cmsContext,thisChannel);
> }
>
> }
|
|
|
|
|