Forums / Setup & design / ONE Fetch for Multiple Folder

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

eZ debug

Timing: Jan 18 2025 16:20:42
Script start
Timing: Jan 18 2025 16:20:42
Module start 'content'
Timing: Jan 18 2025 16:20:42
Module end 'content'
Timing: Jan 18 2025 16:20:43
Script end

Main resources:

Total runtime0.9371 sec
Peak memory usage4,096.0000 KB
Database Queries220

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 588.8438180.8359
Module start 'content' 0.00550.8079 769.6797719.7266
Module end 'content' 0.81350.1236 1,489.4063348.4688
Script end 0.9370  1,837.8750 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4212210.0002
Check MTime0.00160.1686210.0001
Mysql Total
Database connection0.00080.088610.0008
Mysqli_queries0.827288.27372200.0038
Looping result0.00270.28462180.0000
Template Total0.909297.020.4546
Template load0.00210.220920.0010
Template processing0.907196.801920.4536
Template load and register function0.00020.024310.0002
states
state_id_array0.00090.092110.0009
state_identifier_array0.00090.094820.0004
Override
Cache load0.00210.22521740.0000
Sytem overhead
Fetch class attribute can translate value0.00150.163540.0004
Fetch class attribute name0.00220.2321120.0002
XML
Image XML parsing0.00100.103340.0002
class_abstraction
Instantiating content class attribute0.00000.0036150.0000
General
dbfile0.00170.1833280.0001
String conversion0.00000.000630.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 90
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs