Hi,
There seems to be a problem with asset keyword replacement when using them for the value of a GET variable passed to a nested asset.
What I'm doing:
I have a search result (or asset listing, I've tried both!) that lists standard page assets. In the default Type Format of the search asset, I am nesting another asset listing, The nested asset listing is listing the children of a DB Data Source. The DB Data source has a Dynamic Input which takes its value from a GET parameter (eg. called "vid").
And this is where my problem occurs, when I define a GET variable in the nested asset (called "vid") and set it to a fixed value, eg. "foobar", everything works fine and the DB Data Source returns the expected result from the database.
Yet when I then use a keyword for the value of the nested GET parameter, eg. %asset_name%, which also has the value of "foobar" for the asset being listed by the first search asset (the search only has 1 result in my current tests) - the DB Data Source query returns no result!
I've tried this on both a production server running 3.28.10 and a test server running 4.2.3 with identical results - would anyone know about this? Or is this a bug? As according to the manual:
http://manuals.matrix.squizsuite.net/content-types/chapters/nest-content/
"…These values can include Global Keyword Replacements (%globals_%), Keyword Replacements of the nested asset (%nested_asset_%) and Keyword Replacements of the nesting asset (%asset_*%)."
So it should be working as far as I can tell…
thanks,
Maks.
Asset keywords for nested assets not working
[quote]
Hi,
There seems to be a problem with asset keyword replacement when using them for the value of a GET variable passed to a nested asset.
What I'm doing:
I have a search result (or asset listing, I've tried both!) that lists standard page assets. In the default Type Format of the search asset, I am nesting another asset listing, The nested asset listing is listing the children of a DB Data Source. The DB Data source has a Dynamic Input which takes its value from a GET parameter (eg. called "vid").
And this is where my problem occurs, when I define a GET variable in the nested asset (called "vid") and set it to a fixed value, eg. "foobar", everything works fine and the DB Data Source returns the expected result from the database.
Yet when I then use a keyword for the value of the nested GET parameter, eg. %asset_name%, which also has the value of "foobar" for the asset being listed by the first search asset (the search only has 1 result in my current tests) - the DB Data Source query returns no result!
I've tried this on both a production server running 3.28.10 and a test server running 4.2.3 with identical results - would anyone know about this? Or is this a bug? As according to the manual:
http://manuals.matrix.squizsuite.net/content-types/chapters/nest-content/
"…These values can include Global Keyword Replacements (%globals_%), Keyword Replacements of the nested asset (%nested_asset_%) and Keyword Replacements of the nesting asset (%asset_*%)."
So it should be working as far as I can tell…
thanks,
Maks.
[/quote]
Hi Maks,
From what I understand you are trying to use the keyword (%asset_name%) and wanting to get replacement for this as the name of the asset that is returned by your search page (or asset listing page). Correct if I am wrong here.
[quote]
"…These values can include Global Keyword Replacements (%globals_%), Keyword Replacements of the nested asset (%nested_asset_%) and Keyword Replacements of the nesting asset (%asset_%)."
[/quote]
So if here you have a nested asset of "another Asset Listing" you can use %nested_asset_% keywords for this listing page. If you use %asset_*% keyword it will try and pick the replacement from the first asset listing page.
This functionality isn't designed to treat the searched (or listed) asset as the asset to get replacement for asset based keywords. Hope all this makes sense
Any questions or concerns don't hesitate to fires them back.
Ash
Hi Ash,
Thanks for the quick response!
Ok, I think I understand, the %asset_% keywords will refer to the search assets attributes, not to each asset returned by the search.
The reason I thought that it would work is that if you have say a RawHTML Div inside the search Assets Type format, in that Div %asset_% does refer to the current search result asset.
To give a bit more background:
I have a SQL DB (MS SQLServer) that I can query with Matrix, that given an assets name as input in the SELECT, it will return a string which I can use to form a url to point to a jpg hosted outside of Matrix.
Of course we have specifically named the std page assets to match what is stored in the "mapping" with the SQL DB.
So thats why I'm attempting to do the above, basically to print a <img> tag in the Type Format of the search result, wiht a JPEG that represents each std page found in the search results.
Essentially I need to be able to make a DB query per each result asset of a search (or assetlisting).
Could you advise if there is any way to achieve what I'm trying to do?
thanks,
Maks.
[quote]
Hi Maks,
From what I understand you are trying to use the keyword (%asset_name%) and wanting to get replacement for this as the name of the asset that is returned by your search page (or asset listing page). Correct if I am wrong here.
So if here you have a nested asset of "another Asset Listing" you can use %nested_asset_% keywords for this listing page. If you use %asset_% keyword it will try and pick the replacement from the first asset listing page.
This functionality isn't designed to treat the searched (or listed) asset as the asset to get replacement for asset based keywords. Hope all his makes sense
Any questions or concerns don't hesitate to fires them back.
Ash
[/quote]
[quote]
Hi Ash,
Thanks for the quick response!
Ok, I think I understand, the %asset_% keywords will refer to the search assets attributes, not to each asset returned by the search.
The reason I thought that it would work is that if you have say a RawHTML Div inside the search Assets Type format, in that Div %asset_% does refer to the current search result asset.
To give a bit more background:
I have a SQL DB (MS SQLServer) that I can query with Matrix, that given an assets name as input in the SELECT, it will return a string which I can use to form a url to point to a jpg hosted outside of Matrix.
Of course we have specifically named the std page assets to match what is stored in the "mapping" with the SQL DB.
So thats why I'm attempting to do the above, basically to print a <img> tag in the Type Format of the search result, wiht a JPEG that represents each std page found in the search results.
Essentially I need to be able to make a DB query per each result asset of a search (or assetlisting).
Could you advise if there is any way to achieve what I'm trying to do?
thanks,
Maks.
[/quote]
Hi,
Only 2 options I can think of is :
- somehow import the Asset into Matrix and place these images as the thumbnail for respective Standard Pages from its details screen. But if the number of standard Pages is Massive then Ii guess this option isn't really suitable.
- Other options would be to list all the url from this other DB on the listing/search page but Hide it from view on frontend. With simple JQuery you should then be able to map and get the respective URLs for each of the assets.
I am actually a Matrix developer and not an implementerSo I am the behind the scene guys so I would let one of the other nice people help you out on this one.
Cheers and Good Luck
Ash
Thanks Ash - I guess I will need to look into using some form of external tool.
As a developer (I'm a dev myself, though Java and JS more than PHP :-), can you comment on why the keyword "resolution" is different for Nest Content Divs, vs Raw Html Divs?
Maks.
I have tried to do what you are describing, if my understanding of what you are describing is correct
My understanding;
You have a nested asset in your type format for a search because you want to construct an image tag based on a query using the asset name of the result. You are trying to use the ability to pass a variable to the nested asset as the criteria for the sql query and then use the result to construct the img tag.
So, in your nested asset container you are using %asset_name% and in the nested asset you are trying to pick it up with %globals_get_whateveryoucalledthevariablename%
–//–
I expect that you aren't having any success and depending on what version of Matrix you have you will get a lot of errors. As a Matrix developer Ash could explain how Matrix parses all the keywords as it works it's way through all the nested assets but ultimately I think that passing an asset attribute by keyword through a nested div will only "reliably" work in limited circumstances and from the version that it was fixed in. I have got some working in nests of nests of nests but the process is extremely convoluted and mostly not worth it.
My question is, what is the structure of the image tag you are trying to create? If you have a predictable path with an image that is named as the page all you would need to do is something like <img src="something.com/path/%asset_name%.jpg> in the types format. If the src's are not structured and there is a link between the page name and the url that you can get from the query then maybe construct some javascript that references a variable list in the main body that is built from your query. Does that make sense?
Anyway, Matrix is the ultimate for configurable workarounds so I am sure you will find a way.
Cheers
Shane
Hi Shane,
Thanks for your suggestions!
Thats almost it, but I'm not directly using it in the nested asset - which is itself an asset listing, but the DB Source that that (nested) asset listing is listing - phew what a mouthful.
What I have is a search asset returning 1 or more standard pages.
Each of those returned pages has a asset_name which maps to a image name.
eg. "foobar" (asset_name) -> Abc123 (image name)
That above mapping is stored in a SQL db - it can be changed at any time via systems external to Matrix.
So the DB Data Source asset has a SQL query that given "foobar" in the SELECT gives back "Abc123" as a shadow asset.
You guessed correctly that we then have a predictable path for the image url, that I then use "Abc123" as the suffix within the Nest content
eg. <img src="something.com/path/%asset_name%.jpg>
though of course in the img URL, its the shadow asset's %asset_name% (the result of the sql query) that I need to use.
As I said, the above works fine as long as I "hardcode" a value for the nested content GET variable instead of trying to use %asset_name%
I can of course just set up a "mapping" page in Matrix that uses the DB Data Source asset and given a Http GET param would return the required img name and then use jQuery in my search pages to fill that into the IMG elements , but I'm tyring very hard to avoid the page relying on JS for the image loading, but as you say, that may the only way to do it.
The main thing that has tripped me up is that difference in the way that Raw HTML Div's in a search/listing Type Format resolve %asset_name% to be each the result assets one, BUT the Nested Content Divs in the very same Type Format resolve it to be the search assets %asset_name% From my point of view, for a search asset (or even asset listing) I don't see the value of referring to the search assets attributes in its Type Formats - because those are specifically being applied to each child of the search asset, not the search asset itself…
I'm hoping Ash still has the time to chime in with an answer of why it happens to work that way?
Maks.
[quote]
I'm hoping Ash still has the time to chime in with an answer of why it happens to work that way?
Maks.
[/quote]
Hi Maks,
First thing we need to know here is any container type will generate a content file for itself (which is used to print frontend) when we press the commit button.
The main difference here is the raw/wysywig container type are used to provide the format of output we want. This keywords are not populated while the content file for these containers is generated. Now when a search page or listing page has assets to show it goes to this container type and asks it for how user want to format the output on the screen. This is completely dynamic as you can see.
Again the container in the "default type format" is the only one that behaves this way. The containers on Standard Page or other assets WILL take the Asset being printed (so say the standard page) as its keyowrds replacements.
Hope this helps understand the working better.
Ash
Thanks for the explanation Ash, that makes more sense now, knowing that its only WYSIWYG and raw Divs that resolve the keywords are page render time and the others are at asset commit time.
Will be handy to know this for the future too. Guess I'll need to go the clientside JS route for my implementation.
thanks again,
Maks.
[quote]
Thanks for the explanation Ash, that makes more sense now, knowing that its only WYSIWYG and raw Divs that resolve the keywords are page render time and the others are at asset commit time.
Will be handy to know this for the future too. Guess I'll need to go the clientside JS route for my implementation.
thanks again,
Maks.
[/quote]
Yep No Worries Maks. I know it gets a bit confusing but yeah its always good to know the working.
Glad it helped.
Ash