Associate an image to a news
Hi,
I just can't figure out in Sitefinity 4.0 how you could associate an image to a news. the idea is to let content writers add news, specify comments / tags... and a specific image. Then having the possibility in the News list control to display the news title, summary,... AND image (or thumbnail).
Is that possible and how could I do that ?
thanks for your help
Francois
The option to upload/associate image to a news item is in the news editor. I believe right now there is no way to show just the image in news listing from vanilla Sitefinity.
Hello Francois,
Having thumbnails for news is in the tasks for implementation after official release (#100328).
This is an important feature and we consider it of importance.
In the meanwhile you can use a workaround for that:
1) upload your image in a section Images
2) in the Edit News page, insert a link to the image uploaded in step 1 in of the additional fields which you will not be using for something else (i.e."Source URL")
3) In section Design> Widget Templates, modify the News widget template to include the field from step 2.
Other custom implementations are possible as well (as mentioned in the previous post).
Hope that works for you until we are done with this feature.
Kind regards,
Kalina
the Telerik team
Thank you. Perfectly clear.
Hi Kalina,
I'm having the same problem - although the solution was more elegant in 3.7 in that I could create a meta field for the URL, then in the control template set it to pop up an image selector. Is there any way of doing this in version 4? I noticed you can add custom fields, so could you specify a path to the image selector in the same way?
Previously in 3.7 I added the meta field, then changed the Content Template for the NewsItemEdit.ascx file to open my field like so :
<
asp:TextBox
ID
=
"Thumbnail"
Text
=
""
runat
=
"server"
MaxLength
=
"250"
></
asp:TextBox
>
<
sfLib:ButtonSelector
WindowNavigateUrl
=
"~/Sitefinity/UserControls/Dialogs/ImageDialog.aspx"
AssociatedControls
=
"Thumbnail"
ItemTemplatePath
=
"~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx"
runat
=
"server"
cssclass
=
"pickerWrapper"
ButtonText="<%$Resources:Select%>" />
Hi Francois,
You can try using the custom fields. We implemented them for the RC.
Currently you can add only a custom control ( there are issues when you use a user control). You need to create a custom control that inherits from CompositeFieldControl or completely custom control that implements IField interface.
sample
usingSystem;
usingTelerik.Sitefinity.Web.UI.Fields;
namespaceTelerik.Sitefinity.Samples
classCompositeFieldControlCustom : CompositeFieldControl
protectedoverrideSystem.Web.UI.WebControls.WebControl TitleControl
get
thrownewNotImplementedException();
protectedoverrideSystem.Web.UI.WebControls.WebControl DescriptionControl
get
thrownewNotImplementedException();
protectedoverrideSystem.Web.UI.WebControls.WebControl ExampleControl
get
thrownewNotImplementedException();
protectedoverridevoidInitializeControls(Web.UI.GenericContainer container)
thrownewNotImplementedException();
protectedoverridestringLayoutTemplateName
get
thrownewNotImplementedException();
There is a built-in control PromptDialog that you can use. Inside the CustomTemplate
you can add a control/s you want to see.
<
sf:ResourceLinksid
=
"resourcesLinks"
runat
=
"server"
Theme
=
"Default"
UseEmbeddedThemes
=
"true"
>
<
sf:ResourceFileJavaScriptLibrary
=
"JQuery"
/>
<
sitefinity:ResourceFileName
=
"Skins/PromptDialog.css"
/>
</
sf:ResourceLinks
>
<
sitefinity:PromptDialogrunat
=
"server"
id
=
"promptDialog"
Width
=
"150"
Height
=
"150"
Mode
=
"Custom"
AllowCloseButton
=
"true"
ShowOnLoad
=
"false"
Title
=
"just a test"
>
<
CustomTemplate
>
<
asp:Literalrunat
=
"server"
ID
=
"test1"
Text
=
"Hello there"
/>
</
CustomTemplate
>
<
Commands
>
<
sf:CommandToolboxItemText
=
"Done"
CommandName
=
"ok"
CommandType
=
"CreateButton"
WrapperTagName
=
"LI"
></
sf:CommandToolboxItem
>
<
sf:CommandToolboxItemText
=
"Cancel"
CommandName
=
"cancel"
CommandType
=
"CancelButton"
WrapperTagName
=
"LI"
></
sf:CommandToolboxItem
>
</
Commands
>
</
sitefinity:PromptDialog
>
<
asp:LinkButtonrunat
=
"server"
ID
=
"testbutton"
OnClientClick
=
"showPropmpt();return false;"
Text
=
"call function"
/>
<
scripttype
=
"text/javascript"
>
function showPropmpt()
var propmptDialog = $find('<%=promptDialog.ClientID%>');
propmptDialog.show_prompt();
</
script
>
Hello,
When this feature will be included in Sitefinity? I really need this feature.
Thanks
Hello jocelyn,
Could you tell me for which feature you are asking, so I could see whether we will have it shortly.
Kind regards,
Ivan Dimitrov
the Telerik team
Hello Ivan,
I was talking about the thumbnail in the news module.
Jocelyn
Hello,
This is a new implementation and we will need some more time to schedule it and implement it. Currently we have not set time frame for it. The Id of your request is 105788
Regards,
Ivan Dimitrov
the Telerik team
Hi Ivan,
It would really help having a rough timeline on this so we can weigh up using some custom controls.
I'm not sure why you consider it a 'new item'... does this effect the speed that its applied?
It was on previous versions and would be an expected feature for news.
Hi,
Is this feature now in your product?
Am in the process of evaluating Sitefinity to use for my company's websites. I was trying to implement a small mockup of pulling news items through Sitefinity API and wasn't sure how to get news thumbnails in the newslist.
Thanks
T
Hi,
We created a blog post and provided the code needed to get the content - image/thumbnail relation working
www.sitefinity.com/.../creating_a_thumbnail_selector_for_news_items.aspx
All the best,
Ivan Dimitrov
the Telerik team
Thanks Ivan,
But then how to access the new field through the API ?
Thanks for the prompt response.
T
Hi ,
The Content object has an extension method - GetValue which you can use to get the value set for your key. You should have a reference to Telerik.Sitefinity.Model in your class to use the extension methods.
All the best,
Ivan Dimitrov
the Telerik team
Sorry, but which content object? I only find a string property in NewsItem named content, and that ofcourse dose not have GetValue .
could you perhaps point me to a documentation/ sample . Thanks
Am using SF4 and I did include :
using Telerik.Sitefinity.GenericContent.Model;
using Telerik.Sitefinity.Modules.News;
using Telerik.Sitefinity.Modules;
using Telerik.Sitefinity.News.Model;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity;
Hello ,
The NewsItem is a content object. It inherits from Content.
Kind regards,
Ivan Dimitrov
the Telerik team