ONE Fetch for Multiple Folder

Author Message

Leandro Alves

Thursday 17 June 2004 12:53:35 pm

Hi!

I am trying to use one fetch for multiple folder, but I can not!!

I have this:

Root Folder (node_id = 2)
|_Sales
...|_News (node_id = 10)
......|article 1
......|article 2
|_Account
...|_News (node_id = 20)
......|article 3
......|text 1

I want to fetch all articles that are only in both folders "News" (Node 10 and 20)..

I don't want the articles that are in both folder "Root", "Sales", "Account" or any other folders..

How Can I do this?!!!

I tried:

{let sub_menu=fetch( content, tree, hash( parent_node_id, 2,
sort_by, array( priority, true() ),
class_filter_type, include,
class_filter_array,
array ('10', 'and' '20') ) ) }

{/let}

But it doesn't work... :(

I tried other options found in this links, but nothing worked

http://www.ez.no/ez_publish/documentation/customization/tips_tricks/fetch_function_examples

http://ez.no/ez_publish/documentation/reference/data_fetching/content/list

http://ez.no/ez_publish/documentation/development/libraries/ez_template/operators/data_fetch

What Can I do?

Regards.
Leandro

Paul Borgermans

Thursday 17 June 2004 2:07:09 pm

http://ez.no/ez_publish/documentation/reference/data_fetching/content/search

You can use an array of subtrees.
Study this fetch function thouroghly, you'll be amazed what flexibility it offers

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Leandro Alves

Friday 18 June 2004 4:12:59 am

Thanks a lot for your reply Paul!

I studied the link that you sent and this other too:
http://ez.no/ez_publish/documentation/customization/components/search/search_operator

I made some test and now I have some doubts.
I created this structure:

Root Folder (node_id = 2)
|_Sales
...|_News (node_id = 10)
......|article 1
......|article 2
|_Account
...|_News (node_id = 20)
......|article 3
......|text 1

Then I tried:

{let search=fetch(content,search,hash(text,'article', subtree_array(10, 20)))}

{$search['SearchResult']} {* This Returns the word "Array" in my template *}
{$search['SearchCount']} {* This Returns the number "3" - That's right! *}
{$search['StopWordArray']} {* This Returns the word "Array" too *}

Doubts:

1. The parameter text in search operator is required, so What can I do to fetch ALL articles in both folders??
In this case the fetch didn't catch the article "text 1" in "Account/News"...

2. How can I do to show the results???

Today I use this code to show the results of ONE News folder

{let news_list=fetch( content, tree, hash( parent_node_id, NODE_ID_NEWS_FOLDER,
sort_by, array( published, false() ),
class_filter_type, 'include',
class_filter_array, array( 'article' ) ) )}

<h2>News</h2>
{section var=news max=3 loop=$news_list}
{node_view_gui view=line content_node=$news.item}
{/section}
{/let}

I am not any expert in eZ, I am learn a lot of eZ Publish with the example codes... The link http://ez.no/ez_publish/documentation/reference/data_fetching/content/search there isn't any example.. :(

Could you send me one exemple of how to do this??
Or could you send me other explanation for I try..

Thanks a lot again!
Leandro

Paul Forsyth

Friday 18 June 2004 4:31:58 am

When you see the word Array it actually means the result is an array, so you need to look inside the array to get the results you need, ie:

{section var=SearchResult loop=$search['SearchResult']}
{$SearchResult}
{/section}

paul

--
http://www.visionwt.com

Leandro Alves

Friday 18 June 2004 9:03:01 am

Hi Paul.

I made what you said, but it didn't work yet!!!

I have this code now:

{let search=fetch(content,search,hash(text,'article', subtree_array, array( 10, 20 )))}

{section var=SearchResult loop=$search['SearchResult']}
{$SearchResult}
{/section}

{/let}

And the result is this in my template:

<b>Object(ezcontentobjecttreenode)</b>

What is my mistake??

Still doubt:

1. The parameter text in search operator is required, so What can I do to fetch ALL articles in both folders??
In this case the fetch didn't catch the article "text 1" in "Account/News"...

Thanks!
Leandro

Paul Borgermans

Friday 18 June 2004 9:16:16 am

You can allow empty searches by a setting called AllowEmptySearch in sit.ini.append under [SearchSettings]

Now you should learn to use {$variable|attribute(show)} to discover what to do in the loop.

Regards

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Leandro Alves

Friday 18 June 2004 10:47:06 am

I'm sorry to be a newbie in eZ... But I didn't understand how to use {$variable|attribute(show)}.

I tried:

{let search=fetch(content,search,hash(text,'article', subtree_array, array( 10, 20 )))}

{section var=SearchResult loop=$search['SearchResult']}
{$SearchResult|attribute(show)}
{/section}

{/let}

And the result in my template was:

<b>Attribute Type Value </b>
<b>Object NULL</b>
<b>0 NULL</b>
<b>1 NULL</b>
<b> NULL </b>

<b>And many error in eZ Debug page...</b>

I searched out in eZ Site about your reply, but I found nothing for my case...

How can I use {$variable|attribute(show)} in this case?!

About the empty searches I understood...

Thanks again!
Leandro

Paul Borgermans

Friday 18 June 2004 2:33:25 pm

Hi Leandro

look here for the docs

http://ez.no/ez_publish/documentation/customization/tips_tricks/debugging_templates

And try

   {section var=SearchResult loop=$search['SearchResult']}
   {$SearchResult.item|attribute(show)}
   {/section}

Depending on the number of items you will get a list which shows which variables you can/want to use.

In fact you will get an array of objects of which the member variables (attributes) will provide what you are looking for

hth

-paul

PS: there is also a book to get you started ;-)

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Leandro Alves

Monday 21 June 2004 4:37:15 am

Hi -paul

I tried to use what you sent and now I have the output result like I wanted with this code:

{let search=fetch(content,search,hash(text,'article', subtree_array, array( 10, 20 )))}

{section var=SearchResult loop=$search['SearchResult']}
<a href={$SearchResult.item.url_alias|ezurl}>{$SearchResult.item.name|wash}</a>
{attribute_view_gui attribute=$SearchResult.object.data_map.intro}
{/section}

{/let}

The result is what I want!

But I still have a problem... :(

I changed my site.ini.append allowing empty searches but it didn't work with the fetch operator...

[SearchSettings]
AllowEmptySearch=enabled

After I changed the site.ini.append, I tried all this:

{let search=fetch(content,search,hash(text,' ', subtree_array, array( 10, 20 )))}

{let search=fetch(content,search,hash(text,'*', subtree_array, array( 10, 20 )))}

{let search=fetch(content,search,hash(text," ", subtree_array, array( 10, 20 )))}

{let search=fetch(content,search,hash(text, , subtree_array, array( 10, 20 )))}

{let search=fetch(content,search,hash(subtree_array, array( 10, 20 )))}

And nothing worked.

What can I do now?!! :)

Thanks!
Leandro

PS: May could you get the answer in your eZ Book to me! ;-)

Paul Borgermans

Monday 21 June 2004 6:31:44 am

Try

   {let search=fetch(content,search,hash(text,'', subtree_array, array( 10, 20 )))}

Did you clear the (ini) cache?

hth
-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Leandro Alves

Monday 21 June 2004 7:22:18 am

I tried your reply and nothing happened...

See the results in eZ Debug page:

<b>Error: eZMySQLDB</b>
Query error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by object_count' at line 1. Query: SELECT id, word, object_count FROM ezsearch_word where order by object_count

<b>Notice: eZMySQLDB::query(0.000 ms) query number per page:0</b>
SELECT id, word, object_count FROM ezsearch_word where order by object_count

I cleared all the cache before to try...

Thanks a lot again!
Leandro

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 19:37:22
Script start
Timing: Jan 18 2025 19:37:22
Module start 'layout'
Timing: Jan 18 2025 19:37:22
Module start 'content'
Timing: Jan 18 2025 19:37:23
Module end 'content'
Timing: Jan 18 2025 19:37:23
Script end

Main resources:

Total runtime0.8870 sec
Peak memory usage4,096.0000 KB
Database Queries83

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 589.3438152.6250
Module start 'layout' 0.00520.0035 741.968839.4453
Module start 'content' 0.00870.8769 781.4141714.6484
Module end 'content' 0.88550.0015 1,496.062528.1641
Script end 0.8870  1,524.2266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.3397160.0002
Check MTime0.00120.1363160.0001
Mysql Total
Database connection0.00080.090210.0008
Mysqli_queries0.777087.5987830.0094
Looping result0.00070.0812810.0000
Template Total0.856596.620.4282
Template load0.00210.231620.0010
Template processing0.854496.320620.4272
Template load and register function0.00010.015810.0001
states
state_id_array0.00090.105510.0009
state_identifier_array0.00080.088520.0004
Override
Cache load0.00210.23471740.0000
Sytem overhead
Fetch class attribute can translate value0.00060.068730.0002
Fetch class attribute name0.00100.1157120.0001
XML
Image XML parsing0.00090.098230.0003
class_abstraction
Instantiating content class attribute0.00000.0037150.0000
General
dbfile0.00100.1121170.0001
String conversion0.00000.001240.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
11content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
42content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
27content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/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: 90
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs