Results 1 to 6 of 6

Thread: [solved] Valid HTML elements in templates changed by php

  1. #1
    User
    Join Date
    03-28-13.
    Location
    Bietigheim-Bissingen
    Posts
    55

    Default [solved] Valid HTML elements in templates changed by php

    Hi. I'm creating a custom template for my news list elements, where I use HTML5 valid code, so I wrap a buch of divs, headline and p's in 1 anchor element, so everything is a big link. In HTML this works without any problem, when I use in my template file, it is completely changed: it makes html4 valid, so puts a lot of anchor tags around the texts, and where it's not possible, there places only empty anchor elements.

    I've saw this problem already in other CMS's, too, but there I came up with another structure. Here, it would be important this. If somebody has any ideas, that would be awesome
    Thanks!
    Last edited by zoltanseer; 08/14/2014 at 11:51. Reason: Solved

  2. #2

    Default

    Hi,

    Can you put the code here ?
    I have done some anchors for a project and I didn't have any problems.

  3. #3
    User
    Join Date
    03-28-13.
    Location
    Bietigheim-Bissingen
    Posts
    55

    Default

    So basically this is a list of news (template):
    HTML Code:
    <a href="<?php echo $this->link;?>">
      <div class="meta">
        <img src="<?php echo $this->singleSRC;?>" alt="">
        <time itemprop="dateCreated" datetime="<?php echo date("Y-m-d", $this->timestamp);?>"><?php echo date("d.m.Y", $this->timestamp);?></time>
      </div>
    
      <div class="news-content defpadding">
         <!-- Max char 75 -->
         <h2><?php echo $this->linkHeadline;?></h2>
         <!-- Max char 190 -->
         <?php echo $this->teaser;?>
      </div>
    </a>
    and this is what I get back:
    HTML Code:
    <a href="aktuelles/das-abenteuer-erste-liga-beginnt-5.html">
      <div class="meta">
        <img src="files/SGBBM/SGBBM/Bilder/Aktuelles/news_square.jpg" alt="">
        <time itemprop="dateCreated" datetime="2014-08-13">13.08.2014</time>
      </div>
    </a>
    <div class="news-content defpadding">
      <a href="aktuelles/das-abenteuer-erste-liga-beginnt-5.html">
         <!-- Max char 75 -->
      </a>
      <h2>
        <a href="aktuelles/das-abenteuer-erste-liga-beginnt-5.html"></a>
        <a href="aktuelles/das-abenteuer-erste-liga-beginnt-5.html" title="Den Artikel lesen: Das Abenteuer Erste Liga beginnt 5">Das Abenteuer Erste Liga beginnt 5</a>
      </h2>
      <!-- Max char 190 -->
      <p>Lorem ipsum text</p>          
    </div>
    ...no idea why (I removed the comments, and every extra line, still not good)

  4. #4

    Default

    Hum. Weird..

    I think it comes from :
    PHP Code:
    <?php echo $this->linkHeadline;?>
    If you just show this line, what happens ?

  5. #5
    User
    Join Date
    03-28-13.
    Location
    Bietigheim-Bissingen
    Posts
    55

    Default

    AAaa, I don't know who you are, but I will find you, and I will buy you a beer linkHeadline outputs a link, too (which is quite normal) and browsers don't really like anchors in anchors I changed to $this->headline, now everything is ok. Thanks again!

  6. #6

    Default

    A beer ! This is so much what I need XD

    If you want a HTML5 template, I give you some advices :

    - Put each news item into an "<article>"
    - Your <time> should be on the pattern :
    PHP Code:
    <time datetime="<?php echo $this->datetime?>" title="<?php echo $this->date?>" pubdate><?php echo $this->date?></time> <span itemprop="author"><?php echo $this->author?></span> <span itemprop="commentCount" content="<?php echo $this->numberOfComments?>"><?php echo $this->commentCount?></span>
    Remove author and comments if you don't have.

    - Your <img> should be in a <figure> tag :
    PHP Code:
    <?php if ($this->addImage): ?>
    <figure class="image_container<?php echo $this->floatClass?>"<?php if ($this->margin): ?> style="<?php echo $this->margin?>"<?php endif; ?>>
          <?php if ($this->href): ?>
            <a href="<?php echo $this->href?>"<?php echo $this->attributes?> title="<?php echo $this->alt?>">
          <?php endif; ?>
          <img src="<?php echo $this->src?>"<?php echo $this->imgSize?> alt="<?php echo $this->alt?>">
          <?php if ($this->href): ?>
            </a>
          <?php endif; ?>
          <?php if ($this->caption): ?>
            <figcaption class="caption" style="width:<?php echo $this->arrSize[0]; ?>px"><?php echo $this->caption?></figcaption>
          <?php endif; ?>
        </figure>
    <?php endif; ?>
    - And you can use <summary> / <details> tag on your teaser if he's too long.


    All SEO / HTML5 in this page : http://schema.org/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •