getgrav / grav-plugin-shortcode-core Goto Github PK
View Code? Open in Web Editor NEWGrav Shortcode Core Plugin
Home Page: https://getgrav.org
License: MIT License
Grav Shortcode Core Plugin
Home Page: https://getgrav.org
License: MIT License
color syntax stopped working after last update and it seems not documented.
There is a shotcore-code.php but it does not seems to play its role anymore.
[color=#b52b27]《革命》って、必然的?[/color]
do not work anymore.
What should I do?
Thanks in advance
I will copy it here:
It seems like it is gravstrap plugin, but I could be wrong. I don't remember changing anything that caused this break, but is it possible that I deleted a line or something and accidentally broke something. Anyway, the error message is:
Whoops\Exception\ErrorException thrown with message "Argument 1 passed to Grav\Plugin\ShortcodeManager::getId() must implement interface Thunder\Shortcode\Shortcode\ShortcodeInterface, null given, called in
C:\wamp\www\grav\user\plugins\gravstrap\classes\Base\GravstrapShortcode.php on line 204 and defined"
Stacktrace:
#27 Whoops\Exception\ErrorException in C:\wamp\www\grav\user\plugins\shortcode-core\classes\ShortcodeManager.php:264
#26 Whoops\Run:handleError in C:\wamp\www\grav\user\plugins\shortcode-core\classes\ShortcodeManager.php:264
#25 Grav\Plugin\ShortcodeManager:getId in C:\wamp\www\grav\user\plugins\gravstrap\classes\Base\GravstrapShortcode.php:204
#24 Grav\Plugin\Shortcodes\GravstrapShortcode:registerOutput in C:\wamp\www\grav\user\plugins\gravstrap\shortcodes\Basic\GravstrapSectionShortcode.php:67
#23 Grav\Plugin\Shortcodes\GravstrapSectionShortcode:renderOutput in C:\wamp\www\grav\user\plugins\gravstrap\classes\Base\GravstrapShortcode.php:65
#22 Grav\Plugin\Shortcodes\GravstrapShortcode:Grav\Plugin\Shortcodes\{closure} in C:\wamp\www\grav\user\plugins\shortcode-core\vendor\thunderer\shortcode\src\Processor\Processor.php:134
#21 call_user_func_array in C:\wamp\www\grav\user\plugins\shortcode-core\vendor\thunderer\shortcode\src\Processor\Processor.php:134
#20 Thunder\Shortcode\Processor\Processor:processHandler in C:\wamp\www\grav\user\plugins\shortcode-core\vendor\thunderer\shortcode\src\Processor\Processor.php:93
#19 Thunder\Shortcode\Processor\Processor:processIteration in C:\wamp\www\grav\user\plugins\shortcode-core\vendor\thunderer\shortcode\src\Processor\Processor.php:53
#18 Thunder\Shortcode\Processor\Processor:process in C:\wamp\www\grav\user\plugins\shortcode-core\classes\ShortcodeManager.php:228
#17 Grav\Plugin\ShortcodeManager:processContent in C:\wamp\www\grav\user\plugins\shortcode-core\shortcode-core.php:90
#16 Grav\Plugin\ShortcodeCorePlugin:onPageContentProcessed in C:\wamp\www\grav\vendor\symfony\event-dispatcher\EventDispatcher.php:181
#15 call_user_func in C:\wamp\www\grav\vendor\symfony\event-dispatcher\EventDispatcher.php:181
#14 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in C:\wamp\www\grav\vendor\symfony\event-dispatcher\EventDispatcher.php:46
#13 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in C:\wamp\www\grav\vendor\rockettheme\toolbox\Event\src\EventDispatcher.php:23
#12 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in C:\wamp\www\grav\system\src\Grav\Common\Grav.php:449
#11 Grav\Common\Grav:fireEvent in C:\wamp\www\grav\system\src\Grav\Common\Page\Page.php:561
#10 Grav\Common\Page\Page:content in C:\wamp\www\grav\user\plugins\gravstrap\gravstrap.php:89
#9 Grav\Plugin\GravstrapPlugin:onTwigSiteVariables in C:\wamp\www\grav\vendor\symfony\event-dispatcher\EventDispatcher.php:181
#8 call_user_func in C:\wamp\www\grav\vendor\symfony\event-dispatcher\EventDispatcher.php:181
#7 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in C:\wamp\www\grav\vendor\symfony\event-dispatcher\EventDispatcher.php:46
#6 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in C:\wamp\www\grav\vendor\rockettheme\toolbox\Event\src\EventDispatcher.php:23
#5 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in C:\wamp\www\grav\system\src\Grav\Common\Grav.php:449
#4 Grav\Common\Grav:fireEvent in C:\wamp\www\grav\system\src\Grav\Common\Twig\Twig.php:310
#3 Grav\Common\Twig\Twig:processSite in C:\wamp\www\grav\system\src\Grav\Common\Grav.php:186
#2 Grav\Common\Grav:Grav\Common\{closure} in C:\wamp\www\grav\vendor\pimple\pimple\src\Pimple\Container.php:113
#1 Pimple\Container:offsetGet in C:\wamp\www\grav\system\src\Grav\Common\Grav.php:288
#0 Grav\Common\Grav:process in C:\wamp\www\grav\index.php:38
All grav pages in this install are giving me this error in web browser
I think it is odd that the admin plugin got the same error (admin should work if all else fails unless the php server itself is down). So that implies that one plugin (not the admin plugin) had the ability to break the functions of other plugins with pages that have nothing to do with that plugin.
https://www.dropbox.com/s/mp29bf042o24ypb/gravstrap%20plugin%20bad.zip?dl=1
Let me know if you need more files. I can zip/upload the entire grav install if needed to help reproduce the problem.
Github has issues with their uploader and zip files.
Took me way to long as there was no error. When clicking on Gantry link I would just get
This site can’t be reached The connection was reset.
All the logs empty. So I decided to start turning off plugin by plugin and shorcode-core was the culprit.
Moment I disabled it Gantry started working ok. Tried restarting apache but it didn't work.
Maybe easy fix or my misunderstanding but i am unable to use multiple columns short codes on one page.
My page looks like this:
columns short code works only for first time then it looks like it is ignored.
Hi, I have a simple question here:
If I have a shortcode I want to render a Twig Template. How would I go about implementing this in Grav?
Example: My shortcode is [news]
when this occurs the template partials/news.twig
(i.e. {% include 'partials/news.twig' %}
) should be inserted into the page. Is this possible or is this too late when the shortcodes are rendered?
Hi,
I created a modular form following this instructions. It works fine, but if I enable the shortcode-core plugin the form stops to work.
installed latest shortcode-core 2.5.1. though you added moz-columns --> no columns in firefox.
cleared all caches, tried diffrent processor settings...no columns
After upgrading the lasted version, I am getting a memory error:
E_ERROR - Allowed memory size of 134217728 bytes exhausted (tried to allocate 1052672 bytes)
Using GRAV v1.5.4
Hi,
this is not an issue but a proposal, as the title suggests. :-)
I deeply deal with shortcodes these days and I made my Gravstrap plugin completely working using shortcodes, instead of using Yaml configuration to configure components.
I've abstracted the shortcode declaration and I'd like to ask you if you might consider to evaluate that work to be added to this plugin. Here's the directory where I implemented the base classes I'd like to add to shortcode-core plugin https://github.com/giansi/gravstrap/tree/shortcodes/classes/Base and here you will find an implementation example: https://github.com/giansi/gravstrap/tree/shortcodes/classes/Accordion.
Here it is how the plugin initializes the shortcodes: https://github.com/giansi/gravstrap/blob/shortcodes/gravstrap.php.
If you think this could be helpful for this plugin, I will port this piece of library to yours.
adding center/left/right shortcodes to a text breaks css styling.
text not rendered as paragraph anymore, only as element. paragraph css style gets lost.
This took forever to figure out, so I'm hoping this issue can be a launching point for writing some documentation on a painful edge case I ran into when trying to build & debug a new shortcode extension. The TLDR is a docs that says something like this "for code running inside shortcode handler functions, to output debug information you should either return the log information as part of the shortcode handler return value, or you should use the grav log. Usage of the grav debugger will work in most situations, but log information will not be displayed inside the admin plugin"
Here's why (The following issue assumes all caching is turned off, so every request should re-trigger processing....)
When using the editor (at /admin/pages/<page route>
) you are by default in the "Editor" mode. When you switch into the "Preview" mode, you can see the end result of your custom shortcode handler logic. However, if you have Grav debugger statements inside your shortcode handler function, they will not be displayed in the page's debugger log
The problem is that clicking "Preview" triggers a "processMarkdown" AJAX call to awaken grav and handle processing the markdown and by extension calling shortcode-core which will call your custom shortcode handler logic. Processed content will be returned via the same AJAX call via the magic of the admin plugin, but the debugger log contents are not returned.
On a different note, I went down this rabbit hole of debugging because my shortcodes work fine on /admin/preview/...
but do not work on /admin/pages/...
. It currently seems some high level information is different between those two, e.g. the $page variable changes.
CSS allows for the font-size
attribute to have values such as x-large
, and units such as pt
or %
.
Current implementation of [size=...]
sticks px
onto the parameter. This reduces flexibility.
Suggest change so that px
is concatenated to parameter value only when parameter is a number.
See PR #63
With the update, the color tag do not work anymore. I understood that there is a need to create a new plugin from now on! May be a little bit to difficult for me though...
How show I do?
Seems like the current hook is too late for several use-cases.
As seen in this issue, shortcodes don't correctly add assets when used in modular pages.
As seen in this PR, shortcodes might add unwanted markup.
Hi, I am trying to add a shortcode to a theme but it doesn't seem to work – this is driving me crazy. This is my full theme code:
<?php
namespace Grav\Theme;
use Grav\Common\Theme;
class MyTheme extends Theme
{
/**
* Register events
*/
public static function getSubscribedEvents()
{
// echo 'TEST'; exit; // this works, so the theme should be intialized.
return [
'onShortcodeHandlers' => ['onShortcodeHandlers', 0]
];
}
/**
* Event that handles registering handler for shortcodes
*/
public function onShortcodeHandlers()
{
// is never called?!
$this->grav['shortcode']->registerShortcode('MyShortcode.php', __DIR__);
}
}
Any ideas why this is?
Is it possible to override the version of font-awesome used by the shortcode core plugin?
Hopefully, so people can override the font-awesome version themselves in case they need to.
Something like a setting in a yaml file would be nice.
If this is not possible, could you please update font-awesome to version 5?
I would like to use an icon that doesn't yet exist in 4.
When installing this via the Admin panel or though the terminal, the Font Awesome shortcodes are no where to be found.
Thanks.
I'm using the Forms v2.13.3 and Shortcode Core v2.7.1 plug-ins in Grav v1.4.3. As soon as I enable the Shortcode Core plug-in, forms inside modular pages no longer get populated (only the container HTML is generated, but no dynamic content, such as input fields and buttons).
I'm using the classical method of rendering forms in modular pages as described in the Grav manual, i.e. my parent page contains the form frontmatter, and the modular page consists of form.md with the following contents:
---
title: 'My Form'
cache_enable: false
---
Looks like in a modular page, shortcode variable is always null, independently by cache setting. Here's a working example: https://www.dropbox.com/s/r145zli0gi1l44u/gravstrap.tar.gz?dl=0
Page to check is /gravstrap-theme-simple-page-example (sorry the nav menu is not rendered). I put a {{ dump(shortcode) }} in the twig template, home_single_page.html.twig, and I got null, The cache is disabled.
Hello,
Since the last version, you can't use shortcodes around markdown :(
For exemple I often use [center]
around images like this [center]![My Image](image_src.jpeg)[/center]
. With the last release, this code doesn't work anymore, it just shows ![My Image](image_src.jpeg)
as plain text but centered though...
Other example
[size=10]_some text_[/size]
renders _some text_
with size 10 but not italic... So the shortcode is rendered but not the markdown...
When cache is enabled, sections are displayed only when the cache is built the first time.
When Shortcode-Core plugin is activated, Contact Us form stops working, i.e. doesn't show any field on modular page.
Version of Grav (v1.5.6) released on Fri Dec 14 22:08:22 2018
Land.io skeleton from https://getgrav.org/download/skeletons/gateway-site/1.0.0
Ubuntu 18.04
Hey, I just updated to the latest version and my FontAwesome icons break. It looks like it not honoring the following Markdown formats:
[fa=cog /] Simplest Format
[fa=fa-cog /] Format using fa- prefix
It is however, honoring this format: [fa icon=fa-cog /].
I haven't tested the "extras" options yet.
Thanks.
Your commit:
prevents form messages processing. (in modular forms)
Changing back to value: 0 ---> everythings working again
Is it possible to add new custom shortcodes in a location outside of the plugins folder? Like a new folder in the user/
folder or as part of a theme?
After having used [center][/center]
around some text in a markdown, I found out that the result was some raw text on the web page, stripped from all the CSS.
The reason is the CSS I built is defined on <p>
tags, and that the Shortcode plugin outputs text lines in <div>
, with just inline "style"
attribute. Here is the sourcecode :
<p><div style="text-align: center;">Envoyez un message à l'aide du formulaire de contact ou contactez-nous par téléphone.</div></p>
But styling <div>
to render text properly is more difficult than styling <p>
tags, and can lead to conflicts. Not mentioning that they are not made for this semantic purpose. So, my suggestion would be to fix the problem by embedding correctly the content catched by the plugin ! For instance :
<div style="text-align: center;">
<p>Some text<p>
</div>
Or, more efficiently, by acting on the <p>
tag itself :
<p style="text-align: center;">Some text</p>
I can't quite seem to figure out where to put a custom shortcode in order to get it working correctly. I tried creating a PHP file in the /user/custom/shortcodes
folder, and as a standalone plugin. Either way I get the error:
Class 'Grav\Plugin\Shortcodes\Shortcode' not found
Could you perhaps provide the exact steps of where to put the files to create a simple shortcode?
Thank you.
Hello there,
I've tried to use the size shortcode like this [size=10]test[/size]
Here is the result:
<span style="font-size: =10px;">test</span>
Am I the only one ?
Hello,
I'm trying to use the Shortcode Core plugin v2.0.2, but when it is enabled it seems like breaks the LangSwitcher v1.1.0 plugin, specifically the variable langswitcher.current becomes empty if it is inside a modular page template. Maybe I am missing something here? Please help me understand. Thanks!
Here is some minimal sample code to reproduce the issue:
languages:
supported:
- en
- el
- fr
cache:
enabled: false
twig:
cache: false
enabled: true
built_in_css: false
enabled: true
active: false
active_admin: false
parser: wordpress
load_fontawesome: false
---
title: 'Foo'
menu: Home
onpage_menu: true
content:
items: @self.modular
order:
by: default
dir: asc
custom:
- _header
---
---
title: Home
---
{% extends 'partials/base.html.twig' %}
...
{% block content %}
{{ page.content }}
{% for module in page.collection() %}
{{ module.content }}
{% endfor %}
{% endblock %}
...
<!DOCTYPE html>
...
<head>
...
</head>
<body>
{% block nav %}
{% set lang = langswitcher.current %}
<!-- this works ok output is <span>---en---</span> -->
<span>---{{lang}}---</span>
{% endblock %}
{% block body %}
{% block content %}{% endblock %}
{% endblock %}
...
</body>
</html>
templates/modular/header.html.twig
{% set lang = langswitcher.current %}
<!-- this does not work output is <span>------</span> -->
<span>---{{lang}}---</span>
When shortcode-core is enabled, header.html.twig
produces:
<span>------</span>
If it is disabled, the output is:
<span>---en---</span>
I just installed shortcode-core 2.3.1. Now the section shortcode isnt't rendered anymore. Reinstalled old section-shortcode.php and composer.json, everything is fine again???
When the Shortcode-Core plugin (v3.0.1) is activated, Taxonomy List plugin (v1.3.3) doesn't pull taxonomies anymore.
After updating to latest version shortcode-core (i guess) gives that error.
Location: /user/plugins/shortcode-core/shortcode-core.php
Highlighted line:
// get the meta and check for assets
$meta = $page->getContentMeta();
WordPress parser (default setting) is broken in the latest Grav + Shortcode Core. Switching to Regex or Regular fixes it. Color renders as a span without the color assignment on WordPress parser.
I wonder if this is a Grav or a Shortcode issue or expected behavior, or if this issue is related, but I'll describe the scenario:
I need to do some parsing to the page content before rendering in markdown, so:
|markdown
filterProblem is that, even with markdown extra, content inside shortcodes (such as [div]…[/div]
) then won't get rendered in markdown.
I've tried newlines etc., but at the moment the workaround looks like this:
---
process:
markdown: false
---
[div]{{"
### Markdown content here
I'm an ugly workaround
"|markdown}}[/div]
…which works, but defeats the purpose of the exercise, which is to create complex long-pagers with a single, minimal markdown document with unobtrusive section dividers, a bit like the example in the docs where you render content separated by ---
's in columns, but I'm adding some parsing to throw some id's/classes in, too.
I can't seem to nest div's/shortcodes with this plugin?
[div class="row"]
[div class="x12 s12 m12 l12"]
## Header
[/div]
[/div]
Gives the following output HTML
<div class="row">
<div class="x12 s12 m12 l12">
</div>
<h2>Header:</h2>
</div>
[/div]
Expected result:
<div class="row">
<div class="x12 s12 m12 l12">
<h2>Header</h2>
</div>
</div>
With both the TwigFeeds-plugin and the Shortcode Core-plugin active, the latter is removing twig_feeds
from .twig_vars
when in the module-context. That is, {{ dump(twig_feeds) }}
will return the active feeds on a modular page's template (eg. modular.html.twig
), but not when used on a module's template (eg. text.html.twig
).
For example, installing the Core (v1.1.17) + Admin (v1.2.14) package, TwigFeeds v2.0.3, and Shortcode Core v2.5.3, adding {{ dump(grav.twig.twig_vars.twig_feeds) }}
to user/themes/antimatter/templates7modular/text.html.twig
will return null in the Debugger with Shortcode Core enabled. With it disabled, however, feeds are returned as an array. In the parent-template it returns regardless.
X-ref: TwigFeeds issue 4.
Was working on new site using Gravstrap. Got notice of update for shortcode core and did so. Now the header / footers menus are gone, totally missing from entire site. Downgraded to version b4 update and all menus restored.
I am also working on a new bootstrap theme for Grav and it was effected same way.
Thanks!
Woody
Moved from here at @rhukster 's request.
I have a couple of shortcode plugins. I've received bug reports for Scheduler and Table Importer. It seems related to the Admin plugin somehow. I've done the following:
I did a clean install of Grav only (no Admin).
I then did bin/gpm install table-importer
.
I replaced default.md
with the following and dropped in import.csv
.
---
title: test
---
[u]Testing[/u]
[ti file=import.csv /]
I then downloaded and installed Grav+Admin and immediately did bin/gpm install table-importer
.
I added some dump()
statements to table-importer.php
.
I then dropped in the exact same markdown and csv.
So it appears the onShortcodeHandlers
isn't getting called for some reason, but the [u]
code is working. Any ideas?
Hi @rhukster I'm developing a chart-shortcode and I have to disable markdown parser in my plugin. I discovered some public methods in ShortcodeManager class like setupMarkdown
or processContent
, I need it becouse I'm trying to "parse" json and/or yml data. Do you think is it suitable?
Is there a way for my shortcode plugin to override the shortcode-core parser
setting? I tried just adding a parser
setting to my config file, but that didn't do it. I'm having trouble with my new shortcode recognizing quoted parameters containing spaces.
If shortcode content is 0
(zero), then $sc->getContent();
return NULL
.
Hi,
i tried Shortcode Section with a fresch grav-skeleton-blog-site installation and it's displayed correctly on the blog.page, but not on the homepage.
Thank you!
Userfolder is attached
user.zip
Here's my shortcode:
class JumbotronShortcode extends Shortcode
{
public function init()
{
$this->shortcode->getHandlers()->add('gravstrap-jumbotron', function(ShortcodeInterface $shortcode) {
$this->shortcode->addAssets('css', 'plugin://gravstrap/css/gravstrap_jumbotron.css');
$output = $this->twig->processTemplate('bootstrap/jumbotron.html.twig', [
'id' => $shortcode->getParameter('id'),
'image' => $shortcode->getParameter('image'),
'fullwidth' => $shortcode->getParameter('fullwidth'),
'content' => $shortcode->getContent(),
]);
return $output;
});
}
}
The 'plugin://gravstrap/css/gravstrap_jumbotron.css' asset is not added to page.
Just updated the shortcode-core plugin. After that, I get the following error on the one page where I make use of shortcode:
Argument 1 passed to Grav\Plugin\ShortcodeManager::getId() must implement interface Thunder\Shortcode\Shortcode\ShortcodeInterface, null given, called in /Users/phytzel/Sites/grav/user/plugins/shortcode-ui/shortcodes/AccordionsShortcode.php on line 33
The error page lists the following chunk from
/Users/phytzel/Sites/grav/user/plugins/shortcode-core/classes/ShortcodeManager.php
/**
* returns the shortcode of a specific hash
*
* @param string $hash unique id of state
* @return ShortcodeInterface shortcode stored for this hash
*/
public function getStates($hash)
{
if (array_key_exists($hash, $this->states)) {
return $this->states[$hash];
}
}
/**
* helper method to create a unique shortcode based on the content
*
* @param ShortcodeInterface $shortcode
* @return string
*/
public function getId(ShortcodeInterface $shortcode)
{
return substr(md5($shortcode->getShortcodeText()), -10);
}
/**
* Sets the current page context
*
* @param Page $page
*/
public function setPage(Page $page)
{
and highlights the line with getId().
It appears that the new shortcode-core does not work properly together with shortcode-ui.
Which further output should I provide?
Sections open new scenarios and it would be awesome to get the chance to share them between site pages.
When Shortcode plugin is activated, Breadcrumbs plugin stops working, i.e. doesn't show any path.
I am running a site that uses the shortcodes plugin and I have created a few custom shortcodes in the /user/plugins/shortcode-core/shortcodes/
folder.
But every time I update the plugin they are removed. I have backups which I can replace the missing files with but is there a way to create a folder outside of the plugin directory (either in a user/theme/myCustomTheme/
or directly in the user/
folder) that can be read by the plugin but not updated (thus removing any custom contents)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.