Bectin
  1. You are here:  
  2. Home
  3. Random Insights
  4. PHP

JCB - No items appear in admin list view

If you're using Joomla Component Builder and your admin list view isn't showing any items, even though there are items in the database, edit your admin view and make sure in the Admin behaviour column is set to Show in All List Views for at least one field.

Component Creator custom fields

Ok. When creating a custom field:

Here's an example of the text that goes in the "The php for the getOptions method" box.

// gets the name and IDs of the description articles
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.title')));
$query->from($db->quoteName('#__content', 'a'));
$query->where($db->quoteName('a.state') . ' != 2');
$query->where($db->quoteName('a.catid') . ' = 24');
$query->order('a.id ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
\t$options[] = JHtml::_('select.option', '', 'Select an option');
\tforeach($items as $item)
\t{
\t\t$options[] = JHtml::_('select.option', $item->id, $item->title);
\t}
}

return $options;

In the table field, this is the field that your method above links to. #__content

In the Component field, put the name of your component; example com_regsix

In the value_field: put the field name from the table being accessed by the getOptions method that contains the field that you want to display in the listview. IN this case it is "title".

In the key field: put the field in the table being accessed by the getOptions method that contains the value that is being stored (not the table your getOptions method is accessing). In this example, it would be "id" from the #__content which is being stored in another table for sessions.

 

 

 

 

 

 

Warning: count(): Parameter must be an array or an object that implements Countable

If you get this message after switching to php version 7.x, change your code to from count() to count(get_object_vars()).

Getting keys from an object

You can use array_keys to get the keys from an array but how do you get the keys from elements in an object. 

Easiest method is to cast the object to an array and use array_keys.

$Keys = array_keys(array)$ObjectName);

WAMP Joomla Really Slow

At some point, my Joomla system running on my local WAMP became incredibly slow. It was taking 30-60 seconds to load a page that only takes a few seconds to load on my cloud server.

I discovered that when I had enabled xdebug in my php.ini settings, I had turned on the profiler which was generating 80 MB files on each page load. When I disabled the profiler, then the site went back to loading normally.

  1. Sort array of objects based on one of the object parameter values
  2. SimpleXMLElements
  3. Batch rename of files
  4. Creating left hand menu in admin component

Page 1 of 7

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

Main Menu

  • Home
  • Services
  • Portfolio
  • About
    • Bectin's Founder
  • Contact
  • Random Insights
    • Joomla
    • Joomla Extensions
    • Web Sites
    • Windows Computers
    • Zen Cart
    • Magento
    • MySQL
    • Business
    • Technology
    • Google Analytics & Webmaster Tools
    • PayPal
    • PHP