Forums / Setup & design / Fetch nodes from sections?

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

eZ debug

Timing: Jan 18 2025 21:07:07
Script start
Timing: Jan 18 2025 21:07:07
Module start 'content'
Timing: Jan 18 2025 21:07:08
Module end 'content'
Timing: Jan 18 2025 21:07:08
Script end

Main resources:

Total runtime1.1510 sec
Peak memory usage4,096.0000 KB
Database Queries216

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 587.7109180.8359
Module start 'content' 0.00550.9830 768.5469705.3984
Module end 'content' 0.98850.1624 1,473.9453344.4375
Script end 1.1509  1,818.3828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.3736210.0002
Check MTime0.00170.1468210.0001
Mysql Total
Database connection0.00070.062910.0007
Mysqli_queries1.047390.99432160.0048
Looping result0.00250.21422140.0000
Template Total1.120997.420.5604
Template load0.00230.198320.0011
Template processing1.118697.185120.5593
Template load and register function0.00010.008810.0001
states
state_id_array0.00070.063910.0007
state_identifier_array0.00250.216520.0012
Override
Cache load0.00210.1827520.0000
Sytem overhead
Fetch class attribute can translate value0.00180.160650.0004
Fetch class attribute name0.00200.1740130.0002
XML
Image XML parsing0.00270.233050.0005
class_abstraction
Instantiating content class attribute0.00000.0033180.0000
General
dbfile0.00350.3078440.0001
String conversion0.00000.000430.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 42
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs