How to change meta title as rich text - django-urls

I am new to django. I want to change meta title(header) as rich text( or I want to remove html tag) in django wagtail dashboard,
I tried add wagtailadmin/shared/header.html file and change the title as {{title|safe}} but its not worked.

I override templates/wagtailadmin/pages/edit.html
as
{% block titletag %}{% blocktrans with title=page.get_admin_display_title|striptags page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }}: {{ title }}{% endblocktrans %}{% endblock %}
Now It fixed.

Why would you want to change the meta title to a rich text? Meta title is for your meta header.

Related

How to access view fields inside page--%.html.twig

I have a page view that displays title and body fields and the twig template for the view is named as "page--my--view.html.twig". The view content is as follows:
{% if page.content %}
{{ page.content }}
{% endif %}
How can I add individual fields and classes in this template? For example:
<h3 class="title">{{ fields.title.content }} </h3>
I want to add a 'for' loop and print all the titles through page template like above. How to do this?

Use a template to set a variable

I'm using craftcms and the template language they use is Twig.
The _layout/base.html:
<!DOCTYPE html>
<html>
<head>
{% include '_layout/_seo_default.html %}
</head>
_layout/_seo_default.html:
{% if seo is not defined %}
{% set seo = {title: "Default values for things", description:"Default Description"} %}
{% endif %}
<title>{{ seo.title }}</title>
<meta name="description" content="{{ seo.description }}">
I have a blog/_entry template which shows an entry from the CMS based on the url. The blog/_entry.html:
{% extends '_layout/base.html' %}
{% block main %}
{# i want this include to set a variable used in _seo_default.html #}
{% include '_seo/_from_article_type_entry.html' with {entry: entry} %}
<article>
html irrelevant to question
</article>
{% endblock %}
The _seo/_from_article_type_entry.html
{% set seo = { title: entry.title, description: entry.short_description } %}
The idea was that i would be able to map the fields to the correct keys in one template / at one place. So i don't have to reuse it for the news/blog/story templates the client wants. But the 'seo' variable set in _seo/_from_article_type_entry.html does not get set (either not at all, or not in time that the _layout/_seo_default.html picks it up, and default values are always used.
If i replace the {% include '_seo/_from_article_type_entry.html' with {entry: entry} %} line in blog/_entry.html with the contents of _seo/_from_article_type_entry.html it does work, so it just doesn't seem to get set in the include. But I can't figure out what i'm missing. Or maybe i'm trying to do something that Twig is not supposed to do.
In either case, any help would be very welcome :)
Included templates have their own variable scope, templates outside the included one can't access these variables as seen here

How to add categories in shopify blog like wordpress blog?

I want categories like this in Shopify blog section.
Create a blog-sidebar section and associate on blog page.
Navigate to section and add a template name blog-sidebar.liquid
include a sidebar on blog page
{% section 'blog-template' %}
{% section 'blog-sidebar' %}
on blog-sidebar.liquid add a schema like below which would add a
textarea field to list tags that we are considering as a blog
category
{% schema %}
{
"name": "Sidebar",
"settings": [
{
"type": "textarea",
"id": "blog_category",
"label": "Blog category",
"info": "categories are selective tags. Mention those selective tags seperated with comma above."
}
]
}
{% endschema %}
The above schema on blog-sidebar section would create a field on
blog section on customize theme. (Online store > customize theme >
navigate to blog page on the preview section to view)
enter image description here
Now add tags that you are considering as blog categories separated
with comma, in the above screenshot summer and another are tags.
on the same blog-sidebar section add these codes
{% comment %}
Blog categories
{% endcomment %}
{% if blog.all_tags.size > 0 %}
{{ 'blogs.sidebar.categories' | t }}
{% for tag in blog.all_tags %}
{% if section.settings.blog_category contains tag %}
{% if current_tags contains tag %}
{{ tag }}
{% else %}
{{ tag | link_to_tag: tag }}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
The code above would print tags that we have separated as categories.

text overflow in block content

I want to make a simple blog that shows the details of a post when a user clicks a title in a list of new posts on an index page. However, I realized that my detail of post shows overflow in my block mycontent, this is what I did:
base.html has a line like this:
<div class="col-md-8">
{% block mycontent %}
{% endblock %}
</div>
my read_post.html
{% block mycontent %}
<h3>{{ post.title }}</h3>
<code>{{ post.publish }}</code><br>
{{ post.content|linebreaks }}
{% endblock %}
This is my result when I have long text, I want it to have a newline and to not overflow from block mycontent. I am using boostrap for theme site
Have you tried word-wrap: break-word property?
- Word-wrap allow long words to be able to break and wrap onto the next line
- break-word allows unbreakable words to be broken

How to change the title of page dynamically with Twig

Im using Twig for template in my website, I extend layout.html.twig in all my others twig pages,so In my layout.html.twig I have the title of page :
<title>{% block title %}Title of my website{% endblock %}</title>
Now my problem is how to change this title dynamically in all my pages, for example I have news.html.twig to show all latest news in the world, so I hope when I display my news page I have the title of the news in my title of page...
<title>{% block title %}Title of the news{% endblock %}</title>
My solution looks a bit more elegant in the child-templates:
In your layout.html.twig:
<title>{% if page_title is defined %} {{ page_title }} | {% endif %} Your Website</title>
In your child page-templates:
{% extends '::layout.html.twig' %}
{% set page_title = 'Your page-title' %}
{# Put the rest of your page below #}
And you can also reuse the title in eg. an doing <h1>{{ page_title }}</h1> :-)
You are close. In your news.html.twig I assume you have all of your content in a block like this:
{% extends '::layout.html.twig' %}
{% block content %}
content of the news page here
{% endblock %}`
So all you have to do is add another block for the title outside of that content block
{% extends '::layout.html.twig' %}
{% block title %}Title of news page{% endblock %}
{% block content %}
content of the news page here
{% endblock %}`
Is more simple that you imagine.
Put on main/parent layout
...
<title>{% block title %}{% endblock %} - My Site</title>
...
and, in a content page ( on child layout ), get the page title
...
<h1>{{ block('title') }}</h1>
...
So, any title that you put in head title will be displayed in the content title.
{% block title %} {{ post.title }}Symfony web.app{% endblock %}

Resources