| Author |
Message |
gg
Guest
|
Posted:
Tue Oct 25, 2005 4:51 pm Post subject:
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. |
|
| Back to top |
|
 |
Mei Ying [MVP]
Guest
|
Posted:
Wed Oct 26, 2005 8:08 am Post subject:
RE: Get a image placeholder value |
|
|
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:
| Quote: | 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.
|
|
|
| Back to top |
|
 |
Stefan [MSFT]
Guest
|
Posted:
Wed Oct 26, 2005 12:50 pm Post subject:
Re: Get a image placeholder value |
|
|
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...
| Quote: | 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?
|
|
|
| Back to top |
|
 |
Stefan [MSFT]
Guest
|
Posted:
Wed Oct 26, 2005 12:50 pm Post subject:
Re: Get a image placeholder value |
|
|
Hi gg,
btw: I have written a ready to use solution for this in the past:
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=3cbc04cd-2ce7-410f-acd4-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...
| Quote: | 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?
|
|
|
| Back to top |
|
 |
gg
Guest
|
Posted:
Wed Oct 26, 2005 12:50 pm Post subject:
Re: Get a image placeholder value |
|
|
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? |
|
| Back to top |
|
 |
|
|
|
|