| Author |
Get a image placeholder value
|
|
|
| Hi,
How can i get a image placeholder value (in my case the image url) when
i`m in another channel?
E.g. the placeholder belong to news channel and i need to get the image
url in the home one.
| |
| Mei Ying [MVP] 2005-10-26, 2:48 am |
| Hi
Use the PAPI! You could use the Searches object to navigate to the posting
that contains the image. For e.g.
CmsHttpContext cmsContext = CmsHttpContext.Current;
Posting myPosting =
cmsContext.Searches.GetByPath("/Channels/News/MyPostinng") as Posting;
if(myPosting!=null)
{
string url = ((ImagePlaceholder)myPosting.Placeholders["MyImage"].Url);
}
It would of course, be more efficient if used Searches.GetByGuid. But that's
only if you store the GUID of the posting somewhere.
--
regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Book: http://www.packtpub.com/book/mcms
Contact: meiyinglim@hotmail.com
---
"gg" wrote:
> Hi,
> How can i get a image placeholder value (in my case the image url) when
> i`m in another channel?
> E.g. the placeholder belong to news channel and i need to get the image
> url in the home one.
>
>
| |
|
| Thk, first problem solved. Now i wanto to assign that url in a resouce
stream like that
Resource rs = CmsHttpContext.Current.Searches.GetByPath(MyURL) as
Resource;
Stream ResourceStream = rs.OpenReadStream();
cause i would like to resize the imageph content before the
displaying(of course there is other code following).
But when i open the site i get an error (Object reference not set to an
istance of an object) and the row "Stream ResourceStream =
rs.OpenReadStream();" is highlited.
My image is in the resouce gallery but i don't know how to pass the
path i can only pass the url.
Ther's another way?
| |
| Stefan [MSFT] 2005-10-26, 7:49 am |
| Hi gg,
btw: I have written a ready to use solution for this in the past:
http://www.gotdotnet.com/Community/...d4-7782873c7705
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"gg" <gigino@gmail.com> wrote in message
news:1130315697.850337.9290@g43g2000cwa.googlegroups.com...
> Thk, first problem solved. Now i wanto to assign that url in a resouce
> stream like that
>
>
> Resource rs = CmsHttpContext.Current.Searches.GetByPath(MyURL) as
> Resource;
> Stream ResourceStream = rs.OpenReadStream();
>
> cause i would like to resize the imageph content before the
> displaying(of course there is other code following).
>
> But when i open the site i get an error (Object reference not set to an
> istance of an object) and the row "Stream ResourceStream =
> rs.OpenReadStream();" is highlited.
>
> My image is in the resouce gallery but i don't know how to pass the
> path i can only pass the url.
> Ther's another way?
>
| |
| Stefan [MSFT] 2005-10-26, 7:49 am |
| Hi gg,
most likely rs is null.
That would make sense as you passed in an Url and a Path is not a Url.
So you can't use GetByPath with a Url - you need to pass in the Path of the
resource.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"gg" <gigino@gmail.com> wrote in message
news:1130315697.850337.9290@g43g2000cwa.googlegroups.com...
> Thk, first problem solved. Now i wanto to assign that url in a resouce
> stream like that
>
>
> Resource rs = CmsHttpContext.Current.Searches.GetByPath(MyURL) as
> Resource;
> Stream ResourceStream = rs.OpenReadStream();
>
> cause i would like to resize the imageph content before the
> displaying(of course there is other code following).
>
> But when i open the site i get an error (Object reference not set to an
> istance of an object) and the row "Stream ResourceStream =
> rs.OpenReadStream();" is highlited.
>
> My image is in the resouce gallery but i don't know how to pass the
> path i can only pass the url.
> Ther's another way?
>
|
|
|
|