Skip to main content
deleted 1 character in body
Source Link
Sharky
  • 12k
  • 8
  • 23
namespace Sfi\Component\Aaprueba\Site\Field;

defined('_JEXEC') or die();

use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Form\FormField;

class filtercatid extends FormField 
{
    protected $type = 'filtercatid';
    
    public function getCatid($value) 
    {
        ?>
            <select 
                id="filter_catid" 
                name="filter_catid"
                class="form-control js-example-basic-single"
                onchange="this.form.submit();"
                >
                <option value="uno">Uno</option>
                <option value="dos">Dos</option>
            </select>        
        < ?php
    }
}
namespace Sfi\Component\Aaprueba\Site\Field;

defined('_JEXEC') or die();

use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Form\FormField;

class filtercatid extends FormField 
{
    protected $type = 'filtercatid';
    
    public function getCatid($value) 
    {
        ?>
            <select 
                id="filter_catid" 
                name="filter_catid"
                class="form-control js-example-basic-single"
                onchange="this.form.submit();"
                >
                <option value="uno">Uno</option>
                <option value="dos">Dos</option>
            </select>        
        < ?php
    }
}
namespace Sfi\Component\Aaprueba\Site\Field;

defined('_JEXEC') or die();

use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Form\FormField;

class filtercatid extends FormField 
{
    protected $type = 'filtercatid';
    
    public function getCatid($value) 
    {
        ?>
            <select 
                id="filter_catid" 
                name="filter_catid"
                class="form-control js-example-basic-single"
                onchange="this.form.submit();"
                >
                <option value="uno">Uno</option>
                <option value="dos">Dos</option>
            </select>        
        <?php
    }
}
added 344 characters in body
Source Link
Sharky
  • 12k
  • 8
  • 23

namespace Sfi\Component\Aaprueba\Site\Field;

defined('_JEXEC') or die();

use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Form\FormField;

class filtercatid extends FormField { protected $type = 'filtercatid';

namespace Sfi\Component\Aaprueba\Site\Field;

defined('_JEXEC') or die();

use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Form\FormField;

class filtercatid extends FormField 
{
    protected $type = 'filtercatid';
    
    public function getCatid($value) 
    {
        ?>
            <select 
                id="filter_catid" 
                name="filter_catid"
                class="form-control js-example-basic-single"
                onchange="this.form.submit();"
                >
                <option value="uno">Uno</option>
                <option value="dos">Dos</option>
            </select>        
        < ?php
    }
}

}

protected function populateState($ordering = null, $direction = null)
{ $catid = $this->getUserStateFromRequest($this->context.'.filter.catid', 'filter_catid'); $this->setState('filter.catid', $catid);

protected function populateState($ordering = null, $direction = null)   
{
    $catid = $this->getUserStateFromRequest($this->context.'.filter.catid', 'filter_catid');
    $this->setState('filter.catid', $catid); 
        
    parent::populateState('a.espacio', 'ASC');
}

protected function getListQuery()
{
...

}

protected function getListQuery() { ...

namespace Sfi\Component\Aaprueba\Site\View\Espacios;

\defined('_JEXEC') or die;

use Joomla\CMS\Factory; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\MVC\View\GenericDataException;

class HtmlView extends BaseHtmlView { protected $state; protected $items; protected $pagination;

namespace Sfi\Component\Aaprueba\Site\View\Espacios;

\defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\MVC\View\GenericDataException;

class HtmlView extends BaseHtmlView
{
    protected $state;
    protected $items;
    protected $pagination;

    public function display($tpl = null)
    {
        $this->state        = $this->get('State');
        $this->items        = $this->get('Items');
        $this->pagination   = $this->get('Pagination');

        if (\count($errors = $this->get('Errors')))
        {
            throw new GenericDataException(implode("\n", $errors), 500);
        }

        return parent::display($tpl);
    }
}

}

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Form\FormHelper;
?>
...
<form action="<?= Uri::current() ?>" method="post" name="adminForm" id="adminForm">
    < ?php 
        $selectCatid = FormHelper::loadFieldType('filtercatid', false);
        $selectCatid->getcatid($this->escape($this->state->get('filter.catid')));
    ?> 
...
</form>

use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Router\Route; use Joomla\CMS\Uri\Uri; use Joomla\CMS\Layout\FileLayout; use Joomla\CMS\Form\FormHelper; Please, is there some information about how create custom filters in Joomla 4 without using a xml form?> ...Thanks, JL

" method="post" name="adminForm" id="adminForm">getcatid($this->escape($this->state->get('filter.catid')));?>...***Please, is there some information about how create custom filters in Joomla 4 without using a xml form?Thanks, JL

namespace Sfi\Component\Aaprueba\Site\Field;

defined('_JEXEC') or die();

use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Form\FormField;

class filtercatid extends FormField { protected $type = 'filtercatid';

public function getCatid($value) 
{
    ?>
        <select 
            id="filter_catid" 
            name="filter_catid"
            class="form-control js-example-basic-single"
            onchange="this.form.submit();"
            >
            <option value="uno">Uno</option>
            <option value="dos">Dos</option>
        </select>        
    < ?php
}

}

protected function populateState($ordering = null, $direction = null)
{ $catid = $this->getUserStateFromRequest($this->context.'.filter.catid', 'filter_catid'); $this->setState('filter.catid', $catid);

parent::populateState('a.espacio', 'ASC');

}

protected function getListQuery() { ...

namespace Sfi\Component\Aaprueba\Site\View\Espacios;

\defined('_JEXEC') or die;

use Joomla\CMS\Factory; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\MVC\View\GenericDataException;

class HtmlView extends BaseHtmlView { protected $state; protected $items; protected $pagination;

public function display($tpl = null)
{
    $this->state        = $this->get('State');
    $this->items        = $this->get('Items');
    $this->pagination   = $this->get('Pagination');

    if (\count($errors = $this->get('Errors')))
    {
        throw new GenericDataException(implode("\n", $errors), 500);
    }

    return parent::display($tpl);
}

}

use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Router\Route; use Joomla\CMS\Uri\Uri; use Joomla\CMS\Layout\FileLayout; use Joomla\CMS\Form\FormHelper; ?> ...

" method="post" name="adminForm" id="adminForm">getcatid($this->escape($this->state->get('filter.catid')));?>...***Please, is there some information about how create custom filters in Joomla 4 without using a xml form?Thanks, JL
namespace Sfi\Component\Aaprueba\Site\Field;

defined('_JEXEC') or die();

use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Form\FormField;

class filtercatid extends FormField 
{
    protected $type = 'filtercatid';
    
    public function getCatid($value) 
    {
        ?>
            <select 
                id="filter_catid" 
                name="filter_catid"
                class="form-control js-example-basic-single"
                onchange="this.form.submit();"
                >
                <option value="uno">Uno</option>
                <option value="dos">Dos</option>
            </select>        
        < ?php
    }
}
protected function populateState($ordering = null, $direction = null)   
{
    $catid = $this->getUserStateFromRequest($this->context.'.filter.catid', 'filter_catid');
    $this->setState('filter.catid', $catid); 
        
    parent::populateState('a.espacio', 'ASC');
}

protected function getListQuery()
{
...
namespace Sfi\Component\Aaprueba\Site\View\Espacios;

\defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\MVC\View\GenericDataException;

class HtmlView extends BaseHtmlView
{
    protected $state;
    protected $items;
    protected $pagination;

    public function display($tpl = null)
    {
        $this->state        = $this->get('State');
        $this->items        = $this->get('Items');
        $this->pagination   = $this->get('Pagination');

        if (\count($errors = $this->get('Errors')))
        {
            throw new GenericDataException(implode("\n", $errors), 500);
        }

        return parent::display($tpl);
    }
}
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Form\FormHelper;
?>
...
<form action="<?= Uri::current() ?>" method="post" name="adminForm" id="adminForm">
    < ?php 
        $selectCatid = FormHelper::loadFieldType('filtercatid', false);
        $selectCatid->getcatid($this->escape($this->state->get('filter.catid')));
    ?> 
...
</form>

Please, is there some information about how create custom filters in Joomla 4 without using a xml form? Thanks, JL

Source Link
Peli
  • 103
  • 7

Converting J3 custom filter to J4

I have lots of custom filters in my J3 front-end components and I'm trying to convert to J4, but always get

0 Call to a member function getcatid() on bool

com_aaprueba/src/Field/filtercatid.php


namespace Sfi\Component\Aaprueba\Site\Field;

defined('_JEXEC') or die();

use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Form\FormField;

class filtercatid extends FormField { protected $type = 'filtercatid';

public function getCatid($value) 
{
    ?>
        <select 
            id="filter_catid" 
            name="filter_catid"
            class="form-control js-example-basic-single"
            onchange="this.form.submit();"
            >
            <option value="uno">Uno</option>
            <option value="dos">Dos</option>
        </select>        
    < ?php
}

}


src/Model/EspaciosModel.php


protected function populateState($ordering = null, $direction = null)
{ $catid = $this->getUserStateFromRequest($this->context.'.filter.catid', 'filter_catid'); $this->setState('filter.catid', $catid);

parent::populateState('a.espacio', 'ASC');

}

protected function getListQuery() { ...


src/View/Espacios/HtmlView.php


namespace Sfi\Component\Aaprueba\Site\View\Espacios;

\defined('_JEXEC') or die;

use Joomla\CMS\Factory; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\MVC\View\GenericDataException;

class HtmlView extends BaseHtmlView { protected $state; protected $items; protected $pagination;

public function display($tpl = null)
{
    $this->state        = $this->get('State');
    $this->items        = $this->get('Items');
    $this->pagination   = $this->get('Pagination');

    if (\count($errors = $this->get('Errors')))
    {
        throw new GenericDataException(implode("\n", $errors), 500);
    }

    return parent::display($tpl);
}

}


tmpl/espacios/default.php


use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Router\Route; use Joomla\CMS\Uri\Uri; use Joomla\CMS\Layout\FileLayout; use Joomla\CMS\Form\FormHelper; ?> ...

" method="post" name="adminForm" id="adminForm"> getcatid($this->escape($this->state->get('filter.catid'))); ?> ... *** Please, is there some information about how create custom filters in Joomla 4 without using a xml form? Thanks, JL