Dear drupaler,
I've a problem that don't understand how solve, I've search it in all the web but really nothing to help me found,
I'll try to explain it.

PRE: I've a Mac and MAMP and Installed Druapl 8 via composer.

I made a view with personalized fields like title, image, and more information (this works fine), now I would to override the output of
fields for example I use core/modules/views/templates/views-view-field.html.twig and override it as views-view-field---[view machine name]--[view display id]--[field].html.twig (workaround works),
now would like combine to build a HTML code and TWIG code in a TWIG file, the file that contains {{ output -}}.

I've installed DEVEL with KINT submodules and when I use kint(output) the system getting to me HTML rendered result,
Into the head of file I reading:
* Available variables:
* - view: The view that the field belongs to.
* - field: The field handler that can process the input.
* - row: The raw result of the database query that generated this field.
* - output: The processed output that will normally be used.

If I try to kint(field) the system getting to me ERROR 500, I found the solution to set Kint::$maxLevels = 6;
and upgrade maximum_memory_limit to 1024MB (now kint() works).

Good!! when launch kint(field) a lot of information show to me , but I don't found the basic infos to build HTML and TWIG combined code
to manage this field...

For example if the field of view is an image I think thant into the "field" variable (launched with kint(field))
I could to found info to build html like:
-img src
-alt text
-height img
-width img
-title img

then I could override {{ output -}} to

<div>
<a href={{ link_to_href }}
<img src="{{scr_img }}" alt="{{ alt_img_text }}"/>
</a>
<div> Text example 1 </div>
<div> Text example 2 </div>
<div>

But nothing works beacause this info is not here in field or row variables!!!!

Where there infos are?
Correct is override views-view-field.html.twig?
How can getting this infos and how can access to it (I'm getting that the best practice is use "dot notation"
but what rules for it and what is the differece by protected and public infos showed by kint?)

Comments

mmjvb’s picture

Looks like you look for information on the wrong level.
See Fields in https://www.drupal.org/docs/8/theming/twig/twig-template-naming-conventions

Nil.Ned’s picture

Thank you @mmjvb for your reply,
You suggest to me of use field.html.twig, I tried to override it with field--field_name_image.html.twig but this works only when call node in a node-template not when call results from a view...

mmjvb’s picture

Suggest to use debugging to find out which template applies in your situation.

Nil.Ned’s picture

Dear mmjvb,
I tried to override views-view-field.html.twig with views-view-field--[name_view]--[name-page]--[name-field].html.twig

The system is very slow but I got result using kint(row), I don't understand where and how can I getting the info about some field,

for example if I use kint(row) of field image before described I have this results:
View result level 0
Then if I open the _entity and I 'got:
View result leve0.1
and
View result leve0.1

how can I get the value of field called field_image_place ? the "alt text" "height" "width" "src"?
Where this info is stored?
I try to use something like:
{{ kint(row._entity) }} (this ok) and then {{ kint(row._entity.field_image_place.value) }} (this break)

mmjvb’s picture

Don't know enough about debugging with kint.

Nil.Ned’s picture

Dear mmjvb,
thankyou for your assistance... I appreciate it :-)

Do you know how can get info fields informations like described before and what the rules are for dot notation in drupal?

Thank you so much

p.s. I hope that this question helps someone that have problems like me :-)

cmsMinds’s picture

Nil.Ned,

In views if you want to set attributes(height, width) of images then you can set in by image style where you can set these values.

Nil.Ned’s picture

Dear cmsMinds,
Thank you for answer and support :-)... probably I lost the focus in prev response ...

I know that I can use style image to manage the height/width/crop and a lot of property of image (I use it as in D7),
as wrote in a title I have difficulty like "How get info fields when Override template on Drupal 8?" (all info's field
like property of image height/width/etc etc)

I suppose that all info are in row variables of template but I can't see it.

Please can you post here an example of you get info's array about field in a view (best is using something like
{{ kint(row. ... . ... . ...) }}?

Thank you for the support and I hope that I explane well :-)

Nil.Ned’s picture

Upgrade:
I solve partially a problem:
for getting partial info I use this code:

{{ kint(row._entity.field_image_place.target_id) }}
{{ kint(row._entity.field_image_place.alt) }}
{{ kint(row._entity.field_image_place.height) }}
{{ kint(row._entity.field_image_place.width) }}

now I would access to uri/url of image elabored by image style.

How can access to it?

Thank you so much for everyone can help me

Nil.Ned’s picture

Hi friends...
sorry if I re-open it, but I not found already solution for my problem.

I would like replace output info in twig template but I don't understand how can I do it.

I tried to analize "array's field" override output and "array's fields" override output but I don't found info's field... I'm getting crazy.

Where can I get attributes of image_field for replace output field?
How override twig template when I get processed attributes field and replace it?

can someone help me please ...

Before in D7 was more simple I override template using fore xample $node something like:
$node->field_image['und'][0]['uri']
and now why can't or how can I get it?

Thank you if someone can help me

aiglesiasn’s picture

I got a lot of trouble trying to override views-view-field.html.twig, but manage to obtain uri by:

In the View creating a Relationship to a File, and then on the template used:

{{ file_url(view.field.uri.original_value) }}

Hope this help someone.