I'm not sure if I've used the correct terminology but this is what I want to achieve.

I want to combine two php "commands" to output the title tag as follows:

So the title shows "Shoes by Nike"

The code I'm using is

title="<?php echo $this->htmlEscape($_product->getName()) ?> by <?php echo $_product->getAttributeText('company'); ?>"

Where <?php echo $this->htmlEscape($_product->getName()) ?> brings up shoes

and <?php echo $_product->getAttributeText('company'); ?>" brings up company

  • Did you mean this? title="<?php echo $this->htmlEscape($_product->getName().' by '.$_product->getAttributeText('company')) ?>" – Danny Dev Nz Mar 7 '18 at 2:30

Try this:

title="<?php echo $this->htmlEscape($_product->getName().'by'. $_product->getAttributeText('company')) ?>"

What i just understand is, you want to output Shoes by Nike, You are getting Shoes from different function and Nike from different function, and you want to concatenate these two. It can be done like that.

$prod_name = $this->htmlEscape($_product->getName());
$company = $_product->getAttributeText('company');
echo $prod_name." by ".$company;

You can append the string and add in your title

$title = $this->htmlEscape($_product->getName()) . "by" . $_product->getAttributeText('company'); 

Add it in your html part

title="<?php echo $title; ?>"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.