HTML Slider Error [closed]

0

Hello! I have an HTML slider and I'm deploying PHP to make it manageable, however, when I put PHP, the slider has stopped working. I think it's an error in the following part of the code:

                echo '<div class="col-md-12" style="top:15px;">';
            echo '<div class="lightbox" data-plugin-options=".{"delegate":"a","gallery":{"enabled":true,"tPrev":"Anterior","tNext":"Pr\u00f3ximo"},"image":{"verticalFit":false}}.">';
            echo '<div class="owl-carousel text-center controlls-over" data-plugin-options=".{"items":1,"singleItem":true,"lazyLoad":true,"navigation":true,"pagination":false,"transitionStyle":"fadeUp","autoHeight":true,"autoPlay":false}.">';
            echo '<div class="item">';

I think the concatenation is wrong. What to do?

    
asked by anonymous 17.01.2017 / 05:21

1 answer

6

The problem here is a mixture of quotes in the HTML part itself.

A simpler way is to close PHP to fall into pure HTML mode, so you can use double and single quotes to separate HTML parameters from JS objects:

<?php
   // ... resto do codigo ...
?>
    <div class="col-md-12" style="top:15px;">
    <div class="lightbox" data-plugin-options="{'delegate':'a','gallery':'enabled':true,'tPrev':'Anterior','tNext':'Pr\u00f3ximo'},'image':{'verticalFit':false}}">
    <div class="owl-carousel text-center controlls-over" data-plugin-options="{'items':1,'singleItem':true,'lazyLoad':true,'navigation':true,'pagination':false,'transitionStyle':'fadeUp','autoHeight':true,'autoPlay':false}">
    <div class="item">
<?php
   // ... resto do codigo ...
?>

Another is to use HEREDOC , if you want to use PHP variables in the future without needing echo :

echo <<<HTML
<div class="col-md-12" style="top:15px;">
<div class="lightbox" data-plugin-options="{'delegate':'a','gallery':'enabled':true,'tPrev':'Anterior','tNext':'Pr\u00f3ximo'},'image':{'verticalFit':false}}">
<div class="owl-carousel text-center controlls-over" data-plugin-options="{'items':1,'singleItem':true,'lazyLoad':true,'navigation':true,'pagination':false,'transitionStyle':'fadeUp','autoHeight':true,'autoPlay':false}">
<div class="item">
HTML;

More details about HEREDOC here:

  

What is it for

17.01.2017 / 08:55