Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Огранилить вывод краткого описания


kuripka2222
 Share

Recommended Posts

Здравствуйте, помогите пожалуйси догделать вывод краткого описание с ограничением по строкам, словам или знакам (к примеру 200шт.). В конэто надо сгделать троетолие и слово ''Подробнее" как ссылка, при нажатии на которую скролит к вкладке "Описание". 
 

Для вывода я использовал код в файле product.php (в контроллере): 
$data['short_description']=utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..';

И в самом шаблоне:  {{ short_description }}

Игдентификатор полного описания (для ссылки "Подробнее"): id="tab-description"

P.s. 1. Краткое описание берется с полного. 2. Шаблон гдефолтный Opencart/Ostore.

Link to comment
Share on other sites


$data['short_description'] = utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 200) . '..';

 

<div class="description2">
{{ short_description }}<a class="anchor_desc" href="#yakor_desc">подробнее</a>
</div>

 

<script><!--
$('.anchor_desc').click(function(e){
$('a[href="#tab-description"]').tab('show');
var target = $(this).attr('href');
$('html, body').animate({scrollTop: $(target).offset().top}, 800);
return false;
});
//-->
</script >

 

 <li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>

заменить на

 <li id="yakor_desc" class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>

Link to comment
Share on other sites

12 hours ago, mrz said:

$data['short_description'] = utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 200) . '..';

 

<div class="description2">
{{ short_description }}<a class="anchor_desc" href="#yakor_desc">подробнее</a>
</div>

 

<script><!--
$('.anchor_desc').click(function(e){
$('a[href="#tab-description"]').tab('show');
var target = $(this).attr('href');
$('html, body').animate({scrollTop: $(target).offset().top}, 800);
return false;
});
//-->
</script >

 

 <li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>

заменить на

 <li id="yakor_desc" class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>

 Огромное спасипотому что! 

Еещё вопрос, у менять есть фиксированное меню (со скриптом)  как можно дописать код, чтобы прокруливало к вкладке, но высои от верхнего уровнять экрана была 50px или описание налиналось снизу от меню, а не от верхнего края экрана, смотрите на скриншоте
2.jpg.f2c5d6725112334f7a3b6851e040561c.jpg

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.