Skip to content

Commit

Permalink
add link to tags
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfeng authored and sunfeng committed Jan 5, 2013
1 parent f4bf5a7 commit 653ce8c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/Blogger/BlogBundle/Entity/Blog.php
Expand Up @@ -268,6 +268,15 @@ public function getTags()
return $this->tags;
}

public function getTagsLink()
{
$tags = array();
if ($this->getTags() != '') {
$tags = explode(',', $this->getTags());
}
return $tags;
}

/**
* Set hits
*
Expand Down
3 changes: 2 additions & 1 deletion src/Blogger/BlogBundle/Entity/Repository/BlogRepository.php
Expand Up @@ -73,9 +73,10 @@ public function getTagWeights($tags)
public function getBlogsForTag($tag, $limit = null)
{
$qb = $this->createQueryBuilder('b')
->select('b, c')
->select('b, c, ct')
//->where('FIND_IN_SET(":tag", b.tags)')
->leftJoin('b.comments', 'c')
->leftJoin('b.category', 'ct')
->addOrderBy('b.created', 'DESC');
//->setParameter('tag', strtolower(trim($tag)));

Expand Down
Expand Up @@ -24,7 +24,11 @@
<p>Category: <a href="{{ path('blogger_blog_page_category_blogs', { 'slug': blog.category.slug }) }}">{{ blog.category.name }}</a></p>
<p>Comments: <a href="{{ path('blogger_blog_blog_show', { 'slug': blog.slug }) }}#comments">{{ blog.comments|length }}</a></p>
<p>Posted by <span class="highlight">{{ blog.author }}</span> at {{ blog.created|date('h:iA') }}</p>
<p>Tags: <span class="highlight">{{ blog.tags }}</span></p>
<p>Tags:
{% for tag in blog.tagsLink %}
<a href="{{ path('blogger_blog_page_tag_search', { 'tag': tag|trim }) }}">{{ tag|trim }}</a>
{% endfor %}
</p>
<p>Hits: <span class="highlight">{{ blog.hits }}</span></p>
</footer>
</article>
Expand Down
6 changes: 5 additions & 1 deletion src/Blogger/BlogBundle/Resources/views/Page/index.html.twig
Expand Up @@ -20,7 +20,11 @@
<p>Category: <a href="{{ path('blogger_blog_page_category_blogs', { 'slug': blog.category.slug }) }}">{{ blog.category.name }}</a></p>
<p>Comments: <a href="{{ path('blogger_blog_blog_show', { 'slug': blog.slug }) }}#comments">{{ blog.comments|length }}</a></p>
<p>Posted by <span class="highlight">{{ blog.author }}</span> at {{ blog.created|date('h:iA') }}</p>
<p>Tags: <span class="highlight">{{ blog.tags }}</span></p>
<p>Tags:
{% for tag in blog.tagsLink %}
<a href="{{ path('blogger_blog_page_tag_search', { 'tag': tag|trim }) }}">{{ tag|trim }}</a>
{% endfor %}
</p>
<p>Hits: <span class="highlight">{{ blog.hits }}</span></p>
</footer>
</article>
Expand Down
Expand Up @@ -21,9 +21,14 @@
</div>

<footer class="meta">
<p>Category: <a href="{{ path('blogger_blog_page_category_blogs', { 'slug': blog.category.slug }) }}">{{ blog.category.name }}</a></p>
<p>Comments: <a href="{{ path('blogger_blog_blog_show', { 'slug': blog.slug }) }}#comments">{{ blog.comments|length }}</a></p>
<p>Posted by <span class="highlight">{{ blog.author }}</span> at {{ blog.created|date('h:iA') }}</p>
<p>Tags: <span class="highlight">{{ blog.tags }}</span></p>
<p>Tags:
{% for tag in blog.tagsLink %}
<a href="{{ path('blogger_blog_page_tag_search', { 'tag': tag|trim }) }}">{{ tag|trim }}</a>
{% endfor %}
</p>
<p>Hits: <span class="highlight">{{ blog.hits }}</span></p>
</footer>
</article>
Expand Down

0 comments on commit 653ce8c

Please sign in to comment.