Show Event category
I want to display a list of Events sorted by date and show which category/categories each Event belongs to. I am able to show the sorted list of Events but am not sure how to access any taxonomy information from the Event item itself. Does Beta 2 have any way of doing this?
Thanks,
Ann
Hi Ann,
There is no Fluent API to get the category - Event relation directly. We are working on this now. You could use a dictionary as the sample below illustrates.
var CatID =
new
Guid(
"21d31a1d-c168-45af-a30b-5ad0076c4be9"
);
Dictionary<Guid, Event> dict =
new
Dictionary<Guid, Event>();
var evManager = EventsManager.GetManager();
var eventItems = evManager.GetEvents().Where(ev => ((IList<Guid>)ev.GetValue(
"Category"
)).Contains(CatID));
foreach
(var _event
in
eventItems)
dict.Add(CatID, _event);
break
;
foreach
(KeyValuePair<Guid, Event> pair
in
dict)
Hi,
I am using Sitefinity 4.0.1098.0 SE
In my Event template I added to show the Category(ies) of the event listing with this below:
<
sitefinity:HierarchicalTaxonField
ID
=
"HierarchicalFieldControl"
runat
=
"server"
TaxonomyId
=
"E5CD6D69-1543-427b-AD62-688A99F5E7D4"
DisplayMode
=
"Read"
WebServiceUrl
=
"~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc"
Expanded
=
"false"
TaxonomyMetafieldName
=
"Category"
ExpandText
=
"ClickToAddCategories"
BindOnServer
=
"true"
/>
regex
". With this error, the page freezes in edit mode. Any idea why this is?return this.optional(element)||regex.test(value);
,jQuery.format("The given value does not match the regular expression rule."));
Hello Laura,
Are you getting the error on the live website? The error indicates for js conflict which could be caused if you load some js libraries on the page. If the problem persists only in edit mode you can try to register the script from the server, because there you can use expression methods
IsDesignMode - static method which determines whether the control is in Sitefinity design mode - you are editing a page.
IsPreviewMode- determines whether the control is in Sitefinity preview mode.
IsBackend -determines whether a control instance is in backend.
sample
protected
override
void
OnPreRender(EventArgs e)
base
.OnPreRender(e);
if
(
this
.IsDesignMode() && !
this
.IsPreviewMode())
this
.Controls.Clear();
Hi Ivan ,
I got this error..
"Telerik.Sitefinity.Events.Model.Event' does not contain a definition for 'GetValue'"
actually I want to get all the Event Categories.
Hello Rakesh,
Add reference to Telerik.Sitefinity.Model.DataExtensions
Best wishes,
Ivan Dimitrov
the Telerik team
Hi,
I did not get "Telerik.Sitefinity.Model.DataExtensions".
Is their any dll reference for this.
Hi Rakesh,
Please make sure that you use Sitefinity 4.2 edition
www.sitefinity.com/.../t_telerik_sitefinity_model_dataextensions.html
Best wishes,
Ivan Dimitrov
the Telerik team
Am I understand this post correctly? I want to add an out-of-the-box category widget to a blog page, but I only want categories that are actually associated with blog posts (i.e. I don't want a category assigned to an event item to show up). Does the category widget only show ALL categories created across every content type? If that is the case, did I also understand that you are working on functionality to change that behavior? If the widget should limit itself to the content type to which it is assigned, will you please provide some information on how to make that work. (I have already set the Content Type to Telerik.Sitefinity.Blogs.Model.BlogPost to little affect other than the filtering actually working against the blog widget.)
Hello Allen,
We haven't planned making the categories and tags widgets contextual, so that they can show only relevant taxonomies within the page.
We have decided to separate the logic of the widget, and avoid any dependencies among the widgets as it will make it hard for customers to extend this functionality to support their own widgets. We also have performance concerns on this scenario where we have to traverse all widgets within the current page in order to output the categories and tags of the content associated with this widget.
Thank you for suggesting this, it is definitely something we will consider while optimizing the taxonomies widgets in the upcoming Sitefinity 5.0 release.