[Solved] Total of files in Item (subcategory view)

More
11 years 5 months ago - 11 years 4 months ago #49844 by tevez15
Hi,

I have one question, is possible know how many Files (field file) one article have in subcategory view? :P
Last edit: 11 years 4 months ago by tevez15.

Please Log in or Create an account to join the conversation.

More
11 years 5 months ago #49847 by micker
without code .. not

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
11 years 5 months ago #49854 by ggppdk
Hello

inside your template:

If you have the field in a template position
Code:
<?php echo count($item->fields['fieldname']->filedata); ?>

or if you don't have the field in a template position:
Code:
<?php echo count($item->fields['fieldname']->values); ?>


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
11 years 4 months ago #49884 by tevez15
hello :)

The file what I talking about is category_subcategories_html5.php.. :|

Please Log in or Create an account to join the conversation.

More
11 years 4 months ago #49885 by ggppdk
Hello

just do a loop in the items and calculate a total
Code:
$total_files = 0; foreach($this->items as $item) { $total_files += count($item->fields['fieldname']->values); } echo "Total files: ". $total_files. "<br/>";


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
11 years 4 months ago #49932 by tevez15
I used the code and nothing happens.

Im using version 2.2.0 r1995 of Flexicontent.

Please Log in or Create an account to join the conversation.

More
11 years 4 months ago #49935 by ggppdk
Hello

turn ON error_reporting in Joomla Globla config,
some variable is not correct

e.g.

probably it is because
$item->fields->values

should be:
$item->fields->value


anyway this exists for sure, NOT that you need FIELD ID
$field_id = 44;
$item->fieldvalues[$field_id]


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
11 years 4 months ago #49936 by ggppdk
Hello

the above is for current page

for all items of current category:
www.flexicontent.org/documentati ... egory.html


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
11 years 4 months ago #49940 by tevez15
I do this
Code:
$total_files = 0; foreach($this->items as $item) { print_r($item); //$total_files += count($item->fields['fieldname']->values); }

And don't show nothing in category_subcategories_html5.php.

Anyway, I do what you have in the link above, and show something, but I thing $cat_info->total show the wrong values of files on field



PS: There is my change for the code:
Code:
$_cid = $sub->id; $field_id = 24; if ($_cid) { $db = JFactory::getDBO(); $query = 'SELECT SUM(value) as sum, COUNT(*) as total' .' FROM #__flexicontent_fields_item_relations as val' .' JOIN #__flexicontent_cats_item_relations as rel ON rel.itemid=val.item_id' .' WHERE field_id='.$field_id.' AND rel.catid='.$_cid.' GROUP BY rel.catid' ; $db->setQuery($query); $cat_info = $db->loadObject(); //print_r($cat_info); /*echo JText::_('MY_SUM_OF_FIELD_NN').': '; echo $cat_info->sum;*/ echo JText::_('MY_OUT_OF_TOTAL_ITEMS_IN_CAT').': '; echo $cat_info->total; }


PS2: This is right I thing, the problem is the multi language. He count all items, in PT and EN.



PS3: I solved the problem:
Code:
$_cid = $sub->id; $field_id = 24; if ($_cid) { $db = JFactory::getDBO(); $query = 'SELECT SUM(value) as sum, COUNT(*) as total' .' FROM #__flexicontent_fields_item_relations as val' //define val como tabela .' JOIN #__flexicontent_cats_item_relations as rel' //define rel como tabela .' ON rel.itemid=val.item_id' // o item id tem de ser igual em val e rel .' JOIN #__flexicontent_items_tmp as myitem' //define myitem como tabela .' ON myitem.id=val.item_id' // o item id tem de ser igual em val e rel .' WHERE field_id='.$field_id.' AND rel.catid='.$_cid.' AND myitem.language=\'pt-PT\' GROUP BY rel.catid, myitem.language' ; $db->setQuery($query); $cat_info = $db->loadObject(); //print_r($cat_info); echo "id cat: " . $sub->id; echo "<br />"; echo JText::_('MY_SUM_OF_FIELD_NN').': '; echo $cat_info->sum; echo "<br />"; echo JText::_('MY_OUT_OF_TOTAL_ITEMS_IN_CAT').': '; echo $cat_info->total; }



PS4: Final version
Code:
$_cid = $sub->id; $field_id = 24; $lang = JFactory::getLanguage(); if ($_cid) { $db = JFactory::getDBO(); $query = 'SELECT SUM(value) as sum, COUNT(*) as total' .' FROM #__flexicontent_fields_item_relations as val' //define val como tabela .' JOIN #__flexicontent_cats_item_relations as rel' //define rel como tabela .' ON rel.itemid=val.item_id' // o item id tem de ser igual em val e rel .' JOIN #__flexicontent_items_tmp as myitem' //define myitem como tabela .' ON myitem.id=val.item_id' // o item id tem de ser igual em val e rel .' WHERE field_id='.$field_id.' AND rel.catid='.$_cid.' AND myitem.language=\'' . $lang->getTag() . '\' GROUP BY rel.catid, myitem.language' //E verifica quais os artigos do idioma actual ; $db->setQuery($query); $cat_info = $db->loadObject(); }

Please Log in or Create an account to join the conversation.

More
11 years 4 months ago #49947 by ggppdk
Hello

$this->items

can not be empty, it has the items listed by categoy view, maybe you have destroyed / overwritten with some custom code

if the above has no items then you will get no items listed


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save