Please read and follow the COMMON ISSUES first!
Always add your version information in every new post! Thank you!

Form2Content Forum

Questions and answers for Form2Content, a Joomla CCK.
  1. Ihvar
  2. Form2Content Lite & Pro
  3. Sunday, 01 December 2019
  4.  Subscribe via email
Hi!
How can I group articles by categories for Form2Content search results?

For example - When I search by date I receive chaotic ordering not grouped by categories

http://detilip.tmweb.ru/index.php?option=com_form2contentsearch&task=search.display&pb=1&moduleid=320&searchformid=4&results=52&f2cs_320_13_4=2019-12-01%7C2019-12-31
Responses (1)
Accepted Answer Pending Moderation
I used this code at components/com_form2contentsearch/views/common/default.php before <form action="<?php echo $formAction; ?>" method="post" name="adminForm" id="adminForm"> to group by categories and order by ordering :)



function numberFormat($digit, $width) {
while(strlen($digit) < $width)
$digit = '0' . $digit;
return $digit;
}

foreach ($this->lead_items as &$item) {


$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('rgt')));
$query->from($db->quoteName('%your_db_prefix%_categories'));
$query->where($db->quoteName('id') . ' = ' . $item->catid );
$db->setQuery($query);
$results = $db->loadResult();


$db2 = JFactory::getDbo();
$query2 = $db2->getQuery(true);
$query2->select($db->quoteName(array('ordering')));
$query2->from($db->quoteName('%your_db_prefix%_content'));
$query2->where($db->quoteName('id') . ' = ' . $item->id );
$db2->setQuery($query2);
$results2 = $db2->loadResult();

$item->catidordering = $results.numberFormat($results2, 11);

}


function cmp2($a, $b) {
return strcmp($a->catidordering, $b->catidordering);
}

usort($this->lead_items, "cmp2");

  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.