Forums / Developer / To fetch article class which has image attribute

To fetch article class which has image attribute

Author Message

Romeo Antony

Friday 02 July 2010 5:28:26 am

In some templates need to fetch the article class which has image attribute.Means do not need to fetch article class without image attribute.

In some templates need to fetch all artciles with and without image attribute.

So where do I make chnages .

Someone told me that I need to set the attribute filter in the php class.

If I set the attribute filer , I can't fetch article class without images

Ivo Lukac

Friday 02 July 2010 5:57:22 am

I am not quite sure what you need, but if you need to distinguish article objects which actually have an image uploaded you can use this extended_attribute_filter in your extension:

<?php
class eZExtendedImageFilter{ 
 function eZExtendedImageFilter(){  
  // Empty... 
 }
 function createSqlParts( $params ) {  
  $result = array( 'tables' => '', 'joins'  => '' );  
  if ( isset( $params['classes'] ) ) {   
   $classes = $params['classes'];  
  } else return;
  $attr = 'image';  
  if ( isset( $params['attr'] ) ) {   
   $attr = $params['attr'];  
  } 
  $attribute_ids = array();  
  foreach ($classes as $class) {   
   array_push($attribute_ids,eZContentObjectTreeNode::classAttributeIDByIdentifier( $class . '/' . $attr ));  
  }
  $class_cond = array();  
  foreach ($attribute_ids as $aid) {   
   if ($aid) {    
   array_push($class_cond, 'i1.contentclassattribute_id = '.$aid);   
   }  
  }
  $string_class_cond = implode(" OR ",$class_cond);  
  $filterSQL = array();  
  $filterSQL['from']  = ", ezcontentobject_attribute i1 ";  
  $filterSQL['where'] = " (i1.contentobject_id = ezcontentobject.id AND (" . $string_class_cond . ") AND i1.version = ezcontentobject_name.content_version AND i1.language_code = ezcontentobject_name.real_translation AND i1.data_text LIKE '%is_valid=\"1\"%' ) AND ";  
  return array( 'tables' => $filterSQL['from'], 'joins'  => $filterSQL['where'] ); 
 }
}
?>

Add this into extendedattributefilter.ini.append.php:

[ExtendedImageFilter]
#The name of the extension where the filtering code is defined.
ExtensionName=your_extension
#The name of the filter class.
ClassName=eZExtendedImageFilter
#The name of the method which is called to generate the SQL parts.
MethodName=createSqlParts
#The file which should be included (extension/myextension will automatically be prepended).
FileName=kernel/classes/ezimagefilter.php

To learn more about extended_attribute_filter look here: http://ez.no/doc/ez_publish/technical_manual/4_x/reference/modules/content/fetch_functions/list

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

eZ debug

Timing: Jan 18 2025 11:07:17
Script start
Timing: Jan 18 2025 11:07:17
Module start 'content'
Timing: Jan 18 2025 11:07:18
Module end 'content'
Timing: Jan 18 2025 11:07:18
Script end

Main resources:

Total runtime1.2816 sec
Peak memory usage4,096.0000 KB
Database Queries192

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0086 587.8438180.8125
Module start 'content' 0.00861.0370 768.6563543.0000
Module end 'content' 1.04560.2360 1,311.6563332.7422
Script end 1.2815  1,644.3984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.3434210.0002
Check MTime0.00150.1200210.0001
Mysql Total
Database connection0.00100.080810.0010
Mysqli_queries1.196793.37301920.0062
Looping result0.00240.19121900.0000
Template Total1.246497.320.6232
Template load0.00220.170220.0011
Template processing1.244297.083020.6221
Template load and register function0.00030.021810.0003
states
state_id_array0.00090.067610.0009
state_identifier_array0.00190.151520.0010
Override
Cache load0.00170.1346170.0001
Sytem overhead
Fetch class attribute can translate value0.00130.099630.0004
Fetch class attribute name0.00140.105540.0003
XML
Image XML parsing0.00140.105430.0005
class_abstraction
Instantiating content class attribute0.00000.000740.0000
General
dbfile0.00670.5200340.0002
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 13
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs