Does anyone have example code or details of how to use the Set Thumbnail trigger?
Basically you just have it use a GET or POST value to send an asset id to the broadcasting asset, this id will then replace the thumbnail on the details screen of that asset.
Simple enough? 
[quote]
Simple enough? 
[/quote]
That's what the manual told me
And while the manual information is great, an example that I can review would be much more useful. Like many web developers of old, and probably today, I've learnt from being able to 'view source'.
My question stems from building an asset builder process to create assets that will be standard pages. We're planning on having the enduser then create an image under that new asset (created at step 1 by the asset builder, which provides a link on the success page to edit the page).
It would be ideal if I could have not only a trigger to create image varieties of 'profile' and 'thumbnail' of that image but also a trigger which fires off on the 'thumbnail' variety being created and sets the thumbnail of the parent asset to that variety…
On puc.edu and other sites, I never actual set a thumbnail on the details screen of an asset. We create the image as a child of the asset, then, use an asset listing with list_current_asset_id to load up that image.
This gives us ultimate flexibility, and I would advise that you go this route. You can easily do this with two asset builders, passing the ID from the newly created page to the second asset builder that builds images.
It is just something for you to consider, but in my experience, it is well worth it.
[quote]
{snip}This gives us ultimate flexibility{snip}
[/quote]
It does have a slight trade off with performance, especially at the time the page is being rendered dynamically. As with most applications, you have to make the trade off with flexibility and performance. On a cached site, however, Nic's suggestion would be the best way to go and certainly seems along the lines of what you are doing anyway.
If you did need to create a set thumbnail trigger:
- Set event to Asset Accessed
- Add a condition of tree location, and set the root node to somewhere specific to where these asset are created.
- Add a condition that checks that URL matches Must be in URL and add something like thumb_id
- Add an action of Set Thumbnail and set to to Set new thumbnail based on a GET parameter of thumb_id
You will then be able to call the url of the page to set the thumbnail:
Set Thumbnail of new asset to thumbnail with asset #123
or an example using jQuery to set the thumbnail without actually having to visit the page:
$.ajax({
type: "GET",
url: "http://www.example.com/path/to/new/asset/",
data: "thumb_id=123",
success: function(msg){
alert( "Thumbnail has been set" );
}
});
Like Nic said, this isn't very flexible - but it certainly is possible if you need it to work this way.
[quote]
On puc.edu and other sites, I never actual set a thumbnail on the details screen of an asset. We create the image as a child of the asset, then, use an asset listing with list_current_asset_id to load up that image.
This gives us ultimate flexibility, and I would advise that you go this route. You can easily do this with two asset builders, passing the ID from the newly created page to the second asset builder that builds images.
It is just something for you to consider, but in my experience, it is well worth it.
[/quote]
Hi Nic,
This sounds just like what I am looking for but I am having a bit of trouble figuring it out. I have two asset builders - first one builds a page and on the created layout I have a link to another asset builder (thumbnail) with a get variable setting the asset id of the page just created as the create location. I do end up with an image / thumbnail created under the new page.
I was trying to then have a trigger set the image as the thumbnail for the parent page but am failing miserably so the idea of not having to do this sounds great! But I really don't quite understand how to use list_current_asset_id as you described and / or how to then actually display this image on the asset listing / paint layout?
Regards
[quote]
I was trying to then have a trigger set the image as the thumbnail for the parent page but am failing miserably so the idea of not having to do this sounds great! But I really don't quite understand how to use list_current_asset_id as you described and / or how to then actually display this image on the asset listing / paint layout?
[/quote]
Ok, so say you have your asset listing which lists news items, and have a customized type format for the news item. You would then create a second asset listing, which would be a "helper" listing. You would configure this listing for images, and go down to the dynamic parameters section, set the session var to list_current_asset_id. Then, customize the image type format how you would want the "thumb" to appear. Next, nest this "helper" asset listing into the news item type format of the first asset listing.
So, when each news item is listen, our "helper" listing will look down a level and find an image, then print out the info the the type format that you created. So, each one of the news items would have an image printed with it.
Let me know if you have any other questions…
[quote]
Ok, so say you have your asset listing which lists news items, and have a customized type format for the news item. You would then create a second asset listing, which would be a "helper" listing. You would configure this listing for images, and go down to the dynamic parameters section, set the session var to list_current_asset_id. Then, customize the image type format how you would want the "thumb" to appear. Next, nest this "helper" asset listing into the news item type format of the first asset listing.
So, when each news item is listen, our "helper" listing will look down a level and find an image, then print out the info the the type format that you created. So, each one of the news items would have an image printed with it.
Let me know if you have any other questions…
[/quote]
Thanks Nic, I sort of have it working with a few issues
- on the details screen of the "helper" asset listing if I don't specify a root node then nothing is displayed.
- if I do specify a root node then all images in the site under the specified root node are displayed.
- Since I am nesting this asset in my paint layout I am guessing that I have to have multiple div's if I want to put the image in the middle of my page somewhere?
Currently when I use thumbnails for images in articles I use varieties created by trigger to display images of consistent size. Can I still do this with the list_current_asset_id method?
Anthony, re your sample jquery - I have tried this by adding the code to the created layout for my image asset builder but it just displays the code on the page and doesn't run anything. I have tried creating new div of format code, raw html etc. but am sure I am missing something!
Overall I am starting to think that I might still be better off to use thumbnails for my main article image and then use list_current_asset_id to add additional images to bottom of article that are located under the page asset. Can't wait till I get it working…
Thanks so much for your help!
And just to make sure I am grasping asset building of a standard page + adding image + setting image as thumbnail to the standard page:
1 - first asset builder adds page
2 - created layout has link to image builder page passing get variable of page id so that image can be added under the page.
3 - on created layout of image builder I need to build a link using the thumb_id variable to set the uploaded file as the thumbnail of the originally created page.
Am I on the right track?
[quote]
Thanks Nic, I sort of have it working with a few issues
- on the details screen of the "helper" asset listing if I don't specify a root node then nothing is displayed.
- if I do specify a root node then all images in the site under the specified root node are displayed.
- Since I am nesting this asset in my paint layout I am guessing that I have to have multiple div's if I want to put the image in the middle of my page somewhere?
Currently when I use thumbnails for images in articles I use varieties created by trigger to display images of consistent size. Can I still do this with the list_current_asset_id method?
[/quote]
You would set your root node to the entire site, but, make sure you set you dynamic parameters like:
[attachment=446:Screen shot 2010-02-25 at 8.32.20 AM.png]
Yes, you will need to create multiple divs, so that you can structure code around the nested asset listing.
You can still use your varieties, just use the appropriate keywords in the type format of your "helper" listing.
Screen shot 2010-02-25 at 8.32.20 AM.png (16.7 KB)
[quote]
You would set your root node to the entire site, but, make sure you set you dynamic parameters like:
[attachment=446:Screen shot 2010-02-25 at 8.32.20 AM.png]
Yes, you will need to create multiple divs, so that you can structure code around the nested asset listing.
You can still use your varieties, just use the appropriate keywords in the type format of your "helper" listing.
[/quote]
Thanks Nic, the dynamic parameters in your image are exactly what I have but I still get all images, not just the image(s) under the standard page being displayed.
I am nesting the "helper" list in a paint layout's type format (default). This paint layout is applied to the standard pages folder and sub-assets (all standard pages) which I am using as my news items. Your instructions talk about nesting the helper image list in an asset listing.
Should this still work in a paint layout?
I will set up everything from scratch and see.
[quote]
Thanks Nic, the dynamic parameters in your image are exactly what I have but I still get all images, not just the image(s) under the standard page being displayed.
I am nesting the "helper" list in a paint layout's type format (default). This paint layout is applied to the standard pages folder and sub-assets (all standard pages) which I am using as my news items. Your instructions talk about nesting the helper image list in an asset listing.
Should this still work in a paint layout?
I will set up everything from scratch and see.
[/quote]
Ah, so you are not using an asset listing? list_current_asset_id is specifically for asset listing type format assets.
In your case, I would customize the paint layout for standard pages, then just nest that same helper listing, without the dynamic parameters, to look one level down, for image assets.