0

I'm attempting to create more dynamic slider so I've created a custom datatype which one includes fields like Caption, Text, Link, Image, StartDate, EndDate, Active, etc... I hope I'm in the right path.

Now I need to retrieve active entries. How can I get the necessary entries?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Nime Cloud
  • 6,162
  • 14
  • 43
  • 75

1 Answers1

2

You query data using LINQ through the Get method on the Composite.Data.DataConnection class - dataConnection.Get<T>() where T is your data type wield an IQueryable.

Below is code that will query a data type named Your.Data.Type, filtering on the Caption field and selecting Caption, Text, Image and StartDate.

using  (DataConnection connection = new DataConnection())
{
   var myData = 
      from d in connection.Get<Your.Data.Type>()
      where  d.Caption == "My Caption"
      select new { d.Caption, d.Text, d.Image, d.StartDate };
}

On the Composite C1 documentation website you can read more about accessing data with C#.

If you are not into C# you can use either Visual Functions or XSLT Functions.

mawtex
  • 1,564
  • 1
  • 12
  • 21
  • I've created a C# function and generated the html code like this: http://pastebin.com/2p3y17si which looks ugly, but it works. – Nime Cloud Nov 26 '12 at 13:07
  • How can I embed C# function's result into XSLT function? I tried this and it displayed as html code (encoded) on the page: http://pastebin.com/XZegvApb – Nime Cloud Nov 26 '12 at 13:45
  • You can always call C# Functions (any function returning string of XElement results) from the XSLT's Function Calls tab. You can also call them dynamically, see http://docs.composite.net/XSLT/Calling-C1-Functions – mawtex Nov 30 '12 at 09:46
  • There is only one slider data I got. How can I clone datatype to use multiple instances of the slider? Adding a slider id field is the easiest way but I wonder how can I add separate data for Slide1 Slide2 etc... – Nime Cloud Nov 30 '12 at 11:42