Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui-icon #38

Open
zaszlo opened this issue Nov 24, 2020 · 0 comments
Open

ui-icon #38

zaszlo opened this issue Nov 24, 2020 · 0 comments

Comments

@zaszlo
Copy link

zaszlo commented Nov 24, 2020

Hello,

I would like to create/use a shortcode to place folder icons with a title and href ((like google photos/flickr public album)), basically a ui-polaroid with more features.

Shortcode syntax:

[ui-icon img="folder.png" href="https://www.getgrav.org" description="gombanap" angle="-3" margin="30px 50px 20px 0" position="left"]
Mushroom day
[/ui-icon]

I tried to implement it within this plugin, by:

  • adding user\plugins\shortcode-ui\shortcodes\IconShortcode.php
<?php

namespace Grav\Plugin\Shortcodes;

use Thunder\Shortcode\Shortcode\ShortcodeInterface;


class IconShortcode extends Shortcode

{
    public function init()
    {
        $this->shortcode->getHandlers()->add('ui-icon', function(ShortcodeInterface $sc) {

            // Add assets
            $this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-polaroid.css');

            $output = $this->twig->processTemplate('partials/ui-icon.html.twig', [
                'shortcode' => $sc,
            ]);

            return $output;
        });
    }
}
  • adding user\plugins\shortcode-ui\templates\partials\ui-icon.html.twig
{% set gloss = shortcode.getParameter('gloss', true) %}
{% set img = shortcode.getParameter('img', true) %}
{% set fa-icon = shortcode.getParameter('fa-icon', true) %}
<div class="polaroid-wrapper {{ shortcode.getParameter('position', 'right') }}" style="margin:{{ shortcode.getParameter('margin', '30px') }};">
	<a href="{{ shortcode.getParameter('href') }}" target="_blank">
    <div class="polaroid" style="transform: rotate({{ shortcode.getParameter('angle', 3) }}deg);">
        <div class="polaroid-img">
            {% if gloss is sameas(true) %}
				<div class="gloss"></div>
			{% endif %}
			{% if img is sameas(true) %}
				<img src="{{ shortcode.getParameter('img') }}">
			{{ shortcode.getContent()|raw }}
			{% else %}
				{% if fa-icon is sameas(true) %}
				<i class="{{ shortcode.getParameter('fa-icon') }}"></i>
				{% endif %}
			{% endif %}
        </div>
        <p title="{{ shortcode.getParameter('description') }}">{{ shortcode.getContent()|raw }}</p>
    </div>
	</a>
</div>

The plugin is enabled, a ui-browser shortcode is rendered fine, but my added shortcode is not rendering at all.

Any hints, please?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant