Fetch nodes from sections?

Author Message

Siniša Šehović

Tuesday 06 December 2005 3:25:45 pm

Hi all!

Is it possible to fetch nodes from specified section?

Best regards,
S.

---
If at first you don't succeed, look in the trash for the instructions.

Ben Peter

Tuesday 06 December 2005 4:08:36 pm

Hi Sinisa,

http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/section/fetch_functions/object_list

-- is that what you are looking for? From the object, you can track back to its main node.

Cheers,
Ben

Siniša Šehović

Wednesday 07 December 2005 12:00:44 am

Hi Ben

Thanx for quick reply!

Yes that's what I was looking for :-)

Btw, is it possible to filter object by date of publish and class_id?

Best regards,
S.

---
If at first you don't succeed, look in the trash for the instructions.

Wednesday 07 December 2005 1:54:37 am

Yes it's possible. Here's a complete example from one of my sites:

{* Grab all the news articles. *}
{*
{let children=fetch( content,
                     list,
                     hash( parent_node_id, $node.node_id,
                           sort_by, $node.sort_array,
                           class_filter_type, include,
                           class_filter_array, array( 'article' )
                         )
                    )
}
*}

<h2>2005</h2>
{let year=2005
     firstSecond=maketime(0,0,0,1,1,$year)
     lastSecond=maketime(23,59,59,13,0,$year)
     children=fetch( content,
     list,
     hash( parent_node_id, $node.node_id,
        sort_by, $node.sort_array,
        class_filter_type, include,
        class_filter_array, array( 'article' ),
        attribute_filter, array( 'and', array( 'published', between, array( $firstSecond, $lastSecond ) ) )
        )
     )
}

<table class="news_archive" width="100%">
    <tr>
        <th>
            <b>Artikkeltittel</b>
        </th>
        <th>
            <b>Publisert</b>
        </th>
    </tr>

    {* Loop through all articles that we just fetched. *}
    {section name=Child loop=$children}
    <tr>
        <td>
            {* Display a link to the article. *}
            <a href={$:item.url_alias|ezurl}>{$:item.name}</a>
            <br />
        </td>
        <td>
            {* Display the date the article was published. *}
            {$:item.object.published|l10n(shortdate)}
        </td>
    </tr>
    {* End of loop. *}
    {/section}
</table>

I hope this was what you were looking for.

Wednesday 07 December 2005 1:58:33 am

The code above isn't presented correctly.
Looks like equal signs are being removed in the code field...

Could someone from eZ look into this issue?
The code is correct when i edit my posting....

Siniša Šehović

Wednesday 07 December 2005 2:02:19 am

Hi Hans-Henry,

Thanks for that, but question was for filtering fetched objects from selected section.

How to display only published articles from specified section?

Best regards,
S.

---
If at first you don't succeed, look in the trash for the instructions.

Kristof Coomans

Tuesday 13 December 2005 6:03:08 am

You can filter on 'section' with the 'attribute_filter' array in a 'list' or 'tree' fetch.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Siniša Šehović

Wednesday 14 December 2005 12:01:11 am

Hi Kristof

Could you write some example code for that?

S.

---
If at first you don't succeed, look in the trash for the instructions.

Kristof Coomans

Thursday 15 December 2005 3:41:47 am

{let sectionID=1 
    year=2005
    firstSecond=maketime(0,0,0,1,1,$year)
    lastSecond=maketime(23,59,59,13,0,$year)
    children=fetch( content,
    list,
    hash( parent_node_id, $node.node_id,
       sort_by, $node.sort_array,
       class_filter_type, include,
       class_filter_array, array( 'article' ),
       attribute_filter, array( 'and', 
                                      array( 'published', between, array( $firstSecond, $lastSecond ) ),
                                      array( 'section','=',$sectionID )
                                     )
       )
    )
}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

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 19 2025 00:33:36
Script start
Timing: Jan 19 2025 00:33:36
Module start 'layout'
Timing: Jan 19 2025 00:33:36
Module start 'content'
Timing: Jan 19 2025 00:33:37
Module end 'content'
Timing: Jan 19 2025 00:33:37
Script end

Main resources:

Total runtime1.4225 sec
Peak memory usage4,096.0000 KB
Database Queries79

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 589.0469152.6250
Module start 'layout' 0.00760.0032 741.671939.4453
Module start 'content' 0.01071.4102 781.1172700.3203
Module end 'content' 1.42090.0015 1,481.437520.1641
Script end 1.4224  1,501.6016 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2336160.0002
Check MTime0.00140.1005160.0001
Mysql Total
Database connection0.00090.063310.0009
Mysqli_queries1.338594.0975790.0169
Looping result0.00080.0560770.0000
Template Total1.390097.720.6950
Template load0.00220.154220.0011
Template processing1.387897.563620.6939
Template load and register function0.00010.006910.0001
states
state_id_array0.00220.158210.0022
state_identifier_array0.00120.087220.0006
Override
Cache load0.00200.1401520.0000
Sytem overhead
Fetch class attribute can translate value0.00090.061240.0002
Fetch class attribute name0.00150.1029130.0001
XML
Image XML parsing0.00300.208240.0007
class_abstraction
Instantiating content class attribute0.00000.0027180.0000
General
dbfile0.00130.0928330.0000
String conversion0.00000.000540.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
9content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 42
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs