Microsoft Content Management Server - Programmatically populate a placeholder

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > February 2004 > Programmatically populate a placeholder





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 populate a placeholder
Morten Petterĝe

2004-02-23, 1:35 am

Hi

I want to promote the latest posting in certain channels on my front page. I
have created a placeholder for an image that I want to retrieve from the
latest posting in another channel.

Is there a code sample out there that shows me how to do this?


Thanks,

Morten


Stefan [MSFT]

2004-02-23, 5:35 am

Hi Morten,

there are two ways to achieve this:

1) using a user web control or a server control rather than a cms
placeholder object:

the control needs to pick up the Posting Collection in the channel
(channel.Postings) and sort them (e.g. SortByLastChangedDate or
SortByLastModified).
Then pick the first posting in the collection (channel.Postings[0]) and
extract the Url to the image

string Url = ((ImagePlaceholder)(posting.Placeholders["ImagePh"])).Src;

Benefit: only one place has the actual URL - content is deployed
dynamically - always accurate content

A server control that can be used as a starter for your developments is the
following:
http://www.gotdotnet.com/Community/...b9-8b395b722f24
This version uses a hard coded posting reference but you could replace this
with the logic above.


2) using a CMS placeholder object and a CMS workflow event to populate the
postings

Here you would have to copy the URL to the ImagePlaceholder on the front
page from within a workflow event.
This can be done in the CmsPosting_Changing event (e.g.) or in the
CmsPosting_PlaceholderPropertyChanging event (you need to check for the
right placeholder).

You need to get a reference to the front page (e.g.) using the searches
object and update the Src property of the placeholder object.

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.


"Morten Petterĝe" <morten@imano.nospam (remove the spam, leave the no)>
wrote in message news:eULO72h#DHA.452@TK2MSFTNGP11.phx.gbl...
> Hi
>
> I want to promote the latest posting in certain channels on my front page.

I
> have created a placeholder for an image that I want to retrieve from the
> latest posting in another channel.
>
> Is there a code sample out there that shows me how to do this?
>
>
> Thanks,
>
> Morten
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com