Plugin routes the following url in the admin area to a controller.
url: /admin/custom_route
The controller loads the plugin asset bundle that is CpAssets::class dependent & loads the twig template everything loads but browser console gives an error for Craft.js that Craft is not defined inside the Jquery exenteded plugin function. Where Craft.js & Craft.min.js are both being loaded when only one of them should be.
Been looking at the yii functionality but I'm at a loss.
Solution for anyone who else who is confused with the same problem.
In your template.twig you need to add head tags & call the head function this eliminates the Craft.js error.
<head>
{{ head() }}
</head>
I found the solution by looking at src/web/assets/cp/CpAsset.php where at line 98 - 103 it defines the missing js Craft object.
// Define the Craft object
$craftJson = Json::encode($this->_craftData(), JSON_UNESCAPED_UNICODE);
$js = <<<JS
window.Craft = {$craftJson};
JS;
$view->registerJs($js, View::POS_HEAD);
Where View::POS_HEAD defines the position in the document where the script is loaded according to the yii documentation. Just calling
{{ head() }}
Will not work it need to be within the head element tags of the document.
Related
I am using EJS in the browser (not on the server).
I have some ejs that I would like to use in multiple pages, so I want to put that in its own file, say table.ejs.
Is there a way I can include it in my HTML such that it is immediately accessible to my javascript after onload?
I was thinking something like:
<script id="table-ejs" type="text/ejs" src="ejs/table.ejs"></script>
then in my javascript:
ejs.render(document.querySelector('#table-ejs').???, data)
Is this possible?
I could use the Fetch API to retrieve the ejs file but then I would need to rewrite a lot of code to make it async. I was wondering if I could avoid that.
Well,
place all your ejs-files within a file "views" - within your views you can create another file "partials" - in this file you place your header and footer.ejs.
Within, lets say, your home.ejs you have to include the following code:
<%- include('partials/header'); -%>
// the rest of your code
<%- include('partials/footer'); -%>
You can find more here: https://ejs.co/#docs
If an uncached page is called in the frontend with a GET parameter that is not foreseen and has been appended to the URL from a link of an external source, like a tracking parameter or something worse e.g. …
https://www.example.com/?note=any-value
… then this foreign parameter is passed on in the automatically generated canonical tag, created by TYPO3's core extension ext:seo. It looks like this:
<link rel="canonical" href="https://www.example.com/?note=any-value&cHash=f2c206f6f14a424fdbf82f683e8bf383"/>
In addition, the page is saved in the cache with this parameter. This means that subsequent visitors will also receive this incorrect canonical tag, even if they call up the page https://www.example.com/ without the parameter.
Is this a bug (tested on TYPO3 10.4.15) or can it be disabled for all unknown parameters by configuration?
If you know the parameter, you can exclude it in the global configuration …
[FE][cacheHash][excludedParameters] = L,pk_campaign,pk_kwd,utm_source,utm_medium,…
… or via ext_localconf.php in the sitepackage:
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'tlbid';
I am only concerned with parameters that were not expected. It might make sense to turn the concept around and basically exclude all parameters except for a few self-defined allowed parameters, but I don't know if that is possible so far.
Got it. Actually, TYPO3 handles these already for other common tracking and additional params, like L, utm_campaign, fbclid etc. The whole list of excluded params can be found in the source code.
To add your own, just add/modify the typo3conf/AdditionalConfiguration.php file i.e. just like:
<?php
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'note';
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'foo';
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'bar';
or
<?php
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'] = array_merge(
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'],
['note', 'foo', 'bar'],
);
Don't forget to clear caches after all :D (that should be a TYPO3's slogan)
It's a bug. The extension urlguard2 solves this issue.
it dont work for me in the TYPO3 V11.5.16
LocalConfig:
[FE][cacheHash][excludedParameters] = L,tx_solr,sword_list,utm_source,utm_medi…
Browser URL:
https://www.example.org/testfaelle/test?sword_list%5B0%5D=testf%C3%A4lle&no_cache=1
The HTML Frontend canonical is:
<link rel="canonical" href="https://www.example.org/testfaelle/test?sword_list%5B0%5D=testf%C3%A4lle&cHash=e81add4ca148ad10189b9cbfa4d57100">
Debugging:
if i go in the file: "/typo3/sysext/frontend/Classes/Utility/CanonicalizationUtility.php" and add the Parameters directly: $paramsToExclude[] = 'sword_list'; ist works:
<link rel="canonical" href="https://www.example.org/testfaelle/test">
For example I know of
{{block class="Magento\Cms\Block\Block" block_id="block_identifier"}}
But where can I find documentation on all available features of this template language?
What other arguments can I use for {{ block }} etc.
The official Magento 2 documentation doesn't specify this. But, I think you can typically access all public fields of the base block class. If you are on a dev environment, their might be an error output even, if you use a wrong attribute. That error output probably shows, which attributes you are allowed to use.
The class responsible for parsing the {{ }} directives in
CMS Blocks and Pages is \Magento\Cms\Model\Template\Filter
which extends \Magento\Email\Model\Template\Filter.
In the latter the following directives are implemented:
block
layout
view
media
store
trans
var
protocol
config
customvar
css
inlinecss
widget
The last one is provided by the Widget module.
You can find some more info in this section the official Magento docs
I want to call the Amplience handlebars service with additional parameters that I can then use with my content rendering.
tried with
https://c1.adis.ws/v1/content/jwdemo/content-item/32101dfb-f1aa-4b35-a69d-724fa2275660?template=debug-content-asset&status=In-Progress
Nothing shows up - where in the content JSON should the parameters actually end up? How can I reference them in the handlebars code?
Parameters can then be referenced from within your handlebars template. Parameters need to be name-spaced with 'crparam' in order to be recognised. I've updated your request
https://c1.adis.ws/v1/content/jwdemo/content-item/32101dfb-f1aa-4b35-a69d-724fa2275660?template=debug-content-asset&crparam.status=In-Progress
If you're trying to compare or add business logic then the example below shows what would be needed in your template using the crParam and eq helpers
{{#eq (crParam 'status' .) 'In-Progress'}}
Progressing...
{{else}}
Do Nothing
{{/eq}}
I'm probably missing something simple but I have no way to test Jekyll locally.
I'm using GitHub pages to render Jekyll, for starters I only want to render markdown content on the main index.html from one markdown page.
The structure is:
Index.html
---
layout: default
---
_layouts
- default.html
//html stuff..
<section>
{{page.content}}
</section>
In root folder I have a page called content.md that I wish to render for {{page.content}} the layout renders but the liquid tags section is blank.
How do I render content.md?
Example: https://github.com/wycks/wordpress-gears-jekyll
There are a few things going on here.
In your _layouts/default.html file (and any of the other _layouts directory files for that matter), instead of:
{{ page.content }}
you need to use:
{{ content }}
Jekyll only lets you includes files from a site root level _includes directory. So, you need to move your content.md from the root to that directory (making it if it doesn't already exist).
Finally, you need to actually make the call to the include file from your index.html file. This can be done by changing the content of your index.html file to:
---
layout: default
---
{% include content.md %}
That will setup the behavior you are looking for.
I'd point out two other things:
You may find that changing the extension of your index file from .html to .md works better. An important note though: you need to use .html if you want pagination. Per the Jekyll Pagination documentation, that feature only works when the file is named index.html.
If all you are doing in your index file is calling an include that only resides on that page, you might be just as well off simply putting the content directly in the index file.
include only allows you to include files directly under _includes/. There is is also include_relative which allows you to use paths and include from other places. The include has to be relative to the given file however:
{% include_relative somedir/footer.html %}
There is one issue with either include method I can't resolve: If the file you include has front matter Jekyll won't strip it out. So you can't use front matter to store include specific meta data - like say "title". Of course you can use variables - {% assign title = "My Title" %} but it's not equivalent, because if you want the thing your including to be part of a collection or rendered independently you have to have a front matter.
I believe it is just
{{ content }}
good sir.
ref