• 11-03-2022, 20:44:40
    #1
    Merhaba, FAQ Scheme yapmaya çalıştım döngüyü kurdum. Ancak Döngü sonunda virgül kalması nedeniyle hata alıyorum. Nasıl çözebilirim? Ücretli destek verecekler özelden yazabilir.

    Teşekkürler

      <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "FAQPage",
      "mainEntity": [ <?php
            foreach($sorular["data"] as $soru)
            {
            ?>{
        "@type": "Question",
        "name": "soru...",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "cevap..."
        }
      },
                        <?php
            }
            ?>
      ]
    }
    </script>
    Olması gereken

    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "FAQPage",
      "mainEntity": [{
        "@type": "Question",
        "name": "soru",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "cevap"
        }
      },{
        "@type": "Question",
        "name": "soru2",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "cevap2"
        }
      }]
    }
    </script>
  • 11-03-2022, 21:01:18
    #2
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "FAQPage",
      "mainEntity": [ <?php
            foreach($sorular["data"] as $soru)
            {
            ?>{
        "@type": "Question",
        "name": "soru...",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "cevap..."
        }
      }
      <?    if ($soruid < 4) { echo ",";} ?> 
                        <?php
            }
            ?>
      ]
    }
    </script>
    Virgül koymayı şarta bağlarsan sorun olmaz. Örneğin 4 kayıt var. 4. kayıttan sonra virgül koymasın.
  • 11-03-2022, 21:05:06
    #3
    burhan49 adlı üyeden alıntı: mesajı görüntüle
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "FAQPage",
      "mainEntity": [ <?php
            foreach($sorular["data"] as $soru)
            {
            ?>{
        "@type": "Question",
        "name": "soru...",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "cevap..."
        }
      }
      <?    if ($soruid < 4) { echo ",";} ?>
                        <?php
            }
            ?>
      ]
    }
    </script>
    Virgül koymayı şarta bağlarsan sorun olmaz. Örneğin 4 kayıt var. 4. kayıttan sonra virgül koymasın.

    Teşekkürler denedim ancak malesef olmadı. Örnek olarak 3 soru varsa döngü çalışıyor 3 virgül koyuyor. 4 soru varsa hiç virgül koymuyor.
  • 11-03-2022, 22:03:01
    #4
    [COLOR=#515365][FONT=consolas]<script type="application/ld+json">[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]{[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]  "@context": "https://schema.org",[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]  "@type": "FAQPage",[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]  "mainEntity": [ <?php[/FONT][/COLOR]
    $gid = 1;
    [COLOR=#515365][FONT=consolas]        foreach($sorular["data"] as $soru)[/FONT][/COLOR]
    $gid++;
    [COLOR=#515365][FONT=consolas]        {[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]        ?>{[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]    "@type": "Question",[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]    "name": "soru...",[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]    "acceptedAnswer": {[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]      "@type": "Answer",[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]      "text": "cevap..."[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]    }[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]  }[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]<?    if ($gid <= $sorusayisi) { echo ",";} ?> [/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]                    <?php[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]        }[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]        ?>[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]  ][/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]}[/FONT][/COLOR]
    [COLOR=#515365][FONT=consolas]</script>[/FONT][/COLOR]
  • 11-03-2022, 22:05:24
    #5
    <script type="application/ld+json">
    {
    "@context": "https://schema.org",
    "@type": "FAQPage",
    "mainEntity": [ <?php
    $gid = 1;
    foreach($sorular["data"] as $soru)
    $gid++;
    {
    ?>{
    "@type": "Question",
    "name": "soru...",
    "acceptedAnswer": {
    "@type": "Answer",
    "text": "cevap..."
    }
    }
    <? if ($gid <= $sorusayisi) { echo ",";} ?>
    <?php
    }
    ?>
    ]
    }
    </script>
  • 11-03-2022, 22:25:06
    #6
    burhan49 adlı üyeden alıntı: mesajı görüntüle
    <script type="application/ld+json">
    {
    "@context": "https://schema.org",
    "@type": "FAQPage",
    "mainEntity": [ <?php
    $gid = 1;
    foreach($sorular["data"] as $soru)
    $gid++;
    {
    ?>{
    "@type": "Question",
    "name": "soru...",
    "acceptedAnswer": {
    "@type": "Answer",
    "text": "cevap..."
    }
    }
    <? if ($gid <= $sorusayisi) { echo ",";} ?>
    <?php
    }
    ?>
    ]
    }
    </script>
    Çok teşekkür ederim ufak düzeltme yaptım çalıştı. Benzer sorun yaşayanlar bunu uygulayabilir.

        <script type="application/ld+json">
    {
    "@context": "https://schema.org",
    "@type": "FAQPage",
    "mainEntity": [ <?php
    $gid = 1;
    foreach($sorular["data"] as $soru)
    {
    ?>{
    "@type": "Question",
    "name": "soru...",
    "acceptedAnswer": {
    "@type": "Answer",
    "text": "cevap..."
    }
    }
    <? $gid++; if ($gid <= $sorusayisi) { echo ",";} ?>
    <?php
    }
    ?>
    ]
    }
    </script>