Related pages, but if asset has none, use parent's related pages, recursed


(Tom Chadwin) #1

Do I win the prize for the least elegant topic title?

 

I am being asked if there is a way to allow end users (ie Edit+ users) to specify two flavours of related page for each page asset. If none are defined for a given page, the parent's related pages should be used, and so on up the tree, until related pages are found. I am trying to figure out how I might achieve this. Would it be something vaguely along these lines:

 

  1. create an asset listing to select related assets defined in some way (such as type-2 links in a subfolder), and list them in the results bodycopy
  2. in the no results bodycopy, nest an asset lineage or similar to select the page's parent page, and apply a paint layout which repeats step 1 for this newly-determined parent asset

I don't know if I've described this adequately. If comprehensible, is my approach plausible?


(Tom Chadwin) #2

I've hit a problem implementing this as proposed above.

 

In an asset listing's default type format, I am nesting in another asset listing, and trying to pass it the listed asset's ID as a GET variable. However, in the nested content properties, if I enter %asset_assetid% as the value of a GET var, the ID of the asset listing page is passed, not the ID of the listed asset.

 

Is this a bug, or am I getting something wrong?


(Nic Hubbard) #3

Possibly try using a globals keyword instead? Take a look at the bottom of this page:

 

http://manuals.matrix.squizsuite.net/content-types/chapters/nest-content


(Tom Chadwin) #4

I don’t think so. No globals are likely to relate to the assets in an asset listing. To make it plain, I need to use an asset listing’s default type format bodycopy keyword replacement %asset_assetid% as the root node for a subsequent asset listing. Or achieve the same result with a different technique - see my initial description of what I am trying to do.


(Nic Hubbard) #5

I don't think so. No globals are likely to relate to the assets in an asset listing. To make it plain, I need to use an asset listing's default type format bodycopy keyword replacement %asset_assetid% as the root node for a subsequent asset listing. Or achieve the same result with a different technique - see my initial description of what I am trying to do.

 

Oh sorry, I was misunderstanding what you were wanting to do. You need to use the list_current_asset_id session var for this. It will do exactly what you are needing.


(Bart Banda) #6

Have you tired using %list_current_asset_assetid% as the root node?

 

Also might be related:  http://bugs.matrix.squiz.net/view_bug.php?bug_id=6449


(Tom Chadwin) #7

Ah, OK - I had no ides that existed. That works - many thanks, both.

 

Next problem: nesting the asset listing which finds the parent into the no results bodycopy leads to a recursion warning. An ancient forum post implies that this warning cannot be suppressed:

 

(Ack - IE11 does not like this forum - having to retype this whole post, and it won't let me paste a URL. The forum topic in question is 3518.)

 

I would like to suppress the warning, as I am confident the recursion is finite, since it is traveling up the asset tree. Can it be done? The same post suggests nesting into a paint layout, but I'm not sure that's doable as I need to nest only into the no results bodycopy. I'll see if I can figure it out that way.

 

The hack I can think of is to create multiple clones of the asset listing and nest those into each other, rather than a single one nested into itself. Since the site owners claim they are limiting the depth of nav across the site, that should work, but it is a hack, and the recursed method would be much better. Can it be done?


(Tom Chadwin) #8

In case anyone is interested in this one, I am getting somewhere:

 

  1. create asset listing of child redirect pages with a given link value
  2. in the no results bodycopy, put an asset listing to get the page's parent
  3. in the default type format bodycopy of 2, create a clone of 1
  4. in the no results bodycopy of 3, put a clone of 2, selecting grandparent page
  5. etc, until you have as many copies as you have navigation levels in your site (or more strictly, consecutive nav levels which do not have their own related pages)

Now I'm just trying to get the right list heading to come out. If my page structure is grandparent > parent > page > child > grandchild, and parent has related pages, but page, child, and grandchild do not, I need the asset listing on page, child, grandchild, etc to have a heading of "Popular in parent" (not "Popular in page/child/grandchild"). In other words, I need the results bodycopy of an asset listing to be able to render the title of the page currently reached in the recursion process. I think Nic and Bart's session var might help me do this, but I've not figured it out yet.

 

And my head hurts.

 

Edit: I cannot think of a more suitable forum post to take me from "member" to "advanced member".


(Tom Chadwin) #9

Final bit of the jigsaw, to get the parent of the linked pages out as a heading. When nesting in the asset listing which finds the parent (step 2 in the preceding post), add a GET variable with this value:

%globals_session_list_current_asset_id^as_asset:asset_name%

You can then output this in the Page contents bodycopy of the asset listing you nest in (step 3) as:

 

%nested_get_VARNAME%

 

I think that all works. I'm guessing these pages will only perform when cached.


(Tom Chadwin) #10

A problem has emerged. If a page is linked in two separate locations in the site, two link lists are printed out on each page. How can I limit it only to list assets up the tree from the current location in the structure, not from all linked locations?