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.