# Enhanced Snippets with more positional arguments

**URL:** <https://forum.getkirby.com/t/enhanced-snippets-with-more-positional-arguments/30756>\
**Category:** Questions\
**Tags:** v4\
**Created:** [February 10, 2024, 5:42pm UTC](https://forum.getkirby.com/t/enhanced-snippets-with-more-positional-arguments/30756 "2024-02-10T17:42:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mxst](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mxst/32/12448_2.png) [@mxst](https://forum.getkirby.com/u/mxst)\
**Post date:** [February 10, 2024, 5:42pm UTC](https://forum.getkirby.com/t/enhanced-snippets-with-more-positional-arguments/30756/1 "2024-02-10T17:42:50Z")

</div>

I remember it being possible in Kirby 2, but would it be possible in Kirby 4 do make own snippets like:

```auto
<?= heroicon("iconName", "variant", ["class" => "..."]) ?>
<?= fontawesome("iconName", "variant", ["class" => "..."]) ?>

```

~ Max

EDIT:  
I would love to make the following a bit more ergonomic

Snippet: `snippets/fontawesome.php`

```auto
<?php
$path = $kirby->roots()->assets() . "/fontawesome-pro/svgs/";
$icon = $icon ?? "circle-exclamation";
$variant = $variant ?? "regular";

echo
str_replace(
  '<svg',
  sprintf('<svg %s', 'class="' . $class . '"'),
  svg("{$path}/{$variant}/{$icon}.svg")
);

```

Usage:

```auto
<?= snippet("fontawesome", ["icon" => "language", "class" => "h-5"]) ?>

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 10, 2024, 5:57pm UTC](https://forum.getkirby.com/t/enhanced-snippets-with-more-positional-arguments/30756/2 "2024-02-10T17:57:41Z")

</div>

Hm, I don’t really understand your question. These look like custom functions, that definitely didn’t exist in Kirby 2, either.

---

<div class="post-metadata">

**Author:** ![mxst](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mxst/32/12448_2.png) [@mxst](https://forum.getkirby.com/u/mxst)\
**Post date:** [February 10, 2024, 6:06pm UTC](https://forum.getkirby.com/t/enhanced-snippets-with-more-positional-arguments/30756/3 "2024-02-10T18:06:34Z")

</div>

Maybe I’m completely mistaken …

But would it be possible to write a plugin that behaves like that? And if yes, would you mind guiding me to a starting point? I have no idea which [Plugin Type](https://getkirby.com/docs/guide/plugins/plugin-types) that could be…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 10, 2024, 6:19pm UTC](https://forum.getkirby.com/t/enhanced-snippets-with-more-positional-arguments/30756/4 "2024-02-10T18:19:58Z")

</div>

Simple functions like in your example aren’t Kirby extension types. You can simply add them to your plugin’s `index.php`

```auto
<?php

function xyz($argument) {
  // do stuff
}

```

Or you create a class with several such functions and load this class in your `index.php`.

See [Plugin Basics | Kirby CMS](https://getkirby.com/docs/guide/plugins/plugin-basics)
