A
A
Aieron2019-11-29 23:41:05
MODX
Aieron, 2019-11-29 23:41:05

How to add a category name to an image in ALT?

Hello. I need to add a category name to the alt for an online store to get a
category + product name. Now it takes pagetitle which is the title of the product. Please help me understand how to implement this. Thank you. This is a piece that is responsible for displaying imgs from the tpl.msProducts.row.ext chunk.
This thing displays the name of the category. $_modx->resource.pagetitle but they don't link together.
tried to write {$_modx->resource.pagetitle : $pagetitle } was not understood by modx ))

<a href="{$id | url}">
    	
      {if $small}
      
          <div class="img_wrap"><img src="{$small}" alt="{$pagetitle}" title="{$pagetitle}"/></div>
          
      {elseif $image?}
      
      	<div class="img_wrap"><img src="{'phpThumbOn' | snippet : ['input' => ($image), 'options' => 'wl=200&hp=200&hs=200']}" alt="{$pagetitle}" title="{$pagetitle}"/></div>
      	
      {else}
      	<div class="img_wrap"><img src="{'assets_url' | option}components/minishop2/img/web/ms2_small.png"
               srcset="{'assets_url' | option}components/minishop2/img/web/[email protected]2x.png 2x"
               alt="{$pagetitle}" title="{$pagetitle}"/></div>
      {/if}
             
      <p>{$pagetitle}</p>
      
    </a>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bxspb, 2019-11-30
@bxspb

What makes you so stormy, sometimes with a hair dryer, then ... not with a hair dryer))
{$_modx->resource.parent | resource : 'pagetitle'}
or
2 - I guess pdoTools is installed once you use MS2.

A
Aieron, 2019-11-30
@Aieron

O! Connected, all of a sudden someone also needs it, this is how it works
But I definitely won’t be able to do this ((( how can I write alt and title so that the page title is also displayed?

<a class="part_link" href="" data-link=""><img src=""></a>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question