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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:16:15
Script start
Timing: Jan 18 2025 11:16:15
Module start 'layout'
Timing: Jan 18 2025 11:16:15
Module start 'content'
Timing: Jan 18 2025 11:16:15
Module end 'content'
Timing: Jan 18 2025 11:16:15
Script end

Main resources:

Total runtime0.8504 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 587.9063152.6250
Module start 'layout' 0.00730.0040 740.531339.4453
Module start 'content' 0.01120.8376 779.9766494.0625
Module end 'content' 0.84880.0015 1,274.039112.1719
Script end 0.8503  1,286.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4151160.0002
Check MTime0.00130.1566160.0001
Mysql Total
Database connection0.00160.184210.0016
Mysqli_queries0.790492.9457520.0152
Looping result0.00050.0546500.0000
Template Total0.811495.420.4057
Template load0.00210.244520.0010
Template processing0.809395.175420.4047
Template load and register function0.00020.018310.0002
states
state_id_array0.00120.141410.0012
state_identifier_array0.00100.112320.0005
Override
Cache load0.00180.2097340.0001
Sytem overhead
Fetch class attribute can translate value0.00140.163510.0014
Fetch class attribute name0.00110.129330.0004
XML
Image XML parsing0.00370.432310.0037
class_abstraction
Instantiating content class attribute0.00000.001140.0000
General
dbfile0.00380.4457160.0002
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs