Welcome Guest, Not a member yet? Register   Sign In
View Component
#7

I think this would be really helpful to you: Components library for CI4. It allows to encapsulate html and css classes/styles into reusable website building blocks.
See it here: https://packagist.org/packages/dgvirtual...components
It allows to write this in your view:
PHP Code:
<x-green-button onclick="alert('I was clicked!')">
  <?= $clickMeLabel ?>
</x-green-button> 
and after rendering get this sent to your browser:
PHP Code:
<button
    style
="color: white; background-color: green;"
    <?= isset($onclick) ? 'onclick="' $onclick '"' '' ?>
>
    <?= $slot ?>
</button> 
This functionality has been available in Bonfire2 for a while, but I have extracted it and put it into an installable composer package.

Bonfire2 was written mainly by Lonnie Ezell (@kilishan), so most of the credit goes to him.

Hope you will find it as useful as I have.
==

Donatas G.
Reply


Messages In This Thread
View Component - by SubrataJ - 10-22-2022, 04:51 AM
RE: View Component - by captain-sensible - 10-22-2022, 09:32 AM
RE: View Component - by kenjis - 10-22-2022, 06:56 PM
RE: View Component - by SubrataJ - 10-22-2022, 08:23 PM
RE: View Component - by kilishan - 10-24-2022, 06:52 AM
RE: View Component - by SubrataJ - 10-25-2022, 06:26 AM
RE: View Component - by dgvirtual - 01-06-2025, 11:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB