How to add the link to the product in twig? - drupal-8

I customized the template :
commerce-product.html.twig
I want to display a link to the product like this but using twig:
How to add the link to the product in twig ?

Related

Django enable URL link in template

I have a blog and users can comment any articles. For now, when they post an URL, we can not follow the link by a clic. Because there is no tag.
I know we can display HTML by using the filter "|safe". But I don't want a user using all html tag for security reasons.
I just want to make URL like "http://google.fr" as active and cliquable.
Any idea ?
The urlize filter does exactly what you want.

how to add new filed to opencart

I want to add three more filed to cart page .()
<input name="pr_name">
<input name="pr_phone >
<input name="pr_add">
can any one help me to add these files to cart .
you will need to modify the following:
the model for the cart /catalog/model/checkout
the controller for the cart /catalog/controller/checkout
the view for the cart whatever theme you are using
finally you will need to do the same for the admin panel and depending on where you would like to see them for example you might want to view them in the invoice you will need to change the model / controller that correspond to that. unfortunately its not like a plug and play thing.

Add list view to Fluid template

I've built a custom extension which displays comments for a page.
But, of course, I want to have the comments section on every page. Is there a way to add it into the Fluid template so that I won't have to add it to every single page?
Looking for something like this:
<f:blabla.bla extension="tx_comment" action="list"/>
You don't need to create your own viewhelper for this. You can use the VHS extension and use render.request
<v:render.request action="[string|NULL]" controller="[string|NULL]" extensionName="[string|NULL]" pluginName="[string|NULL]" vendorName="[string|NULL]" arguments="{foo: 'bar'}" onError="NULL" graceful="1">
<!-- tag content - may be ignored! -->
</v:render.request>
https://fluidtypo3.org/viewhelpers/vhs/master/Render/RequestViewHelper.html

Django-tables2 - how to use a custom filter in a TemplateColumn

I have a TemplateColumn in a django-tables2 table and I want to use a custom template filter (named int_to_time) to transform the data. When I use a built in filter it works fine.
What I have done until now is that I've copied the templates\django_tables2\table.html from django-tables2 to my project and included my tag library to table.html.
However, when I try to render my view, I get the following error:
TemplateSyntaxError at /details_show/2012/3/13/2
Invalid filter: 'int_to_time'
The error seems to be in line 28 of table.html
{% for column, cell in row.items %}
I can confirm that my tag library is loading because if for instance I write the name of the tag library wrong then I will get a Template library not found error.
Please help !
Simplest solution
TemplateColumn renders the column externally to the template. Any custom filters or tags you load in the template won't be available.
You should be able to load the custom filter when you define the TemplateColumn. Something like:
name1 = tables.TemplateColumn('{% load my_filters %}{{ record.name|int_to_time }}')
Alternative (suggested by Bradley in comments)
Instead of using TemplateColumn in the class defining your table. Use a Column, but define a method render_columnname() with the formatting. Something like:
from myfilters import int_to_time
class MyTable(tables.Table):
time = tables.Column()
def render_time(self, value):
return int_to_time(value)
See Table.render_FOO() Methods for more detail.

Customising specific fields in Django Admin change form

I have a couple of fields in my model that to which I wish to add a link that will allow the user to search for names/files (external from the application's database).
So what I would like is:
Field name: [text box] - LINK
Is there a straightforward django way of achieving this?
Cheers.
You need to change the widget that the form field uses to display the models information. You basically add some html after the input to link to where you want.
Here's some code I put together to create a widget that displays how many characters are left for a CharacterField so it's similar to what you are looking to do:
https://github.com/pastylegs/django-widget-charsleft/blob/master/widget_charsleft/widgets.py