Impresspages - set meta title/description from plugin's PublicController? - impresspages

Is there any way to set page-specific attributes for plugin in PublicController, like seo meta tags (title, description, keywords) or push it to breadcrumbs? I figured that I can easily set layout file for plugin, but can't go any deeper.

If you return an \Ip\Response\Layout object in your controller, you can use methods like ->setKeywords(), ->setDescription() ...
If you simply return a string leaving the layout to be generated by ImpressPages, you can add a filter which would add required meta information before outputing it. Here is an example that sets favicon https://github.com/impresspages-plugins/Favicon/blob/master/Filter.php

Related

How To Enable Block Inside Fifty Different Sections Without Copying Meta Code?

I am developing a Shopify Theme. The structure I have now is (excerpt):
Snippets
custom-message-snippet
Sections
custom-message-section
welcome-page-a-section
welcome-page-b-section
Templates
welcome-page-a-template
welcome-page-b-template
...
Custom message snippet uses settings that are in the custom-message-section, that is:
a) message
b) header text
I'd like for users to be able to add custom-message-snippet to welcome-page-a and welcome-page-b in a way that settings for both are different.
I can not render section 'custom-message-section" inside welcome pages because it is not possible (and a workaround is nasty).
There are fifty welcome pages. Every welcome page is totally different.
My question is:
How to allow users to use custom-message-snippet in all welcome pages without copying and pasting custom-message-page setting schema to each and every welcome page?
combine custom-message-section to custom-message-snippet
combine welcome-page-\w+-template to welcome-page-template, you only need to have one template and schema set, the user will control the sections in schema selection.
in template, use schema to select the page-content; this, defined by a bunch of if-else /switch statement.
{% section "welcome-page-custom-message-section" %}
{% section "welcome-page-content" %}
in welcome-page-custom-message-section
{% render "custom-message-snippet" with "string from welcome-page-section schema " %}
create checkbox select schema for custom message to appear or not.
Short: You can't.
Long: Using storefront 2.0, you end you having blocks, which can be added manually to any template.
It is possible if you have a little knowledge of Node.js and you're using the Shopify CLI.
Check the solution here: Shopify Section / Block Schema In A Separate File. It is possible 

Go template is adding extra quotes to output

I want to use the value of my variable in Go template as-is but Go is adding extra quotes around it. E.g., for a Go template like
{{.Site}}:{{.Port}}/{{.Path}}
I want to get the output as
Mysite:3000/from/here
but the template is giving me the following instead:
"Mysite":"3000"/"from/here"
So,
How can I fix it (get rid of all the extra quotes or better suspend them all)? See https://play.golang.org/p/uKpgXdLv5gM
Go template also changed "orgId=1&refresh=30s" to orgId=1\u0026refresh=30s, how to avoid that?
Moreover, if I add https:// to the front of my url, the output is truncated. How to fix that as well?
Finally, is it possible to escape "`" within "`"?
As per Go HTML template doc:
HTML templates treat data values as plain text which should be encoded so they can be safely embedded in an HTML document. The escaping is contextual, so actions can appear within JavaScript, CSS, and URI contexts.
The security model used by this package assumes that template authors are trusted, while Execute's data parameter is not. More details are provided below.
It means JavaScript escaping is enabled whenever the go HTML template engine detects that it is within a <script> tag, (i.e., it has nothing to do with whether using regular " or not as the first commenter thinks). So
to get the output as
Mysite:3000/from/here
instead of:
"Mysite":"3000"/"from/here"
Do not wrap it with <script> & </script> tag.
Do the concatenation after template Execute().
Again, with <script> & </script> tag wrapped around, I'm getting:
var url = `"Mysite":"3000"/"from/here"/${othervars}?"orgId=1\u0026refresh=30s"`
vs. without <script> & </script> tag wrapped around it, I'm getting:
var url = `Mysite:3000/from/here/${othervars}?orgId=1&refresh=30s`
Just what I need.
However, my actual case is that I'm using go HTML template engine to process my .html template files, so I cannot really do the concatenation afterwards, as everything is defined in the .html template file. So, just as Martin Gallagher has shown in his code, for such case, using template function seems to be the only option.
But even that might not be a viable option, as this is what I'm getting out of Martin's code:
var url = "Mysite:3000\/from\/here?orgId=1\u0026refresh=30s"
It is still not exactly what I wanted:
var url = `Mysite:3000/from/here/${othervars}?orgId=1&refresh=30s`
So maybe with such case, it indeed has no ideal solution.

How do I force Pelican to suppress generation of category files?

I don't want Pelican 3.6 to generate:
/author/
/category/
/tag/
/archives.html
/authors.html
/categories.html
/tags.html
DIRECT_TEMPLATES can be set to suppress some of the index files:-
# DIRECT_TEMPLATES = ['index', 'categories', 'authors', 'archives']
DIRECT_TEMPLATES = ['index']
Omitting tag metadata in source content files will prevent generation of the tag folder and index; omitting author metadata and the AUTHOR setting will prevent generation of the author folder and index.
But it seems that suppressing category isn't so simple. I've tried setting DEFAULT_CATEGORY to an empty string, but this results in errors and no output for sources with no category metadata:-
Skipping <some_file>: could not find information about 'NameError: category'
I've also tried removing the relevant template files from the theme being used, but this merely causes them to be replaced with the matching template in the built-in "simple" theme.
Am I missing an established method of suppressing category generation?
The URL settings documentation has a long list of settings, including several […]_SAVE_AS settings. Directly below the URL settings table is a note that answers your question: for any page type that you do not want generated, set the corresponding […]_SAVE_AS setting to ''. For example, to suppress individual category page generation, add this setting:
CATEGORY_SAVE_AS = ''

How can I make a grid of content in Pelican?

I am trying to use Pelican to generate a static webpage that would have rows of content.
I want it to look something like this (WIP)
Currently I have just manually created the necessary HTML.
How could I have a single content file that would generate this page ?
Pelican uses the Jinja template system, so the first step is to create your own theme, putting your existing HTML structure into the base.html template. You'll likely want to customize your page.html template as well.
Once your theme's templates are customized to your liking, you can then create pages in any of the formats that Pelican supports: Markdown, reStructuredText, and Asciidoc. It's not always easy to use these markup formats to get precisely the HTML you want, so you might start with Markdown, since that format allows you to put HTML directly inside your content.
To make a table grid in Markdown-formatted file, add the Pelican just_table plugin.
If your existing PLUGINS is defined to something like:
PLUGINS = ['sitemap', 'code_include', 'tag_cloud']
just add , 'just_table' to PLUGINS set to make a:
PLUGINS = ['sitemap', 'code_include', 'tag_cloud', 'just_table']
and in creating your first Markdown text file named my-first-grid-table.md, take your CSV-formatted content and wrap it with [jtable]/[/jtable] tags. Such working example is:
Title: My first grid table
Date: 2018-11-06 11:00
Tags: grid, table
Category: blog
My grid looks like:
[jtable]
Name, Age, Description
John, 40, Cantankerous
Jill, 35, Bruised from tumbling down the hill
Basket, 120, an inanimated object
[/jtable]

New blank page in Zen-Cart

How can I create a new blank page in zen-cart without applying the template.
I want to create a page that will result only a JSON data...
Thanks in advance
Create a php file in your store directory. In that file, if you want to use ZenCart functions you can include them, like so:
<?php
include "includes/application_top.php";
set headers for mime type
set headers for not caching
YOUR CODE
echo $json;
// below is optional if you didn't create/edit session
include "includes/application_bottom.php";