PHP code example of magehx / htmx-actions

1. Go to this page and download the library: Download magehx/htmx-actions library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

magehx / htmx-actions example snippets


use MageHx\HtmxActions\Controller\HtmxAction;

class Example extends HtmxAction
{
    public function execute(): \Magento\Framework\Controller\ResultInterface
    {
        return $this->getBlockResponse('your.block.name', ['your_layout_handle']);
    }
}


/** @var MageHx\HtmxActions\ViewModel\HxAttributesRenderer $hxAttrRenderer */


/** @var MageHx\HtmxActions\ViewModel\HxAttributesRenderer $hxAttrRenderer */

// to verify the request is an HTMX request.
$manager->isHtmxRequest(); 
// Here you can set a header value to the response.
$manager->setHeader($response, \MageHx\HtmxActions\Enums\HtmxResponseHeader::RESWAP, \MageHx\HtmxActions\Enums\HtmxSwapOption::NONE->value);