I have a view named "Blog archive". The view displaye title, blurb and image fields. It's a page view and the twig template for the view is named as "page--blog--archive.html.twig". The view content is as follows:
{% if page.content %}
{{ page.content }}
{% endif %}
Thsi prints out the view fields correctly but without any style classes. I want to add the below snippet into the twig template and iterate through view rows:
<div class="grid-4 omega ft-text">
<h3 class="blog-title">{{ fields.title.content }} </h3>
<br/>
<span style="font-family: sans-serif; font-size: 10pt;">
<p>{{ fields.field_blurb_new.content }}</p>
</span>
<h4>{{fields.field_blog_readmore_link.content }}</h4>
</div>
any help on how to achieve this?
Related
im trying to get bullet points on all listed items on that tab (collapsible content) on dawn theme with shopify. But i managed to get that just on first item, you can check here with preview url: https://1524t2hmp2urghsm-53196980409.shopifypreview.com
and here is part of code reference this issue:
{%- when 'collapsible_tab' -%}
<div class="product__acordion_container">
<div class="product__accordion accordion" {{ block.shopify_attributes }}>
<details id="Details-{{ block.id }}-{{ section.id }}">
<summary>
<div class="summary__title">
{% render 'icon-accordion', icon: block.settings.icon %}
<h2 class="h4 accordion__title">
{{ block.settings.heading | default: block.settings.page.title }}
</h2>
</div>
{% render 'icon-caret' %}
</summary>
<ul>
<li id="ProductAccordion-{{ block.id }}-{{ section.id }}">{{ block.settings.content }}</li>
{{ block.settings.page.content }}
</ul>
</details>
</div>
</div>
https://ed.codes/blogs/tutorials/add-a-youtube-video-inside-collapsible-row-block-accordion-on-shopify-product-page use this vid to add the element to the block
then add a container in the liquid
<p>
{% if product.metafields.custom.METAFIELDNAME %}
<div class="product-features__features Container">
{{product.metafields.custom.METAFIELDNAME}}
</div>
{% endif %}
</p>
and then link to the HTML formatted list as a multi-line text meta field.
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?
I have the following in a custom text field in a view:
<h5 class="rates_title">{{title}}</h5>
{%if field_car%}
<p class="car">{{field_car}}
{%if title != "Home" %}
<span class="small_caps">car</span>
{%endif%}
</p>
{%else%}
<p class="view-details">View Details</p>
{%endif%}
Everything works except the {%if title != "Home" %} part. Every item gets the span tag, even Home, which I do not want. Yes, the title is Home, and I can confirm that in the <h5> tag.
title at that point is an array and needs to be rendered but then it will contain html tags so you need to search in that rendered string for Home like this
{% if 'Home' in title|render %}
<span class="small_caps">car</span>
{% endif %}
I'm trying to pass a form along to a view but it wouldn't display and I get an error 500 (page loading is stopped and then, when I try to reach another page, it freezes)
I tried several tutorials including the official symfony documentation and I always get to that same point.
So please help me... (below is my code)
my controller
<?php
namespace siteBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use siteBundle\Form\ContactType;
use siteBundle\Entity\Contact;
class SiteController extends Controller
{
public function navigationAction(string $page,Request $request)
{
$option=array();
if ($page=='contact')
{
$donnees=new Contact();
$form=$this->createForm(ContactType::class,$donnees);
$option['contact']=$form->createView();
}
return $this->render('siteBundle:Pages:'.$page.'.html.twig',$option);
}
}
?>
my view
{% extends 'general.html.twig' %}
{% block description %}blabla{% endblock %}
{% block title %}blabla{% endblock %}
{% block body %}
<div class="container">
<h1>Prendre Contact </h1>
<p class="text-justify">
<br>blabla
</p>
<br>
<div class="row text-center">
<div class="col-md-6">
<p>
<img src="{{ asset('bundles/site/img/telephone.png') }}" alt="téléphone"><br>
<p>01.23.45.67.89</p>
</p>
</div>
<div class="col-md-6">
<p>
<img src="{{ asset('bundles/site/img/email.png') }}" alt="email"><br>
<p>a#b.fr</p>
</p>
</div>
</div>
<br>
<div class="row text-center">
<p>
<img class="text-center" src="{{ asset('bundles/site/img/formulaire.png') }}" alt="Formulaire"><br>
<p>Complétez le formulaire ci-dessous</p>
</p>
</div>
{% if contact is defined %}
<div>
{{ form_start(contact) }}
{{ form_widget(contact) }}
{{ form_end(contact) }}
</div>
{% endif %}
</div> <!-- container -->
{% endblock %}
thanks in advance for your help
Regards
Make sure you use the dev env to display the stack trace of the Exception.
You can use /app_dev.php for that.
my opinion, the error in:
return $this->render('siteBundle:Pages:'.$page.'.html.twig',$option);
use:
return $this->render('SiteBundle:pages:'.$page.'.html.twig',$option);
Check your logs! /var/logs/prod.log or error.log, and you find an error message
In you route change the key word controller by _controller
Maybe this would help :
if i get rid of the array $option on my render line (see code below), there is absolutely no problem and the page loads fine.
return $this->render('siteBundle:Pages:'.$page.'.html.twig');
something is happening when passing the variable to the template...
I am completely new to PHP, Wordpress and Timber. I have a custom post type called Projects, it uses the posts archive template and I am going crazy to create a specific Projects archive template so I can have a different layout for it.
This is what my index.twig looks like
{% extends "layouts/base.twig" %}
{% block content %}
<div class="uk-child-width-1-3#m" uk-grid uk-scrollspy="cls: uk-animation-fade; target: > div > .uk-card; delay: 500; repeat: false">
{% for post in posts %}
{% include "tease-post.twig" %}
{% endfor %}
</div>
{% endblock %}
and this is the tease-post.twig
{% block content %}
<div>
<div class="uk-card uk-card-default">
<div class="uk-card-media-top">
<img src="{{post.thumbnail.src('full')}}" alt="">
</div>
<div class="uk-card-body">
<h3 class="uk-card-title">{{post.title}}</h3>
<p>{{post.get_preview(25,false,false,true)}}</p>
</div>
<div class="uk-card-footer">
Read more
</div>
</div>
</div>
{% endblock %}
Any idea how it works? Can't find any related documentation..
There are a few diff't methods depending on what you're looking to achieve. It would seem the simplest is...
{% extends "layouts/base.twig" %}
{% block content %}
<div class="uk-child-width-1-3#m" uk-grid uk-scrollspy="cls: uk-animation-fade; target: > div > .uk-card; delay: 500; repeat: false">
{% for post in posts %}
{% include "tease-'~ post.type ~'.twig" %}
{% endfor %}
</div>
{% endblock %}
You could then create a file called tease-project.twig (assuming that `project is the name of your custom post type's slug) that might look something like this...
{# tease-project.twig #}
<h2>My cool project is... {{ post.title }}</h2>
If you're looking to do something special with a CPT's specific archive page...
Check your archive.php file, if you're using the starter theme it should load a file called archive-projects.twig (assuming that projects is the name of the custom post type).
The logic is fully customizable so you can load any .twig files you want depending on the circumstance