Reputation: 1076
My code works fine but when i try to get data of each funds = subpage.Name i get all the funds data not as individual. what im missing here ?? Can anyone help me? im sorry im new to umbraco and c#, whats the best way to manage this
now its like this
(16) [{…}, {…},]...
0: {Fundo: "CURTO PRAZO", data: Array(21)}
1: {Fundo: "CA MONETARIO", data: Array(21)}
...
In reality it should be
(16) [{…}, {…},]...
0: {Fundo: "CURTO PRAZO", data: Array(4)}
1: {Fundo: "CA MONETARIO", data: Array(3)}
for example
...
this is my code
var currentPage = Model.Content;
var selection = Umbraco.Content(1448);
@foreach (var page in selection.Children){
if(page.Children.Count() > 0){
foreach(var subpage in page.Children){
var listaPdf = subpage.GetPropertyValue<IEnumerable<IPublishedContent>>("listaPdfsFundos");
if(listaPdf == null) {
listaPdf = new List<IPublishedContent>();}
if(listaPdf != null){
foreach(var row in listaPdf) {
name = Umbraco.Field(row, "categoriaDoFundo").ToString();
var id = Umbraco.Field(row, "documentos").ToString();
var mediaItem = Umbraco.TypedMedia(id);
url = mediaItem.Url;
<script type="text/javascript">
data.push({"Nome":"@name", "Url":"@url"});
</script>
}
<script type="text/javascript">
list.push({"Fundo":"@subpage.Name", data });
</script>
}
}
}
}
Upvotes: 0
Views: 91
Reputation: 1781
You should use UmbracoHelper to get the IPublishedContent and then you can get the children of your content page & reach individual properties.
Please see details below; in my example my test content id is my Home page's nodeId and see how I get the children of my Home page and the first child's properties - so please update your code according to this, for further details take a look at this;
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var testContentId = 1353; // This is your umbraco node id of your content page
var publishedContent = umbracoHelper.TypedContent(testContentId);
if (publishedContent != null)
{
foreach (var child in publishedContent.Children)
{
// This is where you can reach the Children of this child as well as individual properties of this child
if (child.HasProperty("emailAddress_Contact_Information"))
{
var emailAddressContactInformation = child.GetProperty("emailAddress_Contact_Information");
}
}
}
Upvotes: 1