Hide An Element After A Certain Date - date

I have created a countdown and want to hide it after the expiry date which is the 17th of December.
The countdown section is called AnnouncementBar__Wrapper40.
Here is the code:
<div class="AnnouncementBarnew">
<div class="AnnouncementBar__Wrapper60">
<div class="AnnouncementBartext">
{{ section.settings.content }}
</div>
<div class="AnnouncementBartext">
{{ section.settings.content2 }}
</div>
</div>
<div class="AnnouncementBar__Wrapper40">
{% include 'countdown-timer',
title: "CHRISTMAS LAST ORDER",
end_date: "Dec 17, 2022"
%}
</div>
</div>
I have tried to hide with code but I copied but my knowledge isn't that advanced.

Related

How to shift a Bootstrap form over to the right?

I am doing an inventory management page for my school project, and currently, the form whihroducts is shifted to the left.
How it looks like:
{% extends "base.html" %}
{% block title %}Adding a new product{% endblock %}
{% block content %}
{% from "includes/formHelper.html" import render_field %}
<h1 class="display-4">Add new product</h1>
<form method="POST" action="">
<!-- Container class for Form -->
<div id="container py-2">
<div class="form-group" >
<div class="col-sm-3 order-5 float-right py-2">
{{ render_field(form.name, class="form-control") }}
</div>
</div>
<div class="form-group">
<div class="col-sm-3 order-5 float-right py-2">
{{ render_fiel {{ render_field(form.type, class="form-control") }}
</div>
</div>
<div class="form-group">
<div class="col-sm-3 order-5 float-right py-2">
d(form.stock, class="form-control") }}
</div>
</div>
<div class="form-group">
<div class="col-sm-3 order-5 float-right py-2">
{{ render_field(form.price, class="form-control") }}
</div>
</div>
</div>
<input type="submit" value="Submit" class="btn btn-success btn-lg float-left">
</form>
I tried using CSS to float-right and row-reverse the entire form to the right of the page, but it still does not work out.

Display Twig Form with a loop

I'm currently working on a private social network for fun and to improve my skills.
Anyway, I want to display a form to leave a comment on a post using a loop but I have issues trying that.
I'm using Symfony, twig and bootstrap, and I'd like to keep js, jquery or ajax away.
Here is my code:
My form builder:
class CommentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', null, [
"label" => "Your title"
])
->add('content', null, [
"label" => "Your content"
])
->add('submit', SubmitType::class, [
"label" => "Publish your shitty comment!"
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Comment::class,
]);
}
}
and my view:
<ul class="nav col-4 offset-3">
{% for post in posts %}
<li class="postItem">
<article class="postItem">
<p> {{ post.title }} </p>
<img id="postPics" src="{{ asset('./pictures/posts/' ~ post.picture) }}">
{{ form(leaveCommentForm) }}
<h3>{{ post.title }}</h3>
<p>{{ post.content }}</p>
<author>{{ post.user.username }}</author>
<div class="commentPost">
{% for comment in post.comments %}
<article>
<h6 style="font-weight: bold">{{ comment.title }} -
By
<author>{{ comment.user.username }}
on {{ comment.dateCreated | date('Y-M-d') }}</author>
</h6>
<p>{{ comment.content }}</p>
</article>
{% endfor %}
</div>
<input type="hidden" value="{{ post.id }}" name="postId"> {{ post.id }}
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Leave a comment
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Leave a comment</h4>
</div>
<div class="modal-body">
{{ form_start(leaveCommentForm) }}
<input type="hidden" value="{{ post.id }}" name="postId"> {{ post.id }}
{{ form_end(leaveCommentForm) }}
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</article>
</li>
{% endfor %}
</ul>
As you can see I want to display my form on each iteration of post (with or without modal I don't really care I was just trying some things).
My problems here are:
*If I use a modal, I can't get my post.id inside my modal and so I can't send it to my controller.
Actually I get the value of first post.id for every posts.
*If I don't use a modal I can't even see my form on my page.
If you have a solution that would be great!
Thanks in advance guys!

Why my jekyll site on github not work with mathjax?

I start to build a jekyll site on github following this BLOG.
OK it works.
I would like to add some math stuffs in my blog, I add a "mathjax.html" in "include folder"
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
equationNumbers: {
autoNumber: "AMS"
}
},
tex2jax: {
inlineMath: [ ['$','$'],
['\(', '\)'] ],
displayMath: [
['$$','$$'] ],
processEscapes:true,
}
});
and then include this file in Layouts files(default.html page.html post.html)
<div class="wrapper-footer">
<div class="container">
<footer class="footer">
{% include svg-icons.html %}
</footer>
</div>
</div>
{% include analytics.html %}
</body>
</html>
{% include mathjax.html %}
default.html
---
layout: default
---
{% include mathjax.html %}
<article class="page">
<h1>{{ page.title }}</h1>
<div class="entry">
{{ content }}
</div>
</article>
page.html
---
layout: default
---
<article class="post">
<h1>{{ page.title }}</h1>
<div class="entry">
{{ content }}
</div>
<div class="date">
Written on {{ page.date | date: "%B %e, %Y" }}
</div>
{% include disqus.html %}
</article>
{% include mathjax.html %}
post.html
and add this line in post file
$$ sin(x^2) $$
As a result ,the page show nothing ...
what 's wrong with it?

Default checked radio input not working in Laravel with Bootstrap syntax

Using Laravel 4's Radio form helper, I cannot use Bootstrap 3's radio button syntax and get the inputs to be checked by default.
Here is a normal radio button setup, that works properly
{{Form::radio('awesome_radio_input', 'yes', true)}} Yes
{{Form::radio('awesome_radio_input', 'no')}} No
And here is the BS3 syntax, where I am not getting any radio inputs checked by default
<div class="radio-inline">
<label>
{{Form::radio('silly_radio_input', 'yes', true)}}
Yes
</label>
</div>
<div class="radio-inline">
<label>
{{Form::radio('silly_radio_input', 'no')}}
No
</label>
</div>
Any ideas as to why the syntax would break the Radio helper?
Try this :
<div class="form-group">
{{ Form::label('gender', 'Gender') }}
<div class="form-inline">
<div class="radio">
{{ Form::radio('gender', 'true', true) }}
{{ Form::label('men', 'Men') }}
</div>
<div class="radio">
{{ Form::radio('gender', 'false') }}
{{ Form::label('woman', 'Woman') }}
</div>
</div>
</div>

how to display all form error at one place

I have seen various posts regarding same issue but nothing could become useful for me.
This is my Form
<form action="" method="post" {{ form_enctype(form) }} novalidate>
{{ form_errors(form) }}
<div class="login_field">
{{ form_label(form.name) }}
{{ form_widget(form.name) }}
</div>
<div class="clear"></div>
<div class="login_field">
{{ form_label(form.status) }}
{{ form_widget(form.status) }}
</div>
<div class="login_field">
<label> </label>
<input type="submit" value="Create" class="submit_btn" />
</div>
</form>
Error are not being displayed at all. How can i get out of this issue?
You have to include form_errors for every field ...
<div class="login_field">
{{ form_errors(form.name) }}
{{ form_label(form.name) }}
{{ form_widget(form.name) }}
</div>
... or just use form_row to render all the three of them together ...
<div class="login_field">
{{ form_row(form.name) }}
</div>
... or let your form errors bubble up to the top using the error_bubbling option for your form-fields in your FormType class. This means they will then be rendered through {{ form_errors(form) }}.
$builder->add('fieldname', 'text', array(
'error_bubbling' => true,
));
quick tip: you can include the submit button in your FormType since symfony 2.3 and don't have to manually render it (reference).
To display all the errors at top of form do like below
<ul>
{% for error in form.vars.errors.form.getErrors(true) %}
<li>{{ error.message }}</li>
{% endfor %}
</ul>