I was wondering what the best or better way to link an asset is. In designs I have been using "%globals_asset_url:123%" but in content page I tend to use "./?a=123". I get that the globals keyword may allow me to use keyword modifiers but when I don't need that option is it better to use the other code?
Is there a benefit to either of these? Is one better than the other? What does everyone else use?
Best way to link assets with keywords
[quote]
Is there a benefit to either of these? Is one better than the other? What does everyone else use?
[/quote]
I use ./?a= just out of habit because it has been around longer.
I once tried a performance test listing 500 assets using ./?a=123 and then %globals_asset_url:123% and the _performance test. The results were inconclusive. So, not really sure if there are performance differences.
Yeah I didn't think there would be much difference if any. I used to always write ./?a= because it is shorter and what I learned first, but now I'm moving towards %globals_asset_url:123% for readability among the team and users.
The link in format of ./?a=123 creates notice link between the assets, and monitored by Matrix mechanism for quality (safe trash, broken link report etc).
%globals_asset_url:123% doesn't create links. If the referred asset is deleted, the link is broken without any warning.
[quote]
The link in format of ./?a=123 creates notice link between the assets, and monitored by Matrix mechanism for quality (safe trash, broken link report etc).
%globals_asset_url:123% doesn't create links. If the referred asset is deleted, the link is broken without any warning.
[/quote]
Excellent observation and something I knew about, but I had forgotten about for the moment!
Oh yeah your're right Robin - can't believe that went by me. Thanks for pointing it out
Something odd I've only just noticed in the front end source code of pages is the formatting of URLs when using ./?a= for links in Design files.
In the parse file I have these two lines:
<link rel="stylesheet" href="./?a=406417" type="text/css"> <script type="text/javascript" src="./?a=406405"></script>
All good, but they output like this:
<link rel="stylesheet" href="?a=406417" type="text/css"> <script type="text/javascript" src="http://www.example.com/__data/assets/js_file/0019/406405/respond.js"></script>
It seems like the <link> href attribute doesn't like to support ./?a= formatting as the script tag and images within the template seem to output fine. Anyone else noticing this? Currently on Matrix v4.10.2
What is the #406417 asset type?
#406417 is a CSS Design File and there is a reference to a CSS File which has the same output.
Something odd I've only just noticed in the front end source code of pages is the formatting of URLs when using ./?a= for links in Design files.
In the parse file I have these two lines:
<link rel="stylesheet" href="./?a=406417" type="text/css"> <script type="text/javascript" src="./?a=406405"></script>
All good, but they output like this:
<link rel="stylesheet" href="?a=406417" type="text/css"> <script type="text/javascript" src="http://www.example.com/__data/assets/js_file/0019/406405/respond.js"></script>
It seems like the <link> href attribute doesn't like to support ./?a= formatting as the script tag and images within the template seem to output fine. Anyone else noticing this? Currently on Matrix v4.10.2
I wouldn't use ./?a= style links in a parse file as they are not well supported. Use globals or mysource_file style links.
In the parse file, use following design area to include the CSS design file.
<MySource_AREA id_name="layout" design_area="linked_css" />
Then in the design customisation of the parse file, customise the linked_css design area to point to 406417.
If you don't need dynamic function, just use CSS text file instead. CSS text file can be linked the way you link JS file.
Check out the manual http://manuals.matrix.squizsuite.net/designs/chapters/css-design-file
Edit: added the manual link.
In the parse file, use following design area to include the CSS design file.
<MySource_AREA id_name="layout" design_area="linked_css" />
Yea I've been trying a combination of all the options just to see what works best for us.
I wouldn't use ./?a= style links in a parse file as they are not well supported. Use globals or mysource_file style links.
I think we will stick with the globals for now.
Thanks as always for the responses guys.