I need to determine the parent of the page being viewed. If the page being viewed is linked in multiple locations, my current asset listing to achieve this brings back the asset's parents from all of these locations. I need it to return only the parent in the viewed linked location. How?
URL-specific parent of asset linked in multiple locations
I am already using an asset_lineage design area which can output the asset id of the root node which would narrow this down enough for me. How can I output this value into something which can then be pulled in when I nest in the asset listing? In other words, how can I use an attribute of an asset lineage ASSET outside the design/parse file - can I set a session var or some such?
If your site is your root node, can you use %globals_site_assetid% or %globals_site_asset_assetid% ?
No, the different root nodes are children of the site asset.
I’m now experimenting with grouping the asset by parent, and in the group format bodycopy trying (pseudocode):
%group_name_linked^replace_keywords:contains:{globals_asset_url}:{group_listing}:%Not working yet. Need to check if the global keyword and the modifiers work in the group format.
No joy yet. It's really frustrating, because the information is kind of there to achieve this, I think, but not quite in the format I need to be able to get modifiers to return the right result. I need to find out if %globals_asset_url% contains the HREF only of %group_name_linked%. I can get the HREF on its own like this:
%group_name_linked^replace:(">.*):^replace:<a href=":%
I would need to find out whether %globals_asset_url% ^contains that, but I think everything is likely to be evaluated in the wrong order, if at all, to achieve this:
%globals_asset_url^replace_keywords:contains:{group_name_linked^replace:(">.*):^replace:<a href=":}:{group_listing}:%
That doesn't seem to work. *sigh*.
Don't hate me for saying this, but I would just get it done using javascript. Would be very quick and easy:
var current_url = 'http://www.test.com/path/1/4';var parent_urls = [‘http://www.test.com/path/1’,
‘http://www.test.com/path/2/4’,
‘http://www.test.com/path/3/4’,
‘http://www.test.com/path/4/5/3’];// Check to see if current URL is part of any of the parent URLs
for (var i=0;i<parent_urls.length;i++) {
parent = parent_urls[i];
if (current_url.indexOf(parent) != -1) {
alert(parent);
}
}
Working example: http://jsfiddle.net/zedsaid/6kfL9/3/
That's what I've resorted to. I feel unclean. However, your revelation of the %parent_*% keyword replacements in group format bodycopies might yet allow me to crack this without script.
Thanks
Tom
Right. Why doesn't this work?
%globals_asset_url^replace_keywords:contains:{parent_url}:{group_listing}: %
Right. Why doesn't this work?
%globals_asset_url^replace_keywords:contains:{parent_url}:{group_listing}: %
One extra colon at the end?
%globals_asset_url^replace_keywords:contains:{parent_url}:{group_listing}%
I don’t think so. That’s so that there is empty output if the ^contains is false. I’ll try it though.
I don't think so. That's so that there is empty output if the ^contains is false. I'll try it though.
Yea you are right, my bad, I read it wrong. That won't work.
Thanks for letting me know before I tried it out. Does anyone else have any ideas why the code in post #8 of this thread does not work? As far as I can tell, it always resolves the ^contains as false.
Right. Why doesn't this work?
%globals_asset_url^replace_keywords:contains:{parent_url}:{group_listing}: %
You are using global keyword with the asset specific keyword there. The keyword "group_listing" and "group_name_linked" keywords are the listing page specific keyword and are not recognised at the global level, that is when the global keywords are evaluated.
Not very sure but this keyword might work: %asset_metadata_global_url^replace_keywords:contains:{parent_url}:{group_listing}: %, where "global_url" is the metadata field applied to the listing page that has the global asset url value.
Do you mean add global_url as a metadata field, with a default value of %globals_asset_url%, and then use that?
I'm still not getting anywhere with this. I'm not sure if I understood Chiranjivi's idea correctly. If I have, I don't think it can work. I can't set the URL as a default metadata value, since the value I need to compare to is different depending on where the asset is in the site structure.
This is so frustrating. Can anyone definitely confirm Chiranjivi's reason why my attempt did not fail - that you cannot mix asset grouping keywords with global keywords in a keyword replacement, as they are replaced at different times?
Can anyone else think of a way to achieve this?
I'm going to try passing the nested asset listing a GET variable with the value of %globals_asset_url%, and then try that. If someone tells me that %nested_get_*% replacements are unavailable in group formats, I shall scream.
If someone tells me that %nested_get_*% replacements are unavailable in group formats, I shall scream.
It seems that %nested_get_*% replacements are unavailable in group formats.
I've had to give up, as the site goes live tomorrow. Instead, I've removed all instances of pages linked in multiple locations. Instead, I have created separate pages in each location, added the content to one, and then nested that into the other. Very much not ideal, messy, and inconvenient, so if anyone can solve the problem, it would be great.
Hi Tom - I've had to do this but did not (could not??) do it with an asset listing or keyword. What I did was use a asset lineage design area, you force it to start at the top and then only show 1 level. Then, when you have linked pages, it will show the one based on the currently viewed URL. It's one of the neat things about the asset lineage design area. It's also pretty limited, e.g. you need to have a very specific structure, and/or be pretty specific about what the 'top' is, and if you want to set it up for number of different areas you will end up with a couple of different design customisations to cater for everything. I'm at home at the mo, happy to look it up again and post instructions tomorrow of what I did if you like.
Cheers
Thanks, Tim. The issue is that this is in a paint layout, not a design, so I don't have access to design areas. I'm also not sure your approach would work in our case, which is fundamentally bottom-up. I've actually been looking at this again this morning, and thought I had thought of something which might help, but it seems to have stopped the whole thing working at all, so I need to debug that first.