Forums / Setup & design / Access selection datatype

Access selection datatype

Author Message

Robert Malevic

Saturday 07 June 2008 7:06:58 am

Hi,
Again a newbie question. I defined a FAQ class with a single choice selection datatype (category) which represent available categories:

selection category 1
selection category 2
...
selection category n

To display the FAQ's in different categories I tried the following code:

{for 0 to $option_count as $category_number}

<h4>DISPLAY THE CATEGORY STORED IN THE SELECTION ATTRIBUTE</h4>
    
{def $faqs=fetch( 'content', 'list', hash( 'parent_node_id', 399,
               'sort_by', array( 'attribute', true(), 'faq/question'),
               'class_filter_type', 'include',
               'class_filter_array', array( 'faq' ),
               'attribute_filter', array( array( 'faq/category',
               '=',
               $category_number ) ) ) )}
  
<ul class="faq-list">
    {foreach $faqs as $faq}  
    <li> <span class="fold-out">{$faq.data_map.question.content}</span>
        <div class="summary hide">
            {attribute_view_gui attribute=$faq.object.data_map.answer}
        </div>
    </li>
    {/foreach}
</ul>
{/for}

I have two questions:
1. How to determine the number of options available in the selection attribute ($option_count)?

2. How to extract the content of each available options to display in "<h4>DISPLAY THE CONTENT STORED IN THE SELECTION ATTRIBUTE</h4>"?

Thanks for your help!

Maxime Thomas

Sunday 10 August 2008 10:49:57 pm

Hi,

I'm not sure to understand what you want to do. I give a try so :
You would like to have a FAQ content. For this FAQ you would like to have a category filter ?

If it's that, you can easily reach some information :
- in each content template, the $node value is provided. you can use the following code to show what is inside this variable :

{$node|attribute(show,1)}

- in the $node, you've got the data_map array which is an array of your attributes. You can access the category attribute like this :

{$node.data_map.category}

- on each attribute, you can use the content function to get back the value of the content. For the selection datatype, the content function returns an int of the selected category. The list of category are stocked in the content of the content class attribute.

- finally, if you want to display all the faq filtered by a category, in your template a code like this :

<form action="{$node.url_alias|ezurl('no')}" action="post">
<select name="category">
{foreach $options as $o}
<option value="{$o.value}">{$o.name|wash}</option>
{/foreach}
</select>
</form>

- and to find your selected category :

{def $selected_category=ezhttp('category', 'post')}
{$selected_category}

Hope it helps...

Max

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

eZ debug

Timing: Jan 18 2025 10:21:55
Script start
Timing: Jan 18 2025 10:21:55
Module start 'content'
Timing: Jan 18 2025 10:21:55
Module end 'content'
Timing: Jan 18 2025 10:21:55
Script end

Main resources:

Total runtime0.3029 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0078 587.7109180.8359
Module start 'content' 0.00780.0137 768.546993.9922
Module end 'content' 0.02160.2813 862.5391524.2734
Script end 0.3028  1,386.8125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00341.1072200.0002
Check MTime0.00140.4501200.0001
Mysql Total
Database connection0.00100.340710.0010
Mysqli_queries0.240479.36951410.0017
Looping result0.00150.48981390.0000
Template Total0.280792.710.2807
Template load0.00090.289610.0009
Template processing0.279892.368810.2798
Override
Cache load0.00060.205010.0006
Sytem overhead
Fetch class attribute can translate value0.00090.308710.0009
XML
Image XML parsing0.00030.087410.0003
General
dbfile0.01394.5903200.0007
String conversion0.00000.002330.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs