Hansmagz Hansmagz - 3 months ago 6
CSS Question

What is the most efficient way to convert this jekyll code to PHP?

What is the most efficient way to convert this jekyll code to PHP?

{% for post in site.posts limit: 12 %}
<a href="{{post.url}}" style="background-image: url(assets/img/posts/thumbnails/{{post.thumbnail}})" class="academic-thumb">
<div class="academic-meta">
<div class="name">
{{post.title}}
</div>
</div>
</a>
{% endfor %}

Answer
<?php
  foreach ($site->getPosts() as $post) {
    echo '
      <a href="'. $post->getUrl() .'" style="background-image: url(assets/img/posts/thumbnails/'. $post->getThumbnail() .')" class="academic-thumb">
    <div class="academic-meta">
        <div class="name">
            '. $post->getTitle() .'
        </div>
    </div>
        </a>';
  }

This is will of course only work if the $post object is available and has gathers for the variables.

You should also listen to @borracciaBlu: study the ruby syntax first and the the php syntax