I am using the paragraph module in drupal
I am trying to get acces to some values
I am able to get each paragraph object by content.field_portfolio_items.1 or 2 or 3 ... etc
I am not getting to the values inside.
I am trying to acces the value 'field_button_text'
Van anyone tell me how i get to that value using twig
something like (this one isnt working for me):
{{ content.field_portfolio_items.2.paragraph.values.field_button_text }}
Related
I'm trying to create a mail template for my dags in airflow, I'm strugling to find the documentation, I tried this but it's poor
I'm trying to find out what are the variables that I could use in my template, for example : for the subject I want to access the dag name (not the {{ ti }} which contains others informations), also for the body, I want to choose which part to be send (in my case, the real exception is displayed as warning in aiflow log, thus, I want to send it instead of {{ exception_html }}
Basically, what I'm trying to do is get a 1/4 of a price in a Django Template Editor.
quote.total is a generated value by the system, for example: 1235.00, and I need to manipulate that value to show 308.75 (1235.00 divided by 4).
I've tried things like using {% widthratio quote.total 4 1 %} to get the quotient, however widthratio rounds the quotient, and I need an exact one.
I've also tried {% widthratio quote.total 4 100 %}, to get the quotient multiplied by 100 (implying that all I'd need to do is figure out how to place a decimal point two places over), but have found no way of using CSS to place a decimal point in.
It is also worth noting that because of the products I am working with quote.total will never have a value in the tenths or hundreths place. I've tried using that to my advantage by adding modulus operators and complex math rules & logic with no success.
The one problem with the system I am using is I have no access to the backend to create custom functions, and because of the way the system parses the template, I cannot use script tags.
EDIT: I see you cannot use tags since you have no access to the back end. You may need a JS-based solution. I'll leave this answer up in case it helps someone.
This is a pretty common use case. Consider using a custom filter, something like:
template.html
{% load quarter %}
{{quote.total|quarter}}
/your_app/templatetags/quarter.py
from django import template
register = template.Library()
#register.filter()
def quarter(value):
return (float(value) * 0.25)
Documentation on custom filters is here in the Django Docs. Also, as with any template tag, be sure to restart your server after adding it, or it will django will not register the tag and will throw an error. This is true of production and development servers.
I would like to display a uniquely defined form_widget(form.myform) at several places in my code.
How could I do it?
When just put form_widget(form.myform) at different places in my code, only the first one is shown, all the following ones are ignored.
Thank you!
It is impossible by following reason: by default twig generates id for each form field considering following scheme - formTypeName_formTypeFieldName, and there could be only one element with such id at the same time.
EDIT:
You could try something like {{ form_widget(form.title, { 'id': 'my_custom_id' }) }} with different identeficators for same field, but those input still will have same names and to be frank I'm doesn't sure how it will be handled by symfony kernel.
Im trying to modify records from my wep page using bolt, for lets say an comment section. If someone posts an answer underneath an news item how do i put that info into an record. And if they want to edit their reaction how would I update it.
So i was trying something at this point with the status. My base status is always published.
{{ record.status == draft }} <-- tried this way
{% set record.status == record.status = draft %} <-- tried SET
{% set record.status == record.status = "draft" %} <-- tried adding ""
After my try and error period I went to all the documentation on bolt and twig. But I cant seem to find out how to do this.
So I hope someone knows how to do this, thank you in advance.
short anwser is - you can't modify database records directly from twig.
Twig it's template system (idea is to show data with it) .
To dwhat you want you need to write all this "stuff" by yourself . It can be done (best way is to learn about creating custom modules - but you need to be quite good with OOPHP , symfony components etc. )
We are transforming PHP Application to Symfony2 Application.
Most of the pages we are completely writing new but some pages we decided to keep it as it is. i.e I want to use the same php without any major change.
In the php page we used GET['prospect_id'], GET['executive_id'] and many other arguments. Both GET and Post methods. When I view the page in Symfony1.4 there is no error or warning.
But when I view in Symfony 2 I am getting undefined index error.
How can I solve the issue?
EDIT: if GET['prospect_id'] is null there is no error in Symfony 1.4 but i'm getting undefined index notice in Symfony2. There are many variables like that. Is it necessary to define variable before use it. How to avoid this notice message.
What i want is if i am using $_GET['xxx']. symfony2 should not show any notice or error. i want to escape from that.
Use (in Symfony2) the controllers request-object, to get those params:
$this->request->get('prospect_id');
$this->request->get('executive_id');
You can also set default values, if there is no value given. Take a look at this documentation.