I'm trying to make a side menu that knows the parent category of the page being viewed. What I currently have is a mixture of Paint Layouts, Asset Listings, Category Folders and News Items to create something similar to a 'Blog'.
A combination of the Paint Layout and Asset Listing is what makes up the screen content when viewing a News Item. Currently I am able to retrieve the name of the News Item asset by using the $asset_name% keyword replacement in the paint layout that generates the News Item's contents.
Each of the News Items are created within a folder asset which acts as a category. What I want to do with the menu (using the EasyTree Menu js) is have Squiz tell me what the parent category is of the News Item currently being viewed - store this as a variable that is passed to the EasyTree menu js at runtime so that it will have all category folders contracted except for the category that the current item being viewed is within. Pretty much making it a smart menu.
Seeing as though I am using this Keyword Replacement on a Paint Layout bodycopy, I just don't know how to get the name of the parent folder. Is there a possible way to do this? The closest thing I could find is to get the %asset_lineage% and then using .replace() method to cut out the unecessary text in the string, sounds messy when I come to think of it.
An asset could have many many parents (if you link it in multiple locations), so this can pose an issue for your question. However, if there is only one parent, you can create an Asset Listing that looked UP the tree one level (direct links only set to Yes). Set the Dynamic Params to current asset, then nest that Asset Listing in the paint layout. That will tell you what the parent is.
For now, I'm just splitting the string returned with Javascript.
The folders will always be in the same place and the News Items will always be within one of the folders so although it could be considered a 'string hack', its risk is controlled and minimized.
Thanks Nic, I had a go at that but it did not work out for me, I got no results from the asset listing. Just to clarify the process:
1) Create an asset listing page (which I just placed in my "components" folder)
2) Nest that asset listing page into the paint layout which displays the content for the News Item ("News Item Format" bodycopy)
3) Go back to the newly created asset listing page and then call up the javascript function: alert ("%asset_name%"); on the "default format" bodycopy?
I am just getting the "no results were found" message and no javascript alert action.
I'm not sure what's going on here, did you want me to PM with more visual information?
You missed three important steps. Set Tree direction to "Up the Tree", and set Direct Links to Yes. You also need to set the Dynamic Params to the Current Asset.