{"id":16124379,"url":"https://github.com/jongacnik/kirby-props","last_synced_at":"2025-07-08T23:03:49.250Z","repository":{"id":56998658,"uuid":"278002915","full_name":"jongacnik/kirby-props","owner":"jongacnik","description":"Helper to convert an array to a Kirby content object","archived":false,"fork":false,"pushed_at":"2020-07-08T06:12:13.000Z","size":4,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T15:38:21.617Z","etag":null,"topics":["kirby","kirby-plugin","kirby3-plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jongacnik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-08T05:58:36.000Z","updated_at":"2023-01-17T00:56:09.000Z","dependencies_parsed_at":"2022-08-21T11:10:22.348Z","dependency_job_id":null,"html_url":"https://github.com/jongacnik/kirby-props","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jongacnik/kirby-props","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongacnik%2Fkirby-props","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongacnik%2Fkirby-props/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongacnik%2Fkirby-props/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongacnik%2Fkirby-props/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jongacnik","download_url":"https://codeload.github.com/jongacnik/kirby-props/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongacnik%2Fkirby-props/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264363744,"owners_count":23596501,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kirby","kirby-plugin","kirby3-plugin"],"created_at":"2024-10-09T21:21:05.577Z","updated_at":"2025-07-08T23:03:49.226Z","avatar_url":"https://github.com/jongacnik.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kirby Props → `kprops`\n\nHelper to convert arrays to [`Kirby\\Cms\\Content`](https://getkirby.com/docs/reference/@/classes/cms/content) objects, particularly useful for snippets:\n\n**Pass props**\n\n```php\nsnippet('some-snippet', kprops([\n  'text' =\u003e 'Here *is* some **text**',\n  'image' =\u003e 'filename.jpg',\n  'page' =\u003e 'some/page'\n]));\n```\n\n**Access in `some-snippet`**\n\n```php\n\u003c?= $props-\u003etext()-\u003ekirbytext() ?\u003e\n\u003c?= $props-\u003eimage()-\u003etoFile()-\u003eurl() ?\u003e\n\u003c?= $props-\u003epage()-\u003etoPage()-\u003eurl() ?\u003e\n```\n\n## Usage\n\n### `kprops($data, $parent, $raw)`\n\n- `Array $data` **\\*required** → array to convert to [`Kirby\\Cms\\Content`](https://getkirby.com/docs/reference/@/classes/cms/content)\n- `Page $parent` → parent `Page` object for the content object. Defaults to current page.\n- `Boolean $raw` → if `true` returns content object directly. Default `false`.\n\n## Details\n\nUse the `$parent` argument when passing values (such as a filename), that belong to a specific page.\n\n```php\n$data = [ 'image' =\u003e 'filename.jpg' ]; // \u003c- let’s say this file belongs to `some/page`\n$page = page('some/page');\n\nsnippet('some-snippet', kprops($data, $page));\n```\n\n---\n\n`kprops` returns an array which looks like:\n\n```php\n$output = kprops([]); // =\u003e [ 'props' =\u003e Kirby\\Cms\\Content ]\n```\n\nThis is ideal for snippets which expect arrays. That said, the `$raw` argument can be passed to directly return the `Content`:\n\n```php\n$output = kprops([], page(), true); // =\u003e Kirby\\Cms\\Content\n```\n\nThis is useful when using `kprops` outside of the context of snippets, or, if passing additional values into a snippet:\n\n```php\nsnippet('some-snippet', [\n  'key' =\u003e 'value',\n  'props' =\u003e kprops([], page(), true)\n]);\n```\n\n## Configuration\n\nYou can set the `key` content is assigned to:\n\n**config.php**\n\n```php\n[\n  'jg.kprops.key' =\u003e 'props' // default\n]\n```\n\n## Installation\n\n```\ncomposer require jg/kirby-props\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eOther installation methods\u003c/summary\u003e\n\n### Download\n\nDownload and copy this repository to `/site/plugins/kirby-props`.\n\n### Git submodule\n\n```\ngit submodule add https://github.com/jongacnik/kirby-props.git site/plugins/kirby-props\n```\n\u003c/details\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongacnik%2Fkirby-props","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjongacnik%2Fkirby-props","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongacnik%2Fkirby-props/lists"}