Forums / Suggestions / Select frontpage image

Select frontpage image

Author Message

Daniel Staver

Wednesday 10 September 2003 5:23:33 am

I suggest adding a function to select a frontpage image from the list of related images. This was possible in 2.2, and it would be nice to have it in 3.x as well.

It can be done right now by adding an integer field to the article class where you insert the ID of the related object you want on the frontpage. To make it more user-friendly you can also override the template and display the integer field as a drop-down list of all related images and allow the user to select which one to use as a frontpage image.

The problem with this is that you manually have to remove the ID if you delete an image.

Something like this could probably be generalized into a related-selector datatype which would allow the user to make a selection between the exisiting releated objects. The selector should support filtering of specific class types.

Daniel Staver
http://daniel.staver.no

Daniel Staver

Friday 19 September 2003 1:46:21 am

I've solved it for now by creating an override for the integer edit field for class 2 in admin, like this:

[frontpageimage]
Source=content/datatype/edit/ezinteger.tpl
MatchFile=frontpageimageselect.tpl
Subdir=templates
Match[class]=2

And then I put this in the template:

{let name=CurrentObject current_object=fetch('content','version',hash(object_id,$attribute.contentobject_id,version_id,$attribute.version))}
<select name="ContentObjectAttribute_data_integer_{$attribute.id}" size="1">
{section show=$attribute.data_int}
<option value="">Ikke bruk forsidebilde</option>
{section-else}
<option value="" selected>Ikke bruk forsidebilde</option>
{/section}

{section name=ContentObjectRelation loop=$CurrentObject:current_object.related_contentobject_array}
{section show=eq($attribute.data_int,$CurrentObject:ContentObjectRelation:item.id)}
<option value="{$CurrentObject:ContentObjectRelation:item.id}" selected>{$CurrentObject:ContentObjectRelation:item.id} - {$CurrentObject:ContentObjectRelation:item.name}</option>
{section-else}
<option value="{$CurrentObject:ContentObjectRelation:item.id}">{$CurrentObject:ContentObjectRelation:item.id} - {$CurrentObject:ContentObjectRelation:item.name}</option>
{/section}
{/section}
</select>
{/let}

Daniel Staver
http://daniel.staver.no