Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Magento 2 -Limit the length of the product name on the front end.

<?php
$productName = $_helper->productAttribute($_product, $_product->getName(), 'name');
$len = strlen($productName);
?>
<a class="product-item-link" href="<?php echo /* @escapeNotVerified */ $_product->getProductUrl() ?>">
    <?php echo substr($productName,0,50); ?>
    <?php if($len > 50) echo '...'; ?>
</a>
Comment

PREVIOUS NEXT
Code Example
Php :: php pass variable by reference 
Php :: wordpress throw to debug.log 
Php :: php ini_set timeout 
Php :: php home url 
Php :: laravel $loop interation 
Php :: wp display custom fields 
Php :: PHP | get client ip simple 
Php :: foreach loop in php 
Php :: add column in laravel migration 
Php :: laravel inverse seeder 
Php :: share link in facebook php 
Php :: how to one increment after post in laravel collective 
Php :: how count the rout in route.php laravel 
Php :: how to trim white space array in php 
Php :: flutter form autadjust height 
Php :: how unset request parameter in laravel 
Php :: Laravel Validation check array size min and max 
Php :: wordpress get child posts 
Php :: blade foreach key value 
Php :: convert string to lowercase in php 
Php :: laravel required only one of multiple fields not both 
Php :: laravel eloquent get last 
Php :: laravel check if field has changed 
Php :: limit 1 1 in laravel query 
Php :: update-alternatives java 
Php :: cache clear in laravel 
Php :: how to compare two versions in php 
Php :: php mysql get last inserted id 
Php :: where_in codeigniter 
Php :: carbon last day of month in timestamp 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =