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

More
10 years 8 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...

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

More
10 years 8 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...

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

More
10 years 8 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
10 years 8 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...

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

More
10 years 8 months ago #49969 by tevez15
In the subcategory I don't have any custom code, just the previous now, but it works very well right now :D

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.306 seconds
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