Developer forum

Forum » Templates » Relation between pages, paragraphs and items

Relation between pages, paragraphs and items

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

I have a page, that is item based

On this page, i have severeal paragraphs that also are items based.

Normally, paragraphs are sort of children to pages. But in my case - I want the items attached to the paragraphs to actually "belong" to the item attached to the page

Now the question is - What is the relation between pages, paragraphs and items? 

Using indexing - lets say that i want to show the item attached to the page, but i also want to a list of the items attached to the paragraphs.

Example: The item attached to the page has a field that has the value "Sendistovan"

the items attached to the paragraphs have a field that has a value of year as a normal string. so the list of paragraphitems would be (2020, 2019,  2018, 2017 etc. etc.) Where each "year" is a seperate item.

So the questions are:

1. if and how can I show the pageitem and the paragraphitems using indexing?

2. Is there any relation directly between the items on the paragraphs and the item on the page, or do i have to go sort of like this? 

Item <--> page <--> paragraph <--> item  (I know it´s a poor diagram, but hopefully you know that i mean)

So that if i fetch the pageitem, form there I can grab the page id, and from the pageid - I can get the belonging paragraphs - and from there, i can render the items on the paragraphs?

 

Hope this all makes sense

 

/Hans

 


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Hans,

 

I don't think I understood what you need, but I wonder if you can't achieve it with the ItemPublisher? You can use it as an App on a paragraph to get a specific ItemType of a given Parent (Page).

 

The same can be achieved using tags https://doc.dynamicweb.com/documentation-9/content/apps/item-publisher#3297

 

Best Regards,

Nuno

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi - no, that wont do

we have thousands of pages and paragraphs. Therefore we need to do it in an "automatical" setup

/Hans

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Hans,

 

Then I really need to understand more. Because in the ItemPublisher you can determine what is the root (which could be a Page or an entire Area).

 

And being tags, you could set the root page id to come from the pageview, so the way I see it, you could do it, using Example 1 from the documentation and replacing it with the current page ID or something.

 

string DataFromItem = RenderItemList(new {
            ItemType = "NameOfMyItem",
            ListSourceType = SelfPage,
            ListSourcePage = Pageview.Page.ID.ToString(),
            ItemFieldsList = "*",
            ListTemplate = "ItemPublisher/ListMyItems.cshtml",
            ListPageSize = "100",
        });
       @DataFromItem

 

Nuno

 

You must be logged in to post in the forum